-
Hello everyone, in the documentation it says about the fluid_synth_noteoff() return value:
Now, is there a way to distinguish between "no voices matched the note off event" and an actual error? I am writing a C++ wrapper around fluidsynth and I am always checking the return codes of the libfluidsynth functions. If it is FLUID_FAILED (-1), I am throwing an exception. void fluid_synth_auto::noteoff(int chan, int key) const {
if (fluid_synth_noteoff(ptr, chan, key)) {
throw fluid_exception();
}
} In my program, if a note faded out after a note_on, and I call noteoff, it throws an exception, which is unexpected. How do I handle the return value of noteoff correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Currently there is no way to distinguish. By default, noteoff() returns FLUID_FAILED, unless it found a matching voice, in which case it returns FLUID_OK from here: fluidsynth/src/synth/fluid_synth_monopoly.c Line 594 in b580a11 On the other hand, the only real errors that could occur during noteoff are:
You can easily avoid the first three error sources. Not sure if you're using the basic channels feature; if not, you can ignore that as well. Then you know that FLUID_FAILED is because it didn't match a voice. A more explicit way of doing it would be to lookup all voices with |
Beta Was this translation helpful? Give feedback.
Currently there is no way to distinguish. By default, noteoff() returns FLUID_FAILED, unless it found a matching voice, in which case it returns FLUID_OK from here:
fluidsynth/src/synth/fluid_synth_monopoly.c
Line 594 in b580a11
On the other hand, the only real errors that could occur during noteoff are:
fluid_synth_set_basic_channel()
You can easily avoid the first three error sources. Not sure if you're using the basic channels feature; if not, you can ignore that as well. Then you know that FLUID_FAILED is because it did…