pretty-midi
pretty-midi copied to clipboard
fluidsynth: error: Unknown integer parameter 'synth.sample-rate'
Hi Colin. I wonder if you might have any suggestions for the following.
I'm noticing an error on my Mac with new versions of pyfluidsynth, pretty-midi and fluidsynth, when I try to run the following code
import pretty_midi
_SAMPLING_RATE = 16000
sample_file = 'maestro-v2.0.0/2013/ORIG-MIDI_03_7_6_13_Group__MID--AUDIO_09_R1_2013_wav--2.midi'
pm = pretty_midi.PrettyMIDI(sample_file)
waveform = pm.fluidsynth(fs=_SAMPLING_RATE) # <--- this line is where the error occurs
That code still works fine on Colab (e.g. in the Tensorflow RNN MIDI demo), but running on my Mac, I get:
fluidsynth: error: Unknown integer parameter 'synth.sample-rate'
On the Mac, I'm getting the error message with both pyfluidsynth versions 1.3.1 and 1.3.2.
Any idea how one might fix this? Thanks.
$ fluidsynth --version
FluidSynth runtime version 2.3.4
Screenshot from my notebook.
Aha! As per this Closed pyfluidsynth Issue from earlier this year, setting the sample rate to be a float instead of an int makes the error go away.
i.e.
_SAMPLING_RATE = 16000.0
is the fix. Unclear to me why this only shows up on the Mac and not Colab. 🤔
Feel free to close this Issue.
Should we change this: https://github.com/craffel/pretty-midi/blob/0ada945d18d1cbc498db957a715ddee8944c64e6/pretty_midi/fluidsynth.py#L15 to a float then?
What if you just multiplied the sample rate by 1.0 when calling fluidsynth itself? e.g. on line 60
synthesizer = fluidsynth.Synth(samplerate=fs*1.0)
? (To me, this strategy is just a workaround for an issue that "really" should be fixed on fluidsynth's end. )
Better to call float on it, but yes.
Hello there, this issue seems to be fixed on pyfluidsynth 1.3.3 now