jisungk / deepjazz

Deep learning driven jazz generation using Keras & Theano!
http://deepjazz.io
Apache License 2.0
2.88k stars 443 forks source link

How to locate Melody Piece index? (melody_stream = midi_data[5]) #17

Open srianbury opened 6 years ago

srianbury commented 6 years ago

I've been trying to run this program but I've run into an error. On line 24 of preprocess.py (https://github.com/jisungk/deepjazz/blob/b0aa6ca1b91be6ddf081fc05ebfeefa89cc4b848/preprocess.py#L24) the melody is at index 5. Does anyone know how he found this? Was it guess and check? Is there a way to easily know where the melody is? Either way, if there is a method or it's guess and check does anyone know how to find it?

hasagar97 commented 6 years ago

Facing the same issue. Did you find the solution @srianbury ?

srianbury commented 6 years ago

@hasagar97 Yes I found a solution, kind of. The 5, and many of the other parts are hard-coded specifically for this song. If you run this program with a debugger you can see that the information at the 5th index of midi_data is different than the rest, I think, and it's an object of type instrument or something, if I remember correctly. I was using mp3s and found a converter to MIDI and the melody was always placed at midi_data[0] so I was able hard code that and know it would work for anything because of the converter. I don't know if there's a method to write to detect melody, but making sure you put it in the same place every time helped me

yunjiewang commented 5 years ago

You can import the midi file into a scorewriter like MuseScore. Then read the score or even playback to confirm that Pat's part, which is named "Cavaquinho, Guitar", is the 6th part. (Hence index=5)

cvantass commented 5 years ago

I've been trying to use my own midi files, and figured out pretty quickly that since they only consist of one part, that the index here needed to be 0. However, once I do that, a number of other errors pop that also have to do with the fact that i'm not using the piece that this program was hard-coded for. Has anyone here figured out a way around this?