5 #include "cRawDecoder.h" 9 cRawDecoder::cRawDecoder(IDataSource* stream,
unsigned int frequency,
AudioFormats format) : IAudioDecoder(stream), Frequency(frequency), Format(format)
14 cRawDecoder::~cRawDecoder()
53 if(Format == EAF_8BIT_MONO)
55 else if(Format == EAF_8BIT_STEREO)
57 else if(Format == EAF_16BIT_MONO)
62 int amountToSeek = seconds * (float)Frequency * (
float)SampleSize;
69 if(Format == EAF_8BIT_MONO)
71 else if(Format == EAF_8BIT_STEREO)
73 else if(Format == EAF_16BIT_MONO)
77 return (
float)
Stream->
getSize() / ((float)Frequency * (
float)SampleSize);
93 if(Format == EAF_8BIT_MONO)
95 else if(Format == EAF_8BIT_STEREO)
97 else if(Format == EAF_16BIT_MONO)
117 return cAudioString(_CTEXT(
"cRawDecoder"));
virtual int readAudioData(void *output, int amount)
Reads a section of data out of the audio stream.
virtual cAudioString getType() const
Returns the IAudioDecoderType.
virtual AudioFormats getFormat()
Returns the format of the audio data.
virtual int getCurrentCompressedPosition()
Returns the position in the compressed (original) audio stream before decoding.
virtual int getFrequency()
Returns the frequency (sample rate) of the audio data.
virtual int getTotalSize()
If available, returns the total decoded size of the audio stream. Returns a negative number if this c...
virtual float getCurrentTime()
If seeking is supported, will return the current position in the stream in seconds. Returns a negative number if the current time cannot be determined.
virtual int getCompressedSize()
Returns the compressed (original) size of the audio stream, before decoding.
virtual bool seek(float seconds, bool relative)
If seeking is supported, will seek the stream to seconds.
virtual bool isValid()
Returns whether the stream is valid for this codec.
virtual int read(void *output, int size)=0
Reads out a section of the data stream.
virtual int getSize()=0
Returns the total size of the data stream.
virtual int getCurrentPos()=0
Returns the current location in the data stream.
virtual bool seek(int amount, bool relative)=0
Seek to a position in the data stream.
virtual bool isSeekingSupported()
Returns whether seeking is supported.
IDataSource * Stream
Pointer to the data source to take audio data from.
virtual int getCurrentPosition()
If available, returns the current position in the decoded audio stream in bytes. Returns a negative n...
virtual bool setPosition(int position, bool relative)
Sets the position in the stream to read from.
virtual float getTotalTime()
If seeking is supported, will return the length of the audio steam in seconds. Returns a negative num...
AudioFormats
Enumeration of audio formats supported by the engine.
Main namespace for the entire cAudio library.