Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Frequency change in WTOscillator
No permission to create posts
November 24, 2013
9:19 pm
Avatar
alexirae
Member
Members
Forum Posts: 11
Member Since:
November 24, 2013
sp_UserOfflineSmall Offline

Hi Will,

Thanks for all your amazing work with the book!

I was wondering if there is a way to "smooth" the frequency changes of the WTOscillator, if you do a rapid change of frequency with the slider/knob you can notice the "steps" going from the current frequency to the target frequency.

Do I have to do a modification like an interpolation in the setFrequency() method?

Thanks very much!

November 26, 2013
12:04 am
Avatar
Muirscape
SF Bay Area/Miami, FL
Member
Members
Forum Posts: 5
Member Since:
June 8, 2013
sp_UserOfflineSmall Offline

Hey Alexirae,

I gone about smoothing parameters a couple ways. The first is based off the same concept as an envelope follower (check out the "Difference Equation" on the bottom of page 429 in Will's book). Basically the slider becomes the audio input, and the output is the value you want to end up using (in your case the frequency). Thus you can set attack & release times.

The second way is something I call ROCC (Rate of Change Clamp) & is nothing more than a few if-else statements, and is based off the same envelope follower difference equation.

All this does is limits how much the parameter can increase and decrease by a STATIC value (maxChange). It's a render-based function (gets called every sample period). You could cook the maxChange variable based on the sample rate but I haven't implemented that in my attached example.

Here's the .h & .cpp of this implemented within a volume control plug-in: https://www.dropbox.com/s/7pcciwio88edjwy/VolumeSmoothed.zip

Hope that helps! Let me know if you find a different way to do it!

Cheers

Muir

November 29, 2013
2:12 am
Avatar
alexirae
Member
Members
Forum Posts: 11
Member Since:
November 24, 2013
sp_UserOfflineSmall Offline

Hi Muirscape,

I really appreciate all your effort explaining how to do the parameter smooting and also the source code you shared with me, thanks very much!

On the other hand, I was experimenting (the day before you posted the answer) a way to do the parameter smooting in a very simple and efficient way, that fixed all the issues I had with the frequency slider.

Basically I made a small class for the parameter smoothing, these are the most important parts of that class:

void ParameterSmoother::initialize(int sampleFrames)
{
previousSample = 0.0f;
currentsSample = 0.0f;

delta = 1.0f / sampleFrames;
}

float ParameterSmoother::smoothParamValue(float sample)
{
// One Pole Lowpass Smoothing
float smoothedValue = previousSample + delta * (currentsSample - previousSample) ;

previousSample = smoothedValue;
currentsSample = sample;

return smoothedValue;
}

In few words, I did the parameter smoothing with a one pole low pass filter, which is kind of linear interpolation and my delta step is one over the buffer size (in my case I was using 512 samples), but could be any buffer size.

I think the way you do the parameter smoothing works fine but I don't know how much the double branching (the first if and then the ternary operator ? : ) affects the CPU performance because it is executed every sample.

Let me know what do you think, thanks for the advice!
Wink

December 2, 2013
6:58 pm
Avatar
Muirscape
SF Bay Area/Miami, FL
Member
Members
Forum Posts: 5
Member Since:
June 8, 2013
sp_UserOfflineSmall Offline

Nice! I'll have to try your method. Yes a LPF (smoothing filter) would work very well. In a way it seems quite similar to the envelope follower difference equation.

So is ParameterSmoother::smoothParamValue called every time a new audio buffer arrives? That would certainly be more efficient then per-sample rendering.

Cheers!

Muir

December 4, 2013
2:06 am
Avatar
alexirae
Member
Members
Forum Posts: 11
Member Since:
November 24, 2013
sp_UserOfflineSmall Offline

Indeed, it is very similar to the enveloper follower difference equation =), and not, smoothParamValue( ) is called every sample in order to keep track of the rate of change between each sample to hear the smoothed sound change.

I'm testing now a way to avoid the calculation inside smoothParamValue( ) if the slider is not moved, I tried different things like checking if the sample is but I'm getting some "clicks" when I move the slider. =(

March 17, 2015
10:45 pm
Avatar
Discarga
Member
Members
Forum Posts: 8
Member Since:
January 10, 2015
sp_UserOfflineSmall Offline

For what it's worth: check the note-expression-synth in the VST3 SDK, there is examples of ramping parameters in there, see the processing function in the controller.

March 18, 2015
6:18 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

I've posted some similar information in another zipper noise thread:

http://www.willpirkle.com/foru.....per-noise/

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online:
7 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Peter: 41

Derek: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 476

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 482

Posts: 1876

Newest Members:

sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 143

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 143