Skip to content

Conversation

paulfd
Copy link
Member

@paulfd paulfd commented Apr 13, 2020

This implements a linear and multiplicative smoother, trying to match a reasonable mix of behaviors between ARIA and consorts. The linear smoother uses a VA one-pole filter. The smoothing cutoff is a function of the sample rate, and it is quantized/tabulated between a minimum (a smoothing value of 1 with the default sample rate at 48 kHz) to a maximum (a smoothing value of 100 with a max sample rate of 192 kHz). We'd have to evaluate if this is enough.

  • Implement the smoothers with mapping to the smoothcc value and some tests.
  • Add a gain smoother on the voice for the overall amplitude (Implement dynamic crossfade #22); the smooth value is set at 10 for now.
  • Parse the bend_smooth opcodes and add a bend smoother for the pitch bend in the Voices.
  • On parsing in the Synth, check the max number CC parameters there are for each modifier target and adapt the number of smoothers in the Voices.
  • Jointly loop over the modifiers and the smoothers to compute the modifier envelopes in the Voices.

Closes #48, #22, #153

@jpcima
Copy link
Collaborator

jpcima commented Apr 16, 2020

Can you elaborate on what is the distinction between log and linear?
and why we need them? I lack the context to understand this.
("reasonable mix of behaviors between ARIA and consorts")

Also why's not simplest form of LPF not adequate, and why it's needed to tabulate the power function? (given smoothcc is supposed to be fixed?)

(sorry for lots of questions)

@FrnchFrgg
Copy link

As a remember when things are working, xfin_smoothccXX and xfout_smoothccXX would be great, even though they are not supported by LinuxSampler (which arguably is the most complete implementation on Linux to date), and maybe even not by ARIA/Sforzando.

@paulfd
Copy link
Member Author

paulfd commented Apr 16, 2020

edited out

@FrnchFrgg this is linked to #22, and I added a gain smoother here which has this function more or less, but having smooth crossfades is one of the goal of this PR 🙂

@jpcima
Copy link
Collaborator

jpcima commented Apr 18, 2020

I don't find the filter to match to the RE'd specification.
Have you checked it?

@jpcima
Copy link
Collaborator

jpcima commented Apr 18, 2020

This formula matches it exactly.
It lacked a term 2 pi in the relation between the cutoff and time constant.

    smoothing = (smoothValue > 0);
    if (smoothing) {
        float tau = smoothValue * 3e-3f;
        float f = 1.0f / (twoPi<float>() * tau);
        float s = std::tan(pi<float>() * f / sampleRate);
        filter.setGain(s);
    }

@paulfd
Copy link
Member Author

paulfd commented Apr 18, 2020

No I was planning to check it out now so thanks :)

@paulfd
Copy link
Member Author

paulfd commented Apr 18, 2020

In the end it should reduce to this:

std::tan(1.0f / (2 * smoothValue * 3e-3 * sampleRate));

@jpcima
Copy link
Collaborator

jpcima commented Apr 18, 2020

Yes; in addition you can group all constants together.

std::tan((1.0f / (2 * 3e-3f)) / (smoothValue * sampleRate));

Do we need to tabulate this? I thought the smoothcc are set once and never changed.

@paulfd
Copy link
Member Author

paulfd commented Apr 18, 2020

Well the filters belong to the voices, so the have to adapt to the currently played region for all smoothcc, and possibly sample rate. I guess we could set the smoothing filters upon loading the sfz file and make copies of the filter with their gain already set withing the voice, was this what you had in mind?

@jpcima
Copy link
Collaborator

jpcima commented Apr 18, 2020

If I understand this correctly..
it's supposed to be changed in case of:

  • loading sfz file
  • changing sample rate

None of these belong to DSP processing, hence why care to save a small fraction of processing time?

@paulfd
Copy link
Member Author

paulfd commented Apr 18, 2020

No, it's changed when starting a voice, but I'll remove it and benchmark later if this creates problems.

@jpcima
Copy link
Collaborator

jpcima commented Apr 18, 2020

Feel free to cherry-pick 272b195, a test jack client

@paulfd paulfd force-pushed the smoothers branch 3 times, most recently from 7dae185 to 7dfb98b Compare April 18, 2020 23:25
@paulfd paulfd marked this pull request as ready for review April 18, 2020 23:44
@paulfd paulfd requested a review from jpcima April 18, 2020 23:44
@paulfd
Copy link
Member Author

paulfd commented Apr 18, 2020

You can use this to do further work on modulation if you wish.


const auto events = resources.midiState.getPitchEvents();
const auto bendLambda = [this](float bend) {
return region->getBendInCents(bend);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulfd, I'm trying to rebase this.
This function name is misleading. It returns a factor not cents.

paulfd added 2 commits June 20, 2020 15:27
Move modifiers and their helpers in their own files
Add an enum class for modifiers and facilities to iterate over all possible targets
Add smoothers to the voices and preallocate them
Iterate over smoothers and modifiers jointly in the voices for each target
@jpcima
Copy link
Collaborator

jpcima commented Jun 20, 2020

I seem to have trouble with the following patch.
It's set to control panning left and right using a midi controller change.

When smoothcc is set and the note is keyed on, pan is going to start at the right and it will take a delay until the pan value establishes itself at center.

<control>
set_hdcc16=0.5

<region>
sample=*sine
ampeg_attack=0.02
ampeg_release=0.1
pan=-100
pan_oncc16=200
pan_smoothcc16=100

@paulfd
Copy link
Member Author

paulfd commented Jun 20, 2020 via email

@jpcima
Copy link
Collaborator

jpcima commented Jun 20, 2020

It appears the initialization of the filter which is incorrect. I 'll check it.

@jpcima
Copy link
Collaborator

jpcima commented Jun 20, 2020

The modulated unit has been changed to % after rebase, but the initialization had not followed.
This concerns amplitude, pan, width and position.
Fixed in e69365e

@jpcima jpcima merged commit 02630ed into sfztools:develop Jun 20, 2020
@paulfd paulfd mentioned this pull request Jul 5, 2020
@paulfd paulfd deleted the smoothers branch January 21, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a small amount of smoothing on the amplitude/crossfade envelope Smooth CC formula Implement dynamic crossfade
3 participants