GeekFunkLabs / fluidpatcher

A performance-oriented patch interface for FluidSynth
MIT License
124 stars 15 forks source link

Notes from MIDI keyboard do not produce audio #111

Closed ztaylor4 closed 9 months ago

ztaylor4 commented 9 months ago

Describe the bug I'm running on a Raspberry Pi 3B with a Keystep 37. Notes can make it into the Pi, and notes can make it out separately from midi files, but I can't get the notes playing to produce any sound.

Notes show up with aseqdump, e.g.:

pi@keystep:~ $ aseqdump -p 20
Waiting for data. Press Ctrl+C to end.
Source  Event                  Ch  Data
 20:0   Note on                 7, note 71, velocity 80
 20:0   Note off                7, note 71, velocity 64

And if I run a command like the following, I hear audio from the connected headphone jack:

fluidsynth -a alsa -o audio.alsa.device=plughw:0,0 -n -i /usr/share/sounds/sf2/FluidR3_GM.sf2 SquishBox/midi/elevatorgroove.mid

Because I had to add that -o flag, and because of the output from aplay -l, I have edited my fluidsettings to include audio.alsa.device: 'plughw:0,0'.

pi@keystep:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 2: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

SquishBox/squishboxconf.yaml:

soundfontdir: SquishBox/sf2
bankdir: SquishBox/banks
mfilesdir: SquishBox/midi
plugindir: /usr/lib/ladspa
currentbank: bank1.yaml
fluidsettings:
  audio.driver: alsa
  audio.alsa.device: 'plughw:0,0'
  audio.period-size: 64
  audio.periods: 3
  midi.autoconnect: 1
  player.reset-synth: 0
  synth.audio-groups: 16
  synth.cpu-cores: 4
  synth.ladspa.active: 1
  synth.polyphony: 128

If I add a few print statements, I can see the listener from headlesspi.py firing for notes, but I don't see send_event functions elsewhere getting called.

Output of headlesspi.py (the thread priority messages go away if I run with sudo):

pi@keystep:~ $ python headlesspi.py
fluidsynth: warning: Requested a period size of 64, got 444 instead
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: Connection of Midi Through Port-0 succeeded
fluidsynth: Connection of Arturia KeyStep 37 MIDI 1 succeeded
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: Connection of Network succeeded
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to set thread to high priority
Loading bank 'bank1.yaml' ..
fluidsynth: warning: Sample 'SineWave': ROM sample ignored
Bank loaded.
Selected patch 1/26: Piano

Any ideas what I could try next?

Background Info

albedozero commented 9 months ago

Thanks for the helpful info - it appears from your aseqdump output that your Keystep is sending notes on MIDI channel 7. The bank1.yaml bank file assumes your keyboard is sending on channel 1. You can change this on your keystep or add the following rule to the router_rules section at the top of the bank file:

  - {type: note, chan: 7=1}

Side note - if you're using headlesspi.py, you may have installed the legacy version of the RPi synth software. I'm trying to disentangle fluidpatcher from the squishbox software - apologies for any confusion.

ztaylor4 commented 9 months ago

Thank you for finding that so quickly! I tried a lot of things but hadn't found that setting in bank1.yaml.

In general, I was trying to go off of the steps from Headless Raspberry Pi Synthesizer Update video, but maybe I installed something from the other project when I was struggling and didn't realize how all the parts fit together. The YouTube videos have been very helpful--thanks for all the work you've put into this project, both developing it and sharing it!

For anyone this might help, adding this line to bank1.yaml was the solution to my problem (the channel is off by one from the value reported by aseqdump):

  - {type: note, chan: 8=1}