5 #include "cRawDecoder.h" 9 cRawDecoder::cRawDecoder(IDataSource* stream,
unsigned int frequency,
AudioFormats format) : IAudioDecoder(stream), Frequency(frequency), Format(format)
14 cRawDecoder::~cRawDecoder()
41 return Stream->read(output,amount);
46 Stream->seek(position,relative);
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;
63 return setPosition(amountToSeek, relative);
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);
82 return Stream->getSize();
87 return Stream->getSize();
93 if(Format == EAF_8BIT_MONO)
95 else if(Format == EAF_8BIT_STEREO)
97 else if(Format == EAF_16BIT_MONO)
102 return (
float)Stream->getCurrentPos() / ((float)Frequency * (
float)SampleSize);
107 return Stream->getCurrentPos();
112 return Stream->getCurrentPos();
117 return cAudioString(_CTEXT(
"cRawDecoder"));
virtual int readAudioData(void *output, int amount)
Reads a section of data out of the audio stream.
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 cAudioString getType() const
Returns the IAudioDecoderType.
virtual bool isSeekingSupported()
Returns whether seeking is supported.
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.