sfztools / sfizz

SFZ parser and synth c++ library, providing a JACK standalone client
https://sfz.tools/sfizz/
BSD 2-Clause "Simplified" License
418 stars 58 forks source link

hardware sustain pedal doesn't work #1130

Closed kanashimia closed 11 months ago

kanashimia commented 2 years ago

Hello, sustain pedal doesn't work in sfizz, this is on NixOS with pipewire-jack.

When changing automation sliders by hand in ardour sfizz actually gives sustain like it should, but when using pedal, no, even tho ardour actually shows that slider value jumps from 0 to 127 and back to 0.

Pedal works like it should in carlas sfz player and in other LV2 plugins. Same problem occurs with LV2, VST3 and standalone jack client. I have tested latest commit and 1.2.0 release, tested on nixos in ardour and in carla. I actually hear pedal down noise effect, but no sustain.

It seems event handling is flaky.

paulfd commented 1 year ago

Do you have some SFZ file for me to test?

kanashimia commented 1 year ago

Do you have some SFZ file for me to test?

The sustain itself doesn't work on any of the SFZ files, you can use builtin sinewave sample, you can hear pedal noise effect on https://github.com/sfzinstruments/SalamanderGrandPiano

Thanks for reminding me of this, I will try to make a container with captured midi or something if you can't reproduce it.

I've been using liquidsfz for some time, it doesn't have this bug.

kanashimia commented 1 year ago

OH, actually i have a clue @paulfd

It seems my keyboard produces events on 3 channels for some reason, end they look like this:

 518: f8
 661: fe
 502: f8
 693: b0 40 7f control change (channel  0): controller  64, value 127
 742: b1 40 7f control change (channel  1): controller  64, value 127
 743: b2 40 00 control change (channel  2): controller  64, value   0
 533: f8
 275: f8
 259: f8
  52: b0 40 00 control change (channel  0): controller  64, value   0
  52: b1 40 00 control change (channel  1): controller  64, value   0
  52: b2 40 00 control change (channel  2): controller  64, value   0
 144: fe
 241: f8

(this is the output from jack_midi_dump)

Only first one has actual notes

Here is a sample mid file: sustain-broken-sample.mid (sample contains 2 notes unsustained and 2 sustained)

Tested with

sfizz_render --midi out2.mid --wav out.wav --sfz ./SalamanderGrandPiano.sfz

sfizz_render --midi out2.mid --wav out.wav --sfz /nix/store/6xmy9lcdhnyzsb5752zhnhdp0ssphrcp-sfizz-1.2.1/lib/lv2/sfizz.lv2/Contents/Resources/DefaultInstrument.sfz

sfizz_render --midi fix.mid --wav out.wav --sfz /nix/store/6xmy9lcdhnyzsb5752zhnhdp0ssphrcp-sfizz-1.2.1/lib/lv2/sfizz.lv2/Contents/Resources/DefaultInstrument.sfz

But when those 2 channels are removed then sustain works like it should.

paulfd commented 1 year ago

OK I probably know what's happening. The sfizz engine doesn't consider channels at all, so they're basically ignored in midi messages. In your case, there's a 0 CC64 message in the first burst of CC that (I guess) are linked to the "pedal down" event. This would mean that for sfizz, the pedal is pressed and immediately lifted. This would explain why you hear sustain pedal noises but no actual sustain.

Which keyboard is this? I suspect this is some high-res MIDI or MPE shenanigan.

paulfd commented 1 year ago

One fix would be for the plugin to filter channel 0 messages instead of ignoring it. I'll try to look around at what similar plugins are doing.

kanashimia commented 1 year ago

Which keyboard is this? I suspect this is some high-res MIDI or MPE shenanigan.

Yamaha PSR-E373

Found a post about this issue on some forum https://yamahamusicians.com/forum/viewtopic.php?t=17565

paulfd commented 11 months ago

I'll close this issue for now, feel free to reopen if you have new info.

kanashimia commented 11 months ago

@paulfd but this wasn't fixed as far as I understand, right? Why close it then?

redtide commented 11 months ago

I gave a look at the forum thread you linked and wondering if the last post solution was useful for you (other than wondering where is the answer he got from an user not listed there).

paulfd commented 11 months ago

@kanashimia since you linked a forum post hinting at a solution I figured you used that solution.

If anything it's not a problem of the sfizz engine. It might be one of the plug-ins so we might reopen it there as an improvement rather than a bug. The question would be to ignore midi messages coming from anything but channel N. I'm sure though that someone might come up and use channel M and not N and be sad about it, so what I would really need is add some parameter to restrict midi messages to some channel.

You could solve it in the meantime your DAW by inserting some midi filtering.