r/Python • It works on my machine • Oct 28 '24

Showcase Algorithmic Music Generation with Python

Hi, all. I've been building this Python program on the side when I find time from my full time job for the last month or so. It's nowhere near finished but I wanted to share what I'm building with you guys just to get some feedback. I will keep posting updates about this project as I itterate.

Finally this project got to a point where the output sounds pleasant to me so I wanted to see If I'm the only one or am I on the right track. There is still a lot that doesn't work with this project as I can't find a lot of time to work on it.

There are some example videos on the Github page. UI on the videos are from an older version, so if you decide to run it for yourself (Which I don't recommand. Its really not worth the hastle right now.) you're gonna see a different UI with correct keys on the animations as opposed to the ones on the videos.

What works:

It picks a starting note. Based on the starting note and the defined scale, It picks 4 chords. It picks a way of playing those chords in terms of their timings. It picks random notes in the correct scale to generate a melody. It adds a very very simple drum loop on top of all. It shows what is being played on the screen as it plays. if you press f on terminal, it allows you to play freely with your pc keyboard using fl studio key bindings.

What I'm working on:

  • UI with buttons for start, stop freeplay, output midi, record screen.
  • More instruments, especially bass.
  • More drum patterns.
  • More complex melody algorithm to create intro verse chorus.

Please let me know what other features whould you expect from a program like this. I'm open to any kind of feedback. Let me know what you think.

  • What My Project Does: It algorithmically generates music.
  • Target Audience: just a toy project.
  • Comparison: Compared to other music generation libraries this one doesn't use AI to generate the music so it gives you complete control over the output.

Github

27 Upvotes

12 comments sorted by

View all comments

Show parent comment

5

u/Atiriko It works on my machine Oct 28 '24

Thanks a lot mate. I first started doing it like you did but I could never get the timing right. Then I decided to write a scheduler. So now I first generate chordprogression, melody, drums each adding to scheduler their events. Each event kind of looks like this.

class Event:  
    def __init__(self, channel, note, time,length, velocity = 112):
        self.channel = channel
        self.note = note
        self.velocity = velocity
        self.time = time
        self.length = length

So by the time it starts playing, scheduler knows which notes to play at which channel with which velocity for how long.