[Openal] Queuing/Unqueuing waveforms
bruckmann at mechatronik.uni-duisburg.de
Thu Oct 23 23:22:46 PDT 2008
I have to implement a waveform synthesizer. Finally, it should mix sine
waves with different frequencies, and during runtime, these frequencies
change. So I have to use queing, I think. I'm using ALUT routines to
generate sound which works fine - I have a clear sound. Now I have the
problem to change the queue content - I hear the sound (2 different
buffers), but when I try to remove the last played one, I always get the
information that there are no processed buffers. So I can't remove one
of my buffers from the queue to remove it.
What is the reason for that?
Additionally, one question: How can I mix different frequencies at the
same time? Do I have to define a source for every frequency and play
them simultaneously, or how does it work?
The code below plays two buffers in a loop as it should. After 5 seconds
I expect it to replace the buffers by one with a different frequency
which doesn't work.
Output of the code below (sound is playing):
Number of loaded buffers: 2
Number of processed buffers: 0 //<- That makes me crazy
No errors detected!
ALUT error state: No ALUT error found
What's the problem here?
Thanks a lot and best regards,
if (!alutInit (NULL, NULL))
mexPrintf("Failed to initialize OpenAL\n");
uiBuffers = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 60.0,
uiBuffers = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 100.0,
alGenSources( 1, &uiSource );
alSourcei(uiSource, AL_LOOPING, AL_TRUE);
alSourcePlay( uiSource );
alGetSourcei(uiSource, AL_BUFFERS_QUEUED, &processed);
mexPrintf("Number of loaded buffers: %i\n",processed);
alGetSourcei(uiSource, AL_BUFFERS_PROCESSED, &processed);
mexPrintf("Number of processed buffers: %i\n",processed);
alSourceUnqueueBuffers(uiSource, 1, &buffer);
uiBuffer = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 1000.0,
alSourceQueueBuffers(uiSource, 1, &buffer);
if(alGetError() == AL_NO_ERROR)
mexPrintf("No errors detected!\n");
mexPrintf ("ALUT error state: %s\n",alutGetErrorString
More information about the Openal