#include <wvspeex.h>
Inbut buffer must contain a sequence of Speex packets.
Output buffer will contain a sequence of signed 'float' type values in machine order representing unnormalized PCM audio data.
Missing audio due to lost or damaged packets may be filled in by making predictions (guesses) based on residual energy information from previous ones. The number of lost or damaged packets must be known in order to calculate how much new audio must be synthesized. This technique works well to conceal occasional dropouts but not long strings of lost packets. Still, Speech is still surprizingly recognizable with average packet losses of up to 25% to 50!
Warning: Never invoke encode() unless the input buffer contains exactly zero or one Speex packets. Speex packets do not contain any delimiters therefore it is not possible to locate the boundary between adjacent packets unless they are encapsulated as individual datagrams in some fashion. Multiple adjacent packets cannot be decoded at once.
For archival purposes or for streaming, consider using WvOggSpeexDecoder.
For encoding music or other non-speech audio, consider using WvOggVorbisDecoder.
Definition at line 260 of file wvspeex.h.
Public Member Functions | |
WvSpeexDecoder (int samplingrate, unsigned int channels=1, WvSpeex::CodecMode mode=WvSpeex::DEFAULT_MODE) | |
Creates a Speex Decoder. | |
virtual bool | missing (OBuffer &outbuf) |
Synthesizes one audio frame to compensate for a missing packet. | |
virtual unsigned int | channels () const |
Returns the number of channels in the stream. | |
int | samplingrate () const |
Returns the sampling rate of the stream. | |
virtual size_t | samplesperframe () const |
Returns the number of samples per frame. | |
WvSpeex::CodecMode | mode () const |
Returns the current encoding mode. | |
bool | postfilter () const |
Determines if the perceptual enhancement post-filter is enabled. | |
void | setpostfilter (bool enable) |
Enables or disables the perceptual enhancement post-filter. | |
Protected Member Functions | |
virtual bool | _typedencode (IBuffer &inbuf, OBuffer &outbuf, bool flush) |
virtual bool | _typedfinish (OBuffer &outbuf) |
WvSpeexDecoder::WvSpeexDecoder | ( | int | samplingrate, | |
unsigned int | channels = 1 , |
|||
WvSpeex::CodecMode | mode = WvSpeex::DEFAULT_MODE | |||
) |
Creates a Speex Decoder.
For now, if the input bitstream is stereo, outputs the left channel only. This behaviour may change later on.
"samplingrate" is the number of samples per second, preferably one of 8000, 16000, or 32000 "channels" is number of channels (must be 1 for now), defaults to 1 "mode" is the Speex codec mode to use or WvSpeex::DEFAULT_MODE to select one automatically based on the sampling rate, this is the default
virtual bool WvSpeexDecoder::missing | ( | OBuffer & | outbuf | ) | [virtual] |
Synthesizes one audio frame to compensate for a missing packet.
"outbuf" is the output buffer Returns: true on success
virtual unsigned int WvSpeexDecoder::channels | ( | ) | const [inline, virtual] |
int WvSpeexDecoder::samplingrate | ( | ) | const [inline] |
virtual size_t WvSpeexDecoder::samplesperframe | ( | ) | const [inline, virtual] |
WvSpeex::CodecMode WvSpeexDecoder::mode | ( | ) | const |
Returns the current encoding mode.
Returns: the encoding mode
bool WvSpeexDecoder::postfilter | ( | ) | const |
Determines if the perceptual enhancement post-filter is enabled.
Returns: true if it is enabled
void WvSpeexDecoder::setpostfilter | ( | bool | enable | ) |
Enables or disables the perceptual enhancement post-filter.
"enable" is true or false