pyfluidsynth
pyfluidsynth copied to clipboard
How to implement play_midi_file?
I've tried the below code but only get '0' as output and no sound. I feel like I'm missing something but couldn't figure it out from the documentation.
fs = fluidsynth.Synth()
fs.start()
sfid = fs.sfload(sound1)
fs.program_select(0, sfid, 0, 0)
fs.play_midi_file(midi_path)
fs.play_midi_stop()
The below code did work for me:
fs = fluidsynth.Synth()
fs.start()
sfid = fs.sfload(sound1)
fs.program_select(0, sfid, 0, 0)
fs.noteon(0, 60, 100)
fs.noteon(0, 67, 100)
fs.noteon(0, 76, 100)
time.sleep(1.0)
fs.noteoff(0, 60)
fs.noteoff(0, 67)
fs.noteoff(0, 76)
time.sleep(1.0)
fs.delete()
Same problem, but discovered the problem is script ending soon. Avoid it with a sleep() or doing something else (playing notes, etc). This works for me.
fs = fluidsynth.Synth()
fs.start()
sfid = fs.sfload(sound1)
fs.play_midi_file(midi_path)
time.sleep(midi_duration) #or something else that avoid script end
Sorry if something is wrong, my first post on github and i'm not english-speaker.
@emilycardwell Does the solution proposed by @astrolozano work for you?
Closing this as inactive. Feel free to re-open if you think there is still an issue.