Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequencer event ordering is broken for NoteOn vel=0 events #907

Closed
jet2jet opened this issue Jun 8, 2021 · 6 comments · Fixed by #908
Closed

Sequencer event ordering is broken for NoteOn vel=0 events #907

jet2jet opened this issue Jun 8, 2021 · 6 comments · Fixed by #908
Labels
Milestone

Comments

@jet2jet
Copy link

jet2jet commented Jun 8, 2021

FluidSynth version

(commit hash: 17fb48d )

$ ./fluidsynth --version
FluidSynth runtime version 2.2.1
Copyright (C) 2000-2021 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

FluidSynth executable version 2.2.1
Sample type=double

Describe the bug

With using sequencer (fluid_sequencer_t), when sending 'Note on' event immediately after (i.e. same tick of) 'Note on with velocity = 0' event, the first 'Note on' event may sound nothing.

Expected behavior

'Note on' should always sound in that case

Steps to reproduce

I attached reproduce source code: main.cpp.zip
(I used VintageDreamsWaves-v2.sf2 Soundfont on reproduce.)

Extract main.cpp, build with gcc -o main main.cpp libfluidsynth.a -lglib-2.0 -lstdc++ -lm -fopenmp, and execute ./main.
The WAVE file out.wav is generated and it may play something weird sound.

Additional context

  • If 'Note off' event is used instead of 'Note on with velocity = 0', it seems OK.
  • I wonder that this problem occurs from 0d98c47 (not tested well, but v2.1.x had no problem)
@jet2jet jet2jet added the bug label Jun 8, 2021
@jet2jet jet2jet changed the title Note on event immediately after 'note on with velocity = 0' may sound nothing 'Note on' event immediately after 'note on with velocity = 0' may sound nothing Jun 8, 2021
@derselbst
Copy link
Member

Since 2.2.0 events that share the same tick are ordered in a special way, see docs of fluid_sequencer_send_at(). This ordering currently considers NoteOn Vel=0 events as real NoteOns by mistake. NoteOns with velocity=0 are always treated as noteoff by the synth.

There is more than one way to fix this, I'll need to think about it.

@derselbst derselbst changed the title 'Note on' event immediately after 'note on with velocity = 0' may sound nothing Sequencer event ordering is broken for NoteOn vel=0 events Jun 8, 2021
@derselbst derselbst added this to the 2.2 milestone Jun 8, 2021
@derselbst
Copy link
Member

I think the best way would be to make fluid_event_noteon() return a NOTEOFF event when vel==0. I'll add a regression test for this as well.

@derselbst derselbst linked a pull request Jun 8, 2021 that will close this issue
@derselbst
Copy link
Member

Implemented in #908, feel free to test.

@jet2jet
Copy link
Author

jet2jet commented Jun 9, 2021

Thanks for the fix.
I tested and confirmed that the issue was fixed.

Since 2.2.0 events that share the same tick are ordered in a special way, see docs of fluid_sequencer_send_at().

I understood that the order of events that have the same timestamp is undefined, but how do you think about 'on-off' effects such as Hold? I wonder that, there may be the case that Hold-off event is followed by Hold-on event with the same timestamp, which assumes it resets sounded notes and turn hold on again at the same time. (If it is a rare or not so good case, the current behavior would be fine.)

@derselbst
Copy link
Member

By "hold-event" you mean regular Sustain and Sostenuto events? If yes: Just like other CC events, if you want them to be applied in a special order to achieve a special effect, you would need to use different ticks.

@jet2jet
Copy link
Author

jet2jet commented Jun 9, 2021

By "hold-event" you mean regular Sustain and Sostenuto events?

Yes.

Just like other CC events, if you want them to be applied in a special order to achieve a special effect, you would need to use different ticks.

I understood. Thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants