[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re:[fluid-dev] Dealing with startup
From: |
John O'Hagan |
Subject: |
Re:[fluid-dev] Dealing with startup |
Date: |
Tue, 14 Oct 2008 05:06:36 +0000 |
Ben Leggett wrote:
>[...]
>Currently, I start fluidsynth in a shell script in conjunction with
>Dosbox, as opposed to systemwide, since the soundfont I use makes
>fluidsynth take up quite a lot of memory.
>
>Because this soundfont is large, fluidsynth startup time can take quite
>a while, and can vary depending on whether it's a cold start or not.
>
>Is there a way in a shell script to tell if fluidsynth has finished
>loading a font? Using "sleep" doesn't always produce the desired
>effects, since the load time is, as I said, quite variable. To recap, I
>need a way to wait for fluidsynth to finish loading before I start
>anything else.
I recently came across the same issue; I dealt with it (in Python) by using a
while loop to keep trying to connect to fluidsynth server at its "localhost
9800" address:
from telnetlib import Telnet
import subprocess
host = "localhost"
port = "9800"
#See if fluidsynth is already running:
try:
fluid = Telnet( host, port )
#if not, load it:
except:
soundfont = "path_to_my_soundfont"
subprocess.Popen( ["fluidsynth", "-i", "-s", soundfont] )
#While that's happening, keep trying to connect:
while 1:
try:
fluid = Telnet( host, port )
except:
continue
else:
break
#After break, move on to rest of program
It's probably wise to put a timeout in there somewhere, but you get the idea.
In a shell script, you could probably do something similar with telnet or
netcat.
Hopefully someone will point out if this is a bad way to do it!
HTH,
John
- Re:[fluid-dev] Dealing with startup,
John O'Hagan <=