[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [fluid-dev] [SOLVED] How to send manual midi commands to fluidsynth
From: |
John O'Hagan |
Subject: |
Re: [fluid-dev] [SOLVED] How to send manual midi commands to fluidsynth from another program? |
Date: |
Mon, 13 Oct 2008 05:31:06 +0000 |
User-agent: |
KMail/1.9.9 |
On Sun, 12 Oct 2008, Pedro Lopez-Cabanillas wrote:
> John O'Hagan wrote:
> > Hi,
> >
> > I'm writing an algorithmic music program which generates lists of numbers
> > representing notes and durations. The results can be printed as scores
> > and played as midi files using lilypond, and to play the results as they
> > are generated (i.e., bar by bar), I'm using the sox synth.
> >
> > That's pretty limited, however, so I thought that fluidsynth might be the
> > way forward.
> >
> > The simplest solution would be to translate my number lists into noteon
> > commands, etc, and pipe them to fluidsynth.
> >
> > But I need a little help understanding the fluidsynth shell.
> >
[...]
>
> Use the TCP/IP shell server mode. QSynth enables it in Linux, or you can
> enable it in the command line client with the argument "-s, --server". By
> default, the shell port is 9800/tcp, but you can change the number with the
> setting "shell.port", for instance:
>
> $ fluidsynth -i -s -o "shell.port=9988" ...
>
> To send commads to the shell server, use the telnet protocol:
>
> $ telnet localhost 9988
> noteon 1 66 100
> noteoff 1 66
Great! I'm using Python, and this is how I did it in my program (Python code
follows):
from telnetlib import Telnet
fluid = Telnet("localhost","9800")
fluid.write("noteon 1 46 64 \n noteon 1 49 64 \n noteon 1 53 64 \n")
It's as simple as that. As an added bonus, it's easy to do chords (as in the
above example) or other simultaneous messages with a single command.
> ...
>
> Using the bash shell, or a bash script:
> $ echo "noteon 1 60 100" > /dev/tcp/localhost/9988
> $ echo "noteoff 1 60" > /dev/tcp/localhost/9988
I don't seem to have those directories in /dev, and I have to be root to
create them. Even when I do, the commands above (or their Python equivalents)
don't produce a response from Fluidsynth. Given that I don't know the telnet
protocol from a hole in the ground, my ignorance on the subject is
undoubtedly the issue here.
Anyway, I'm very happy with the above solution.
> Hope this helps.
Sure does!
Regards,
John