[Openal] Question about alcCaptureOpenDevice buffersize
Daniel PEACOCK
dpeacock at creativelabs.com
Thu Nov 2 11:23:59 PST 2006
Hi,
The header file definition shouldn't really use the name 'buffersize' it
would be more accurate to say 'samplesize' or 'numsamples' perhaps.
Anyway, the value tells AL how much captured data it should store before
the data is thrown out (overwritten). So, if you set the value to 44100
Samples then if the application doesn't ever capture the samples, when the
44101st sample is captured it will overwrite sample 0 and the 44102nd
sample will overwrite sample 1 etc ... Basically you need to set this to
a value that gives the rest of your application enough time to service the
captured stream (i.e pulled captured samples out of the capture buffer).
So, in the example code (which is hardcoded to record a 22KHz 16bit mono
stream) it is telling OpenAL to buffer 200ms of captured audio data (which
is 4410 Samples; equivalent to 8820 bytes (because it is 16bit mono)). The
capture data is read out whenever 4410 Bytes are available (half of the
captured buffer size). If you want to capture stereo and / or a higher
frequency then you could continue to capture 4410 samples if you like (this
would be 100ms of audio data) - but you will need to retrieve the data
faster and expect to get more data (e.g 4 bytes for each captured sample).
Dan
> The "buffersize" ("samps" in the specification) is the number of samples
> which the application would like to retrieve. The buffer must be at
> least large enough to contain that number of samples, but is allowed to
> be larger.
>
> Garin
> Dear all,
> I see many many doc online have different answer on buffersize in
> alcCaptureOpenDevice.
>
> ALCdevice * alcCaptureOpenDevice(const ALCchar * devicename, ALCuint
> frequency, ALCenum format, ALCsizei buffersize);
>
> Case 1: buffersize = the byte size of the buffer will get by
alcCaptureSamples
> Case 2: buffersize = ( the byte size of the buffer will get by
> alcCaptureSamples ) /2
> Case 3: buffersize = wave samples
> Case 4: buffersize = wave feq (SamplesPerSec) () * 5 +1
> Case 5: buffersize = wave feq (SamplesPerSec) () * 2
> Case 6: buffersize = 0 ( error in alcCaptureSamples )
>
> in API Spec:
> buffersize = the size of the capture buffer, it means case 1?
>
> in offical example "C:\Program Files\OpenAL 1.1
SDK\samples\Capture\Source" is
> the code is case 1, but the remarks
> // Open the default Capture device to record a 22050Hz 16bit Mono Stream
using
> an internal buffer
> // of BUFFERSIZE( 4410 ) Samples (== BUFFERSIZE * 2 bytes)
> it make me confuse,
> 1, how can calc BUFFERSIZE : 4410
> 2. if it's 16 bit need BUFFERSIZE = BUFFERSIZE *2 ? what if Stereo?
> 3. i have try set another number to buffersize , it runs normal, what is
this
> var. use for?
>
> thanks
> _______________________________________________
> Openal mailing list
> Openal at opensource.creative.com
> http://opensource.creative.com/mailman/listinfo/openal
> ForwardSourceID:NT0003858E
More information about the Openal
mailing list