Share your repls and programming experiences

← Back to all posts
A python program that makes semi-random music

This program makes random music by choosing a root note for the key and whether it will be major or minor, then, based on those things it semi-randomly generates notes and adds them to a midi object using midiutil. (I say semi-randomly because I added a sort of 'bias' to certain intervals to make it sound more melodic). The program will make a midi file called 'song.mid' and print the notes in the console, the output is read like so: <NOTE_NAME> <MIDI_NUM> <DURATION>. the duration is in bpm and all pieces are written with a speed of 180bpm. I developed this alone and, sadly as I did most of it on vacation I had to use my phone and pythonista for most of the development and did not end up with time to get playback working on, so you will most likely need an external program to play the midi files (at least wouldn't play them for me...).