ofSoundStream problem

Hi all

I’ve got a problem with ofSoundStream.

When generating a sinewave I get a lot of clicks, but they dissappear when I connect an external soundcard and set that one to default in my os, while selecting my laptopspeakers in OpenFrameworks. Samplerate,buffersize and nBuffers do not seem to matter. I also tried changing from RTaudio to Portaudio which did not solve it.
I’m using OF 007, and OSX 10.6.8 on a MacBook Pro (15-inch, 2.53GHz, Mid 2009)

Does anyone have any ideas I can try out?


Any chance you could post the code that you’re using? It could be that the max or min value that you’re passing to your soundcard is causing it to drop out, I’ve found that any time I’m generating sound I need to ofClamp() the values that I’m sending.

void testApp::audioOut(float* output, int bufferSize, int nChannels){  
	phaseAdder = (frequency / SAMPLERATE) * M_TWO_PI;  
	while(phase >= M_TWO_PI)  
		phase -= M_TWO_PI;  
	for(int i = 0; i < bufferSize; i++){  
		output[i] = sin(phase);  
		phase += phaseAdder;  

I use only 1 output channel.

I don’t know if this is enough information?

What are you setting frequency and samplerate to? I’m guessing some reasonable value and 44100, but just checking. This works fine for me:

phaseAdder = (400.f / sampleRate) * M_TWO_PI;  
        float ratio = (float) mouseX/ofGetWidth();  
        for(int i = 0; i < bufferSize; i++){    
            phase += phaseAdder;  
            output[i] = sin(phase) * volume * ratio;  

it’s possible that your soundcard doesn’t accept only 1 output channel, try setting stereo and see if that solves it. also always use the values that are passed as arguments to the function, it’s not guaranted that the values that you ask for can actually be set

it’s possible that your soundcard doesn’t accept only 1 output channel

I had wondered the same thing, but I have the same machine && it worked w/o problems. Still, I’d imagine that there’s plenty of cards that don’t accept single channel input.