sweep generation

Hello everybody,

I'm trying to generate a sweep in C++.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	vector<float> vOut_t;
	int length = fs*T;
	float value;
        float K  = 2*PI*f1 * T / (log(f2/f1));
	float L = T/log(f2/f1);

	float t, t2;


	for(t=0;t<length;++t)		
	{
		t2=t/fs;

		value = exp(t2/L) -1;
		value = sin(K*value);
		vOut_t.push_back(value);
	}


When I send the sweep to the soundcard and listen to it, the beginning (low freqencies ) sounds as expected. But at the end ( high frequencies ) the signal does not only contain the pure sine sweep but also some sort of overlay.

If I generate the sweep in scilab, load it into vOut_t and then send it to the soundcard via ASIO, the sweep sounds perfect.

The algorithm for generating a sine-sweep is discribed on [url]http://pcfarina.eng.unipr.it/Public/Papers/134-AES00.PDF[/url] (page 6).

Is it possible to upload the soundfiles to this forum?

I'm using Visual C++ 2008 Express Edition


Does anybody have an idea about how to solve the problem?


Thank you in advance

jomammele

Last edited on
But at the end ( high frequencies ) the signal does not only contain the pure sine sweep but also some sort of overlay.


My hot guess for today is: Arithmetic overflow. You may have an overflow or precision problem somewhere. Did you tried just replaing "float" with "double"?

Ciao, Imi.
Last edited on
Hello Imi,

thank you for your answer.

I tried this but it didn't solve the problem.

Greetings

jomammele
you can debug it, by storing the last value in the for loop and comparing the new one to the last. Then break in debugger as soon as the difference is greater than a certain threshold. Since you are doing sine waves, it shouldn't happen, but you may get the strange overlays with this.

Then you know at least an example frequency and you can try to print the intermediate values and see whether it's really some precision/overflow problem or a mistake in your formula.

Ciao, Imi.
Hello Imi,

I could solve it.

It's not only necessary to change vOut_f and value to "double" but also all the other parameters.

Furthermore it's important to set the buffersize of the soundcard as high as possible (2048) to avoid interruptions.

Thanks for the help

jomammele
Topic archived. No new replies allowed.