alReadFrames(3dm) alReadFrames(3dm)
alReadFrames - read interleaved sample frames from an audio port
#include <dmedia/audio.h>
int alReadFrames(const ALport port, void *samples, const int framecount)
port is the audio input port from which you want to read samples.
This is the returned value of an alOpenPort(3dm) call.
samples is the buffer into which you want to read the samples.
framecount is the number of sample frames that you want to read from
the audio port.
alReadFrames transfers data from an audio port to the samples buffer.
alReadFrames blocks until framecount sample frames have been transferred
to the samples buffer. If you do not wish to block, make sure that
framecount is less than the return value of alGetFilled(3dm).
The format of the data written into samples depends upon the
configuration of the port. Each sample can be an 8-, 16-, or 32-bit
integer, or a single- or double-precision floating-point value or subcode
data; see alSetSampFmt(3dm), alSetFloatMax(3dm) and alSetWidth(3dm) for a
description of how these formats work. By default, the sample format is
16-bit integer (short).
Within each sample frame, alReadFrames provides interleaved data. The
number of samples per sample frame varies according to the value
specified by alSetChannels(3dm). By default, the port provides stereo
data (2 samples per frame).
In order to achieve the best possible performance, alReadFrames does not
verify that port or samples are valid. You should make certain these
values are valid before passing them as arguments to alReadFrames.
The following code fragment opens an audio input port and reads audio
data from it.
Page 1
alReadFrames(3dm) alReadFrames(3dm)
ALport p;
short buf[10000]; /* 5000 stereo frames */
/* open a port with the default configuration */
p = alOpenPort("alReadFrames example","r",0);
if (!p) {
printf("port open failed:%s\n", alGetErrorString(oserror()));
}
while (1) {
alReadFrames(p, buf, 5000); /* read 5000 stereo frames */
/* do something here with the audio data */
}
alReadFrames always returns 0.
alOpenPort(3dm), alGetFillable(3dm), alGetFilled(3dm),
alSetChannels(3dm), alSetWidth(3dm), alWriteFrames(3dm),
alDiscardFrames(3dm), alSetConfig(3dm), alSetQueueSize(3dm),
alSetSampFmt(3dm), alSetFloatMax(3dm)
PPPPaaaaggggeeee 2222 [ Back ]
|