[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] fluidsynth router for program change

From: R.L. Horn
Subject: Re: [fluid-dev] fluidsynth router for program change
Date: Fri, 27 Feb 2015 02:53:04 -0600 (CST)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

On Thu, 26 Feb 2015, Gino Latino wrote:

fluidsynth --audio-driver=alsa -m alsa_raw -o midi.alsa.device=hw:1 -o audio.alsa.device=hw:0 -o synth.polyphony=16 -c 4 -g 1.4 /instruments/xxx.sf2

Ah, I see your problem. I don't think there's any way to interpose a filter between fluidsynth and the controller that way (the two are basically talking directly to each other).

All is not lost, however. The sequencer connections can be automated, and in a way that's more reliable than the above. I've been working on turning my little event displayer into a proper breakout box, with pluggable filters (somewhat along the lines of LADSPA) and realtime scheduling. I think it may be just the thing you need.

Consider the output from aconnect -i/aconnect -o:

  $ aconnect -o
  client 14: 'Midi Through' [type=kernel]
      0 'Midi Through Port-0'
  client 20: 'YAMAHA DigitalKBD' [type=kernel]
      0 'YAMAHA DigitalKBD MIDI 1'
  client 128: 'FLUID Synth (2214)' [type=user]
      0 'Synth input port (2214:0)'
  client 129: 'MIDIBreakout' [type=user]
      0 'MIDIBreakout Port-0'

Every client (and port) has a name. With a little grep and awk (I'm too lazy to do it all with awk right now), we can take advantage of this. The following starts fluidsynth and the breakout box, connects my Yamaha keyboard to the breakout, and connects the breakout to fluidsynth:

  #! /bin/sh

  # Create the configuration file for the breakout box.  Mchord.so plays
  # major chords, so it's immediately obvious.
  echo "Mchord.so" > mybreakoutbox.conf

  # Start fluidsynth in the background...
  # (Use whatever options you like, but "-si" is important.)
  fluidsynth -si -o synth.gain=2 /usr/share/soundfonts/4gmgsmt.sf2 &

  # ...and the breakout box.
  midibreakout mybreakoutbox.conf &

  # Wait awhile for things to settle.
  sleep 1

  # Find the ALSA devices.

  # First, find the keyboard.
  kbd=`aconnect -i | grep 'client.*YAMAHA DigitalKBD' | awk '{ print $2 }'`
  # Find fluidsynth.
  flsynth=`aconnect -o | grep 'client.*FLUID Synth' | awk '{ print $2 }'`
  # Find the breakout box (two connections).
  bboxi=`aconnect -i | grep 'client.*MIDIBreakout' | awk '{ print $2 }'`
  bboxo=`aconnect -o | grep 'client.*MIDIBreakout' | awk '{ print $2 }'`

  # Now connect everything up.  Port 0 is assumed in all cases.
  # Keyboard (input) -> BreakoutBox (output)
  aconnect ${kbd}0 ${bboxo}0
  # BreakoutBox (input) -> fluidsynth (output)
  # (that's not confusing at all)
  aconnect ${bboxi}0 ${flsynth}0

  # and we're done
  exit 0

(This is actually quite brittle, but nobody wants to read a bunch of if...thens.)

If you need fluidsynth to run in the foreground, that can be done too. It's just a little more complicated -- you have to background another script or function that waits a few seconds, then makes the necessary connections.

Feel free to contact me off-list with your requirements (something about turning noteons into program changes or the like, wasn't it?) and I'll run off a filter for you and see that you can get a copy of the software. It's in a rough state right now, but it's usable (and perhaps more reliable than it will be once it's fancied up).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]