fluidsynth icon indicating copy to clipboard operation
fluidsynth copied to clipboard

[RFC] Using Sustain Pedal like Soft Pedal

Open derselbst opened this issue 2 years ago • 9 comments

This attempt to implement the method described in #1271.

Unfortunately, it doesn't work. In my tests I've found that manipulating the release time does not affect voices already playing in release phase.

I currently have no time for a deeper investigation.

derselbst avatar Sep 08 '23 14:09 derselbst

@RobsonFBP FYI

derselbst avatar Sep 08 '23 14:09 derselbst

The effect could be more noticeable if the initial volEnvRelease is 1s and I add 6400 to the modulator parameter.

However, my intention is not just a vibration effect, but primarily to have string, organ and flute sounds that do not ring out indefinitely when the pedal is pressed, but have a smooth pitch with a size. This implies activating the pedal before Release.

Thank you in advance and we await the update.

RobsonFBP avatar Sep 15 '23 09:09 RobsonFBP

Thanks for this PR.

I liked the name of the created variable ignore_sutain because it is more intuitive than cancel_default_hold in your PR

I think if (mod->src1 == SUSTAIN_SWITCH) is true, mod->flags1 & (FLUID_MOD_CC | FLUID_MOD_SWITCH) will always be true because its index is 64, so only FLUID_MOD_CC have index 64 and it could be simplified to:

    if ((mod->src1 == SUSTAIN_SWITCH || mod->src2 == SUSTAIN_SWITCH) && mod->dest == GEN_VOLENVRELEASE)
    {
        voice->ignore_sustain = 1;
    }

I would be even more restrictive using both SUSTAIN_SWITCH sources

    if (mod->src1 == SUSTAIN_SWITCH && mod->src2 == SUSTAIN_SWITCH && mod->dest == GEN_VOLENVRELEASE)
    {
        voice->ignore_sustain = 1;
    }

But if you want to keep the code without simplifying, you could fix the parentheses like this.

    if(((mod->src1 == SUSTAIN_SWITCH && mod->flags1 & (FLUID_MOD_CC | FLUID_MOD_SWITCH))
        || (mod->src2 == SUSTAIN_SWITCH && mod->flags2 & (FLUID_MOD_CC | FLUID_MOD_SWITCH)))
        && mod->dest == GEN_VOLENVRELEASE)
    {
        voice->ignore_sustain = 1;
    }

RobsonFBP avatar Sep 17 '23 04:09 RobsonFBP

Ok, I applied your suggestions, thanks. However, I'm currently unable to test this. It may take me a few weeks before coming back to this.

derselbst avatar Nov 19 '23 17:11 derselbst

I found some time to look into this again. I can confirm that the current change results in an audible manipulation of the sustain and release phases for new voices only (i.e. not for already playing voices). The most noticeable effect is that notes which were played while the sustain pedal was depressed, keep playing even when releasing the pedal afterwards and playing further notes. I'm not quite sure if this is supposed to be the effect intended by the original discussion.

One problem I observed is that fluidsynth easily runs out of polyphone, when playing notes while the pedal is depressed: fluidsynth: debug: Polyphony exceeded, trying to kill a voice

This doesn't happen when playing with the regular sustain pedal behavior and is probably due to decay and release phases being both expanded by the current implementation.

Honestly, I don't really find this behavior intuitive or comprehensive. But I would like to hear what others think about it?

derselbst avatar Jan 02 '24 17:01 derselbst

I would also like to be able to test each change, but I don't know how to do it. If you could send me a compiler with all the settings and all the necessary files and dependencies, so that I could just make the changes and compile, I could perhaps deliver the finished result.

Eu também gostaria de poder testar cada mudança, mas não sei como fazer. Se você pudesse me mandar um compilador com todas as configurações e todos os arquivos e dependências necessários de modo que eu apenas fizesse as mudanças e compilasse, poderia entregar o resultado pronto.

RobsonFBP avatar Jan 29 '24 01:01 RobsonFBP

The process of compiling is explained in our wiki: https://github.com/FluidSynth/fluidsynth/wiki/BuildingWithCMake

derselbst avatar Jan 29 '24 22:01 derselbst