pretty-midi icon indicating copy to clipboard operation
pretty-midi copied to clipboard

fluidsynth: error: Unknown integer parameter 'synth.sample-rate'

Open drscotthawley opened this issue 2 years ago • 5 comments

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. Screenshot 2023-11-03 at 6 12 50 PM

drscotthawley avatar Nov 03 '23 23:11 drscotthawley

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.

drscotthawley avatar Nov 03 '23 23:11 drscotthawley

Should we change this: https://github.com/craffel/pretty-midi/blob/0ada945d18d1cbc498db957a715ddee8944c64e6/pretty_midi/fluidsynth.py#L15 to a float then?

craffel avatar Nov 06 '23 16:11 craffel

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. )

drscotthawley avatar Nov 09 '23 00:11 drscotthawley

Better to call float on it, but yes.

craffel avatar Nov 09 '23 01:11 craffel

Hello there, this issue seems to be fixed on pyfluidsynth 1.3.3 now

yawjalik avatar Feb 19 '24 00:02 yawjalik