[solved] problem outputing microphone in real-time using ofsoundstream

hey folks,
i’m trying to build a simple audio program that takes the input from microphone and outputs it using soundstream classes, something like mixing AudioInputExample and AudioOutputExample (oF 0.062).
here’s the code:

  
  
void testApp::setup()  
{  
	ofSoundStreamSetup(2,2,this, 44100, 512, 4);  
	left = new float[512];  
	right = new float[512];  
}  
  

  
  
void testApp::audioReceived 	(float * input, int bufferSize, int nChannels)  
{  
	for (int i = 0; i < bufferSize; i++)  
    {  
		left[i]  = input[i*2] ;  
		right[i] = input[(i*2)+1];  
	}  
}  
  
  
void testApp::audioRequested 	(float * output, int bufferSize, int nChannels)  
{  
	for (int i = 0; i < bufferSize; i++)  
    {  
		output[i*2]     = left[i] ;  
		output[(i*2)+1] = right[i];  
	}  
  
}  
  

my problem is that mixed with the mic’s output appears some strange noises (flickering?) that were not expected…

at first, i thought it could be something related to the buffer size or the sample rate, but even using lower sample rates (eg 22050) i get exactly the same thing…

another strange thing is that the same code works perfectly on oF 0.06, without any problem (in fact, it came out to me when i was trying to reuse some old code on the 0.062)…

any hint?
by the way, i’m using ubuntu 10.04 and codeblocks!

thanks in advance!

not completely sure but i think 006 still had rtaudio3. rtaudio4 has several problems (more in linux) and full duplex audio is usually one of them. we are going to have swappable soundstream in 007 and probably portaudio by default which works much better than rtaudio

if you want to try, this is a branch with 0062 + a portaudio soundstream implementation:

https://github.com/arturoc/openFrameworks/tree/portaudio/

the library is only compiled for linux 64bits so if you are on 32 you will need to compile it. download it from the web, the one in ubuntu repos is some weird version with a totally different api

http://www.portaudio.com/download.html

if the newest one doesn’t work try with the one from 2007:

http://www.portaudio.com/archives/pa-stable-v19-20071207.tar.gz

thanks, arturo!

not completely sure but i think 006 still had rtaudio3.

it’s true: just found in changelogs of 0.061!

:slight_smile: