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

Smooth CC formula #48

Closed
jpcima opened this issue Feb 8, 2020 · 9 comments · Fixed by #181
Closed

Smooth CC formula #48

jpcima opened this issue Feb 8, 2020 · 9 comments · Fixed by #181
Assignees
Labels
new feature Feature additions and requests

Comments

@jpcima
Copy link
Collaborator

jpcima commented Feb 8, 2020

I have studied effects of bend_smooth, and I share some results.
In SFZ specs, smoothcc under Modulators is a "see also" to opcode bend_smooth.

The experiment is to load a sine tone and modulate midi pitch bend with a ramp lfo.
The results were observed on spectrogram in real-time.
Then, it was matched to a faust program which plays a sine modulated with identical LFO and range.

⚠️ note that the smooth filter must be applied on the CC values, not cents values which are result of the conversion following.

The smoothing filter is one-pole LPF which is defined by a time-constant tau. (cf. faust basics.lib)
pole = exp(-1.0/(tau*Fs))

These are approximate results measured visually.
tau is observed starting at 0, varying +3 ms by bend_smooth unit.

#bend_smooth        tau measured (ms)
10                 30
20                 70
30                 90
40                 120
50                 160
60                 180
70                 220
80                 230
90                 270
100                300

Capture du 2020-02-09 00-28-52

@paulfd
Copy link
Member

paulfd commented Feb 9, 2020

So it's a straightforward lowpass filter with this constant then? Thanks for the investigation. For this one the nice part is that it's not modulated at all so it's much simpler..

@jpcima
Copy link
Collaborator Author

jpcima commented Feb 9, 2020

Yes, I was not expecting anything more complicated..
as it turned out, the model was fitting on the first attempt.

@paulfd paulfd self-assigned this Feb 14, 2020
@paulfd paulfd modified the milestones: 0.3.0, 0.4.0 Feb 14, 2020
@paulfd
Copy link
Member

paulfd commented Mar 31, 2020

⚠️ note that the smooth filter must be applied on the CC values, not cents values which are result of the conversion following.

Re-reading all of this, this is going to be a bit annoying I think.

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 31, 2020

Yes but also it makes more sense implementation-wise.
It's cheaper to apply filtering once per CC rather than modulation sink where it's applied to.

Btw these measurements are 1. pitchbend only, 2. ARIA

I'll try to get a new set measurements based on cakewalk, and by use of CC values.

@paulfd
Copy link
Member

paulfd commented Mar 31, 2020

Well except you can't really apply it per CC, since different regions might have different inertia parameters. You're kind of forced to compute it for each target.

At least for the current state of the modifiers now it would be simpler to apply it after conversion 😄

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 31, 2020

You could still precompute it, per-CC and inertia and curve.
Anyway I'll try later to check how the information above holds on cakewalk.

@paulfd
Copy link
Member

paulfd commented Mar 31, 2020

For sure but then is it in general cheaper to apply a possibly nonlinear function (e.g. exp or log functions mainly) to a full envelope rather than building the envelope out of points from the nonlinear functions? You can do cheap multiplicative ramps using simd so right now I went with the latter.

Note that having a "multiplicative" filter could be a way to solve this dilemma 😁

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 31, 2020

Note that having a "multiplicative" filter could be a way to solve this dilemma

Not possible, however: since you will be repeating these identical instructions for all CC, you could SIMD then in "vertical" manner and handle the filters 4 at a time by SSE.

(it's the same kind of vertical processing I hope to do to speed up strings after finalizing)

@paulfd paulfd added the new feature Feature additions and requests label Apr 2, 2020
@paulfd paulfd mentioned this issue Apr 2, 2020
3 tasks
@paulfd
Copy link
Member

paulfd commented Apr 2, 2020

Todo to finish implementation:

  • Add a simpler smoother that the voices will hold

  • Preallocate the smoothers in the voices after loading the files -- à la filters/eqs

  • Add smoothing to the modifier loops where necessary.

  • Add smoothing for bends too

  • For simplicity I think we can safely assume that the smoothed modifiers are always going to be read in the same order w.r.t. gain/cutoff parameters and state. This means pre-setting the gain is possible, and that

  • For multiplicative-type smoothing an adaptation of e.g. the filters is possible (see e.g. this tentative which seems to behave properly when implemented in python with an exact power function), provided there's a proper way to approximate a pow function. Check the stability of this approach, otherwise there is always the possibility to just smooth linearly in the log-domain, with possibly slightly worse results.

@paulfd paulfd mentioned this issue Apr 13, 2020
5 tasks
@paulfd paulfd linked a pull request Apr 13, 2020 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Feature additions and requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants