The file seek functions work much like
hseek with the exception
that the non-audio data is ignored and the seek only moves within the
audio data section of the file. In addition, seeks are defined in
number of (multichannel) frames. Therefore, a seek in a stereo file
from the current position forward with an offset of 1 would skip
forward by one sample of both channels.
like lseek(), the whence parameter can be any one of the following
three values:
- AbsoluteSeek - The offset is set to the start of the audio
data plus offset (multichannel) frames.
- RelativeSeek - The offset is set to its current location
plus offset (multichannel) frames.
- SeekFromEnd - The offset is set to the end of the data plus
offset (multichannel) frames.
Internally, libsndfile keeps track of the read and write locations
using separate read and write pointers. If a file has been opened with
a mode of
ReadWriteMode, calling either
hSeekRead or
hSeekWrite allows the read and write pointers to be modified
separately.
hSeek modifies both the read and the write pointer.
Note that the frames offset can be negative and in fact should be when
SeekFromEnd is used for the whence parameter.
hSeek will return the offset in (multichannel) frames from the
start of the audio data, or signal an error when an attempt is made to
seek beyond the start or end of the file.