SPKitReader
User's Guide
SPKitReader is a signal input class.
It requests samples from an input soundfile.
SPKitReader is connected to its
input soundfile
with the setInput(const char* sf)
function, where sf is the name of the input soundfile.
setInput() opens the soundfile for reading.
Audio samples are requested from SPKitReader
with the getSample() function.
Here is an example.
The SPKit distribution includes three different versions of SPKitReader
for differenting operating systems.
Choise of these is made when SPKit is compiled.
The "generic" version can be compiled and run
on all platforms, but it supports only the NeXT/Sun
sound file format.
A version for the Audio File Library
can be used on Linux and other systems that
have Audio File Library installed
(see
http://www.68k.org/~michael/audiofile/).
An SGI version is provided for old SGI Irix systems.
The current implementation of SPKitReader
supports only 16-bit integer audio files.
Programmer's Reference
Defined in <spkit/reader.h>
Inherits from SPKitProcessor
SPKitReader
overloads the setInput() function
for opening an input soundfile for reading.
SPKitReader also
redefines getSample().
Public Members
- SPKitError setInput(const char* sf)
- Connect an input soundfile to the object, open the file for reading
and initialize the objects variables,
such as inputSamplingRate,
inputChannelCount and
originalDataFormat,
according to the information stored in the input soundfile header.
- SPKitError setOffsetTime(SPKitFloat value);
- Skip the amount of time (in seconds) indicated by
value from the beginning of soundfile.
This function should be called before calling
getSample() for the first time.
and also before calling setDuration().
- SPKitError setDuration(SPKitFloat value);
- Set the maximum duration of the sample stream to value
(in seconds).
The actual duration is counted from the beginning of the sound file
or from the offset given by a preceding call of
setOffsetTime()
and is determined by either end of file or the desired maximum
duration.
This function should be called before calling
getSample() for the first time.
- SPKitError setOffsetInFrames(SPKitInt value);
- Skip the amount of frames indicated by
value from the beginning of soundfile.
May be used as an alternative to
setOffsetInFrames().
- SPKitError setLengthInFrames(SPKitInt value);
- Set the maximum length of the sample stream to value
in sample frames.
May be used as an alternative to setDuration().
- int getSample(SPKitSample& outputSample,
SPKitProcessor* caller)
- Retrieve an audio sample from sound file.
getSample() reads an audio sample from the input soundfile and
stores it in outputSample.
The sample is converted to SPKitSample and scaled between -1 and 1.
- int32 getFramesLeft()
- Return the amount of sample frames left in the input stream.
Protected Members
These members are specific to the "generic" version of SPKitReader,
which supports the NeXT/Sun soundfile format.
Other versions are not documented yet.
The public members are the same in both versions.
- FILE* filePtr
- pointer to the output soundfile
- SndHeader* fileHeader
- pointer to the output soundfile header
- int32 sampleCount
- number of samples in the input soundfile
- int32 samplesLeft
- number of samples unread samples in the input soundfile