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 Topic RSS sp_TopicIcon
Volume Ramping
Avatar
Member
Members
April 14, 2015 - 6:30 am
Member Since: December 21, 2014
Forum Posts: 23
sp_UserOfflineSmall Offline

Hi Will,

I see from the net some advice on optimization.

"Don't calculate envelopes and LFOs every sample. It's generally fine if you calculate them every 16 samples or so (and ramp volume changes). Same goes for filter settings."

How do I "ramp the volume changes"? What does it mean actually?

Many thanks.

Avatar
Admin
April 14, 2015 - 7:48 pm
Member Since: January 28, 2017
Forum Posts: 659
sp_UserOfflineSmall Offline

Hi Pier

Yeah, this is something I struggled with when writing the book - whether to update everything on each sample interval or not. Eventually, I chose to copy hardware synths and update on each interval.

I believe ramping the volume changes is similar to the dezippering operation - when the volume changes drastically from user input, ramp it slowly to avoid clicks. I think they are referring to calculating the new ramped volume value every 16 samples as well.

There is a big thread in the forum on this topic for removing glitches from GUI control movements.

- Will

Avatar
Member
Members
April 15, 2015 - 6:07 am
Member Since: December 21, 2014
Forum Posts: 23
sp_UserOfflineSmall Offline

Hi Will,

I assume it is this post : http://www.willpirkle.com/foru.....oise/class CParamSmooth
{
public:
CParamSmooth(float smoothingTimeInMs, float samplingRate)
{
const float c_twoPi = 6.283185307179586476925286766559f;
a = exp(-c_twoPi / (smoothingTimeInMs * 0.001f * samplingRate));
b = 1.0f - a;
z = 0.0f;
}
inline float process(float in)
{
z = (in * b) + (z * a);
return z;
}
private:
float a;
float b;
float z;
};

In the interest of learning, what exactly am I doing when I am doing this? Could you explain why we use exp, etc?
Thank you.

Avatar
Member
Members
April 15, 2015 - 6:11 am
Member Since: December 21, 2014
Forum Posts: 23
sp_UserOfflineSmall Offline

Interestingly, csound has this for the opcode port and portk .. it looks similar except the c2 coefficient is calculated using pow instead of exp as in the zipper noise question. Why the difference, and what is the effect? Thank you.

int porset(CSOUND *csound, PORT *p)
{
p->c2 = pow(0.5, (double)CS_ONEDKR / *p->ihtim);
p->c1 = 1.0 - p->c2;
if (LIKELY(*p->isig >= FL(0.0)))
p->yt1 = (double)(*p->isig);
p->ihtim_old = *p->ihtim;
return OK;
}
int kporset(CSOUND *csound, PORT *p) { return porset(csound, p); }

int port(CSOUND *csound, PORT *p)
{
p->yt1 = p->c1 * (double)*p->ksig + p->c2 * p->yt1;
*p->kr = (MYFLT)p->yt1;
return OK;
}

int kport(CSOUND *csound, KPORT *p)
{
if(p->ihtim_old != *p->ihtim) {
p->c2 = pow(0.5, (double)CS_ONEDKR / *p->ihtim);
p->c1 = 1.0 - p->c2;
p->ihtim_old = *p->ihtim;
}
p->yt1 = p->c1 * (double)*p->ksig + p->c2 * p->yt1;
*p->kr = (MYFLT)p->yt1;
return OK;
}

Avatar
Admin
April 16, 2015 - 12:03 am
Member Since: January 28, 2017
Forum Posts: 659
sp_UserOfflineSmall Offline

These are both just types of lowpass filtering. The impulse response of a 1st order LPF is time-smeared, so they are using that property to effectively slow down the parameter. You just run the parameter in question through the filter and it smooths the edges/discontinuities.

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

clau_ste: 39

Nickolai: 39

JimmyM: 33

Gwen: 32

Member Stats:

Guest Posters: 1

Members: 742

Moderators: 1

Admins: 6

Forum Stats:

Groups: 13

Forums: 42

Topics: 820

Posts: 3172

Moderators: W Pirkle: 659