[Openal] Recording and Playing Simultaneously

Spike7d5 spike7d5 at yahoo.com
Mon Jul 23 14:17:01 PDT 2007


Hello,

I want to record and play sound at the same time, but I don't know how to do
this. I've managed to play my own recordings, but I can't manage to combine
these 2 together. Can anybody help me, please? 

Throughout the program, every AL function is checked for errors, and one
appears at alBufferData - "invalid value passed to AL function". Here is a
small portion of my code, that I believe is important. And also, I must say
that the program never gets to that printf.



ALCdevice *deviceCapture = alcCaptureOpenDevice(NULL, 22050,
AL_FORMAT_MONO8, (ALCsizei) 10000);
...
char bufferCapture[220500];
int total = 0;
while (key != 27)
{
	ALCint samples;
	alcGetIntegerv(deviceCapture, ALC_CAPTURE_SAMPLES, 1, &samples);

	if (samples >= 1)
	{
		alcCaptureSamples(deviceCapture, bufferCapture, samples);
		if ((result = alGetError()) == AL_NO_ERROR)
		{
			alBufferData(buffer, AL_FORMAT_MONO8, bufferCapture, samples, 22050);
			if ((result = alGetError()) != AL_NO_ERROR)
			{
				printf("Error setting capture buffer: %s\n", getErrorString(result));
				_getch();
				return -1;
			}

			alSourcePlay(source);

			total += samples;
			printf("%d\n", total);
		}
		else
		{
			printf("Error getting samples: %s\n", getErrorString(result));
			_getch();
			return -1;
		}
	}

	if (_kbhit())
		key = _getch();
}
-- 
View this message in context: http://www.nabble.com/Recording-and-Playing-Simultaneously-tf4132517.html#a11752973
Sent from the OpenAL - User mailing list archive at Nabble.com.



More information about the Openal mailing list