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.

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

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.

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;

}

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

Newest Members:

Cameron C., Kaih, davidfernxndez, J.Miguel, 3ddie, Mike, salik, Franklin, TAldhous, JohanModerators: W Pirkle: 659