I've been working with Fluidsynth on a Raspberry Pi B running Raspian (not the absolute latest image because Fluidsynth wouldn't run on the latest version but from at least April 2014).
I start Fluidsynth by running fluidsynth -a alsa -g 1 -s -o "shell.port=9800" /path/to/FluidR3_GM.sf2
I am able to get the expected audio output using Fluidsynth's own shell with commands like noteon 1 54 100
, and I can also get audio to play using a telnet server from a separate command line using:
telnet localhost 9800
and then typing standard noteon
commands into the subshell it spawns.
My ultimate goal, though, is to send these telnet commands from python.
I've tried the following code, which returns no errors:
>>> from telnet lib import Telnet
>>> fluidsynth = Telnet("localhost","9800")
>>> fluidsynth.write('noteon 1 25 127')
But this fails to produce any kind of sound.
At this point I've hit a wall, and I have no idea why the python statements won't work but the statements in the command shell will. Wouldn't they be doing the exact same thing? Am I missing some subtlety of the telnet protocol?
Add a newline character to the end of the string you pass to
write
: