Closed t-oster closed 7 years ago
I think the stuff added with the latest merge does what you're looking for by adding the setting method to the Synth object. To do what you described, for example:
fs = fluidsynth.Synth()
fs.setting(audio.period-size: 64)
fs.setting(audio.periods: 3)
fs.setting(synth.chorus.active: False)
fs.setting(synth.reverb.active: False)
fs.start()
I tried the new version, unfortunateley it does not produce any sound on the banana pi. It does not throw errors and I tried both versions with exactly the same python file. The old version works, the new one not. So I cannot try if the new options reduce the latency. Fluidsynth itself (without python) works fine. Are there other changes which I need to make?
Sorry for all the self commenting. I used git bisect
(great tool) in order to narrow it down to commit 650f872c85ef1e4d8bbacde28863b92b0f0e9115. My simple test code is:
import time
import fluidsynth
fs = fluidsynth.Synth(samplerate=48000,gain=0.8)
fs.start("alsa")
sfid = fs.sfload("/usr/share/sounds/sf2/FluidR3_GM.sf2", 1)
fs.program_select(0, sfid, 0, 0)
print("Midi loaded...")
notes = [44,36,38,46,45,48]
print("testing...")
for n in notes:
fs.noteon(9, n, 100)
fs.noteoff(9, n)
time.sleep(0.5)
print("done")
This produces sound on a banana pi until commit 650f872c85ef1e4d8bbacde28863b92b0f0e9115. After that it does not throw any error and I can hear that the audio device is opened (kind of white noise), but there is no drum sound. Any idea?
..also tested on my notebook. Same problem, no sound. So this is not raspberry/bananapi/arm related...
This shouldn't work differently in the newer commit, but you might try specifying the hardware-layer audio device rather than letting it use the default. The device
parameter is passed to the audio driver, so for ALSA something like hw:Device,0
may work. Also, it looks a bit weird to me that your code has no time delay between noteOn
and noteOff
events, although I can't see why that would suddenly act differently between commits either.
The missing delay is normal for drum notes as far as I know. I will try the device setting. Thanks for the fast answer.
Changing device to "hw:0,0" does'nt output sound either, while not throwing any error message. I am on fluidsynth 1.1.3, do I need a newer version? Is the api-version variable in the code related to fluidsynth or to pyfluidsynth? I am on Linux Mint 17 on my notebook. Can anyone confirm the problem?
Here is a working fluidsynth wrapper I wrote that uses pyfluidsynth. Check out line 520 where fluidsynth is invoked - maybe you can compare and spot a difference that is causing the issue.
Look at this line https://github.com/nwhitehead/pyfluidsynth/blob/master/fluidsynth.py#L497
it's a simple one-tab-too-much
issue!!!
That would do it! Thanks!
Thank you. After fixing #7 your suggested parameters did reduce the latency significantly.
Hi,
I am building a RaspberryPi based E-Drum with this. It is working and if I use pyfluidsynth on my Notebook, the latency is good, but if I use it one the PI, the latency is way to big (seems like a delay of 300-500ms). here (https://raspberrypi.stackexchange.com/questions/14987/midi-keyboard-latency-with-fluidsynth) the suggestion is to fiddle with buffer sizes and turn of chorus etc. Is there any way to do this with pyfluisynth?