[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: |
Pedro Lopez-Cabanillas |
Subject: |
Re: [fluid-dev] [SOLVED] How to send manual midi commands to fluidsynth from another program? |
Date: |
Mon, 13 Oct 2008 20:29:57 +0200 |
User-agent: |
KMail/1.9.6 (enterprise 20070904.708012) |
John O'Hagan wrote:
> 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")
Note that FluidSynth doesn't follow strictly the telnet protocol, so you can
use something simpler. The command line utility netcat(1) (or 'nc') is
perfect for this purpose:
[~]$ netcat localhost 9800
noteon 1 66 100
noteoff 1 66
quit
cheers!
[~]$
What I mean is that you can use simple TCP/IP sockets and text streams,
instead of the telnet class.
#!/usr/bin/python
import sys
import time
from socket import *
serverHost = "localhost"
serverPort = 9800
s = socket(AF_INET, SOCK_STREAM)
s.connect((serverHost, serverPort))
s.send("noteon 1 66 100\n")
time.sleep(1)
s.send("noteoff 1 66\n")
s.send("quit\n")
data = s.recv(1024)
print data
> > ...
> >
> > 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.
These aren't real directories, but special Bash redirections.
http://www.gnu.org/software/bash/manual/bashref.html#Redirections
It only works in Bash, and only if this feature was enabled when Bash was
configured && compiled.
Regards,
Pedro