int AFfReadData(AFILE *AFp, long int offs, float Dbuff[], int Nreq)
Read data from an audio file (return float values)
This routine returns a specified number of samples at a given sample offset in an audio file. The data in the file is converted to float format on output. The sample data in the file is considered to be preceded and followed by zero-valued samples. Thus if the sample offset is negative or points to beyond the number of samples in the file, the appropriate number of zero-valued samples is returned. The file must have been opened using routine AFopnRead.
This routine returns float data. This format gives 24 bits of precision. A loss of precision is possible if the input file contains double or 32-bit integer data.
The following program fragment illustrates the use of this routine to read overlapping blocks of data. For the simpler case of sequential access to the data without overlap, the variable Lmem should be set to zero.
float Dbuff[320]' ... AFp = AFopnRead(...); ... Lmem = 80; Lblock = 320; Nadv = Lblock - Lmem; offs = -Lmem; while (1) { Nout = AFfReadData(AFp, offs, Dbuff, Lblock); offs = offs + Nadv; if (Nout <= 0) break; ... }
On encountering an error, the default behaviour is to print an error message and halt execution.
P. Kabal / Revision 1.15 2020-11-26