afInitDataOffset(3dm) afInitDataOffset(3dm)
afInitDataOffset, afInitFrameCount - initialize the audio data byte
offset / frame count in an AFfilesetup for a specified raw-format audio
track
#include <dmedia/audiofile.h>
void afInitDataOffset(AFfilesetup setup, int track, AFfileoffset offset)
void afInitFrameCount(AFfilesetup setup, int track, AFframecount count)
setup is an AFfilesetup structure, previously created by a call to
afNewFileSetup(3dm).
track is an integer which identifies an audio track in setup.
Since all currently supported file formats contain only one
audio track, the value AF_DEFAULT_TRACK should always be used
here.
offset is a positive value which specifies the offset in bytes for the
audio data associated with track. The data type AFfileoffset is
large enough to hold any data offset allowed by the filesystem.
count is a positive value which specifies the number of frames of
audio data to be associated with track. The data type
AFframecount is large enough to hold any frame count allowed by
the filesystem.
afInitDataOffset() initializes the audio data offset in an AFfilesetup
structure for an audio track.
afInitFrameCount() initializes the audio frame count in an AFfilesetup
structure for an audio track.
When a file is opened for reading or writing by passing setup to
afOpenFile(3dm), the track will be configured to read or write data using
the data offset and/or frame count specified. These routines may only be
used when reading or writing raw (headerless) audio files. All non-raw
audio formats have a fixed data offset determined by their headers.
These routines are also useful for reading audio file formats which are
not supported by the Audio File Library, but whose format is known to a
particular application. If the application can supply all the necessary
parameters (data offset, frame count, sample format, rate, and channel
count), then the file can be read as a raw file via afReadFrames().
Page 1
afInitDataOffset(3dm) afInitDataOffset(3dm)
EXAMPLE
Attempt to read a raw audio file with a known data offset of 60 bytes and
a known frame count of 1000. All other parameters default to the default
AIFF(4) file values: 16-bit 2's complement, 1 channel, 44.1kz rate.
#include <dmedia/audiofile.h>
main()
{
AFfilesetup setup;
AFfilehandle inHandle;
short buf[1024];
AFframeoffset fileOffset = 60;
AFframecount frameCount = 1000;
/* create setup */
setup = afNewFileSetup();
/* configure as raw file with given offset and frame count */
afInitFileFormat(setup, AF_FILE_RAWDATA);
afInitDataOffset(setup, AF_DEFAULT_TRACK, fileOffset);
afInitFrameCount(setup, AF_DEFAULT_TRACK, frameCount);
/* open the file */
inHandle = afOpenFile("myrawsoundfile", "r", setup);
/* read all the frames */
afReadFrames(inHandle, AF_DEFAULT_TRACK, buf, frameCount);
}
afNewFileSetup(3dm), afOpenFile(3dm), afWriteFrames(3dm),
afSetVirtualSampleFormat(3dm), afGetVirtualSampleFormat(3dm),
PPPPaaaaggggeeee 2222 [ Back ]
|