Collection of Audio Programming Books

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Thanks, I need a few moments to get into what you said but by exponential function, I mean specifically e^x, not just a squared/cubed number. I cannot remember ever coming across the e constant in school, surely thats an slightly advanced concept no?

Post

what do you mean by the induction btw? And how am I supposed to know "the original code is supposed to be x[n]=a e^(-nT)" from the text, it doesn't say that. Is that what you have "induced" from the program? And there is no a??? why? :( I know a = 1 and 1 times anything doesn't have an effect but it doesn't mean there's no a. :?

Post

As I've said, that's an error, there is no a in the original formula, this just computes recursively/through induction x[n] = e^(-nT)

The fact that it's using e, or 4, 6 doesn't matter in this demonstration. The induction of course works for any number.

Post

Ok I feel like I'm getting closer now, but I'm still confused by the exponent. You state it to be (-nT) while the book says (-k/T); why divide instead of multiply and whats the significance of k in relation to n?

Cheers

edit: I think i've muddled it up, n is equivalent to t in the original formula not k. No its still not making sense! :? :? :?

Post

minimaltom wrote:Ok I feel like I'm getting closer now, but I'm still confused by the exponent. You state it to be (-nT) while the book says (-k/T); why divide instead of multiply and whats the significance of k in relation to n?
Typically you would write exp(-n*k*T) where k is supposed to be sampling rate independent (as if there was such a thing in the digital domain) and we have the time-step T=1/fs (where fs is the sampling rate), but maybe the book's definition of T is different (or it's just plain wrong, which is also possible).

Either way, the recursive calculation works like this:

let x[n] = exp(-n*k*T)
then x[n+1] = exp(-(n+1)*k*T) = exp(-k*T)*exp(-n*k*T) = exp(-k*T)*x[n]

The first substitution is because exp(a+b)=exp(a)*exp(b) for any (real or complex) a and b.
The second substitution is simply the definition of x[n] and since exp(-k*T) is now "constant" we can simply call it the "coefficient" and we get:

x[n+1] = coefficient * x[n].

Post

Regarding division vs. multiplication by T. I think that's just different notation. mystran is using T as the sampling period (which pretty much standard in DSP). I could imagine that the formula where T is in the denominator is using T as the "characteristic time" of the exponent (in mystran's case that's implicitly contained in his variable k).

In continuous time domain one could write something like
y(t)=exp(-t/T)
where T is the time of "decaying e times".
To avoid confusion let's call this time T0 instead: y(t)=exp(-t/T0)
Introducing discrete time n: t = nT (where T is the sampling period now) we have
y[n] = y(nT) = exp( - n T / T0 ) = exp( - k * n * T )
where k = 1/T0.

Post

Z1202 wrote: In continuous time domain one could write something like
y(t)=exp(-t/T)
where T is the time of "decaying e times".
Oh yeah.. though in "standard notation" you'd then normally use tau=1/lambda, but we also abuse "w" for omega all the time 'cos we don't have TeX here so can't really blame anyone for that. Oh and I actually tried to post this with the Unicode symbols (rather than symbol names) and here's what I got for it:

Code: Select all

SQL ERROR [ mysql4 ]

Incorrect string value: '\xF0\x9D\x9C\x8F=1...' for column 'post_text' at row 1 [1366]
We really could use a [tex]-tag here for some proper AMS symbols. :D

Post

characteristic time of the exponent which is implicitly contained in his variable k?

I'm not meaning to be ungrateful and im pleased someone else chimed in. I think understand most of the maths behind what you're saying but...

What does k mean? lambda? And T is tau?

What is the "characteristic time of the exponent?" Never heard of that.

"time of decaying e times?" you've got to admit thats confusing; a time of times?

I've bought a DSP book and I hope this will clear up some of the terminology conventions although I'm sure if the Audio Programming book had been more explanatory I could avoid that but its probably not a bad thing to do anyway for other reasons unless you could recommend another area to read up on?

How do you guys know this stuff anyway? Do you work in the industry or r u self taught hobbyists?

Post


Post

Did my own version based on the wikipedia's first example formula, seems to work the same. I admit its no more intelligable but at least I can understand whats going on.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(int argc, char**argv)
{
	int t,nsteps;
    double step, dur, inc, k;
    const double A = 1.0; /* N[0] */

	if(argc != 4){
		printf("usage:  expdecay dur k steps\n");
		return 1;
	}

    dur    = atof(argv[1]);
	k      = atof(argv[2]);
	nsteps = atoi(argv[3]);

	inc = dur/nsteps; /* the constant time increment */
	step = 0.0;
	
	fprintf(stderr,"dur = %.4f, k = %.4f\n",dur,k);
	
	for(t=0;t < nsteps;t++){
		printf("%.4f\t%.8f\n",step, A * exp(-k * t));
		step += inc;
	}
	return 0;
}
As for their original formula
x=ae^-k/T
its not really what they do in the code, unless they are using some kind of coding short hand I don't know. They say in the book 'a' is the first term like N[0], so in the case of audio its always 1 and their use of both T and k is very misleading. Why use k to stand for the time increment???

Post

k is sometimes used as the index in the time serie.
Also your code is far slower that the original one.

Post

Ok, how do I get from the formula I use to one where you have a constant ratio to keep multiplying x by like they have in the book code?

In other words how do I get from

N[t] = N[0]e^(-kt)

to something like

x=ae^-k/T

?

The mystery seems to me to be what is contained in T because it can't be anything variable.

Post

minimaltom wrote:Ok, how do I get from the formula I use to one where you have a constant ratio to keep multiplying x by like they have in the book code?
I already provided the answer above:

Either way, the recursive calculation works like this:

let x[n] = exp(-n*k*T)
then x[n+1] = exp(-(n+1)*k*T) = exp(-k*T)*exp(-n*k*T) = exp(-k*T)*x[n]

The first substitution is because exp(a+b)=exp(a)*exp(b) for any (real or complex) a and b.
The second substitution is simply the definition of x[n] and since exp(-k*T) is now "constant" we can simply call it the "coefficient" and we get:

x[n+1] = coefficient * x[n].

Post

Yes but its insufficient explaination

x[n+1] = exp(-k/T)*x[n]

not

exp(-k*T)*x[n]

Post

You keep on changing the variables. That's what is confusing you.

There is nothing complicated here. x^(n+1) = x*x^n. That's it. There is nothing more complicated than that, and x can be anything, e^(-k) or anything else.
Just simple high school math, nothing more.

Post Reply

Return to “DSP and Plugin Development”