afInitSampleFormat(3dm) afInitSampleFormat(3dm) NAME afInitSampleFormat, AFinitsampfmt, afInitByteOrder, afInitChannels, afInitRate - initialize the audio data format in an AFfilesetup for a specified audio track SYNOPSIS #include <dmedia/audiofile.h> void afInitSampleFormat(AFfilesetup setup, int track, int sampfmt, int sampwidth) void afInitByteOrder(AFfilesetup setup, int track, int byteorder) void afInitChannels(AFfilesetup setup, int track, int channels) void afInitRate(AFfilesetup setup, int track, double rate) PARAMETER 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. sampfmt an integer constant which denotes a sample format. sampwidth a positive integer value which specifies the number of bits in a sample data point. channels is a positive integer value which indicates the number of interleaved audio channels in the audio track. byteorder is a positive integer token which indicates the byte order of the samples in the audio track. rate is a positive double-precision floating point value which specifies an audio sample rate in Hz to be associated with track. afInitSampleFormat() initializes the sample format and width parameters in an AFfilesetup structure for an audio track. The following values may be used for sampfmt AF_SAMPFMT_TWOSCOMP Two's complement samples. This is currently the only legal value for AIFF(4)/AIFF-C and 9-32 bit WAVE(4) format files, and is a legal value for all other supported file formats as well. AF_SAMPFMT_UNSIGNED Unsigned samples. This is the standard value for 1-8 bit WAVE(4) format files. AF_SAMPFMT_FLOAT 32-bit floating point samples. This may be used with NeXT(4) and BICSF(4) format files, as may AF_SAMPFMT_TWOSCOMP. AF_SAMPFMT_DOUBLE 64-bit double-precision floating point samples. Currently, this may only be used with the NeXT(4) format files. afInitByteOrder() initializes the byte order (big- or little-endian) of the samples in an AFfilesetup structure for an audio track. The following values may be used for byteorder AF_BYTEORDER_BIGENDIAN Big-endian byte order samples. This is the only legal value for AIFF/AIFF-C, NeXT(4), BICSF(4) and Sound Designer II (sd2(4)) files, and is the default value. AF_BYTEORDER_LITTLEENDIAN Little-endian byte order samples. This is the standard value for WAVE(4) format files. afInitChannels() initializes the number of interleaved channels in an AFfilesetup structure for an audio track. Legal values vary depending on the file format (see afInitFileFormat(3dm)). afInitRate() initializes the sample rate in Hz in an AFfilesetup structure for an audio track. Most file formats have no restrictions on sample rate values, the exception being the NeXT(4) format, which requires integer values only. When a file is opened for writing by passing setup to afOpenFile(3dm), the track will be configured to store data according to the data format, width, number of channels, or sample rate specified. CAVEATS The Audio File Library will continue to support additional file formats. The ability of these file formats to store data of various sample formats will vary. If you are choosing a file format other than the default format, you should make sure that you explicitly specify a sample format for this file's tracks which is compatible with that file format. See afGetSampleFormat(3dm) for important information about handling this situation. In the case where the audio track in a file is configured for compression, sampfmt and sampwidth should match the data format specified by the compression algorithm. For example, the software G.722 compressor expects to encode 16-bit two's complement linear PCM input data. In addition, many compression formats have restrictions on sample rate and/or channel count as well. See afInitCompression(3dm) for more information. SEE ALSO afNewFileSetup(3dm), afOpenFile(3dm), afWriteFrames(3dm), afSetVirtualSampleFormat(3dm), afGetVirtualSampleFormat(3dm), afInitCompression(3dm) Page 3