arduino-audio-tools
|
Vorbis Streaming Decoder using https://github.com/pschatzmann/arduino-libvorbis-tremor. More...
#include <CodecVorbis.h>
Public Member Functions | |
VorbisDecoder (size_t buffer_size=256, int header_packets=3) | |
Constructor for VorbisDecoder. | |
~VorbisDecoder () | |
Destroy the VorbisDecoder object. | |
~VorbisDecoder () | |
Destructor for VorbisDecoder. | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
AudioInfo | audioInfo () override |
Provides the last available MP3FrameInfo. | |
AudioInfo | audioInfo () override |
Returns audio stream info (sample rate, channels, bits per sample) | |
virtual AudioInfo | audioInfoOut () |
bool | begin () override |
Starts the processing. | |
bool | begin () override |
Resets decoder state and prepares for new Vorbis stream. | |
virtual bool | begin (AudioInfo info) override |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
virtual bool | copy () override |
Process a single read operation - to be called in the loop. | |
bool | copyAll () |
Process all available data. | |
void | end () override |
Releases the reserved memory. | |
void | end () override |
Cleans up all Vorbis decoder structures. | |
Print * | getOutput () |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
virtual bool | isResultPCM () |
Returns true to indicate that the decoding result is PCM data. | |
const char * | mime () override |
Provides "audio/ogg". | |
virtual | operator bool () override |
checks if the class is active | |
operator bool () override | |
Returns true if decoder is active. | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
void | setAudioInfo (AudioInfo from) override |
for most decoders this is not needed | |
virtual bool | setCodecConfig (const uint8_t *data, size_t len) |
Some decoders need e.g. a magic cookie to provide the relevant info for decoding. | |
void | setDelayOnNoData (size_t delay) |
Defines the delay when there is no data. | |
void | setInput (Stream &inStream) |
Stream Interface: Decode directly by taking data from the stream. | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
virtual void | setOutput (AudioOutput &out_stream) |
Defines where the decoded result is written to. | |
virtual void | setOutput (AudioOutput &out_stream) |
Defines the output streams and register to be notified. | |
virtual void | setOutput (AudioStream &out_stream) |
Defines where the decoded result is written to. | |
virtual void | setOutput (AudioStream &out_stream) |
Defines the output streams and register to be notified. | |
virtual void | setOutput (Print &out_stream) |
Defines the output Stream. | |
virtual void | setOutput (Print &out_stream) override |
Defines where the decoded result is written to. | |
void | setReadSize (size_t size) |
Defines the default read size. | |
void | setWaitForData (size_t wait) |
Defines the delay to wait if there is not enough data to open the decoder. | |
size_t | write (const uint8_t *data, size_t len) override |
Feeds a Vorbis packet (header or audio) to the decoder. | |
Public Attributes | |
int | id |
custom id to be used by application | |
Protected Member Functions | |
void | convertFloatToInt16PCM (float **pcm, int samples, int channels) |
Converts float PCM to interleaved int16 PCM and stores in pcmout_buffer. | |
AudioInfo | currentInfo () |
size_t | decodeAudioPacket (ogg_packet &packet) |
Decodes an audio packet and writes PCM to output. | |
const char * | getOpenError (int error) |
bool | initDecoder () |
Initializes the Vorbis decoder after header parsing. | |
void | notifyAudioChange (AudioInfo info) |
void | notifyAudioChange (AudioInfo info) |
bool | ovOpen () |
bool | parseHeaderPacket (ogg_packet &packet, int header_packets) |
Parses a Vorbis header packet. | |
virtual size_t | readBytes (uint8_t *data, size_t len) override |
Reads bytes from the input stream. | |
const char * | readError (long error) |
void | setAudioInfo (AudioInfo newInfo) override |
Defines the input AudioInfo. | |
void | writeBlocking (Print *out, uint8_t *data, size_t len) |
Protected Attributes | |
bool | active = false |
Decoder active state. | |
int | bitstream = 0 |
ov_callbacks | callbacks |
AudioInfo | cfg |
bool | decoder_initialized = false |
size_t | delay_on_no_data_ms = 100 |
size_t | delay_wait_for_data_ms = 500 |
OggVorbis_File | file |
int | header_packets = 0 |
AudioInfo | info |
AudioInfo | info |
bool | is_first = true |
bool | is_notify_active = true |
bool | is_notify_active = true |
bool | is_ov_open = false |
size_t | max_read_size = 1024 |
Vector< AudioInfoSupport * > | notify_vector |
Vector< AudioInfoSupport * > | notify_vector |
int | num_header_packets = 3 |
Number of Vorbis header packets. | |
Stream * | p_input = nullptr |
Input stream for encoded audio data. | |
Print * | p_print = nullptr |
Output stream for PCM audio. | |
Vector< uint8_t > | pcm {0} |
size_t | pcm_buffer_size = 256 |
PCM output buffer size. | |
Vector< int16_t > | pcmout_buffer |
Buffer for interleaved PCM output. | |
vorbis_block | vb {} |
Block structure for synthesis. | |
vorbis_comment | vc {} |
Vorbis comment metadata. | |
vorbis_dsp_state | vd {} |
Decoder state for synthesis. | |
vorbis_info | vi {} |
Vorbis stream info (channels, sample rate, etc.) | |
Vorbis Streaming Decoder using https://github.com/pschatzmann/arduino-libvorbis-tremor.
Vorbis Audio Decoder using low-level libvorbis API.
This decoder expects Ogg Vorbis packets to be provided via the write() method. It parses the Vorbis headers, initializes the decoder, and outputs PCM audio.
Usage:
|
inline |
Constructor for VorbisDecoder.
buffer_size | Size of the PCM output buffer (default: 256) |
header_packets | Number of Vorbis header packets (default: 3) |
Initializes the decoder and allocates the PCM output buffer.
|
inline |
Destructor for VorbisDecoder.
Cleans up all decoder resources.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtual |
Provides the last available MP3FrameInfo.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Returns audio stream info (sample rate, channels, bits per sample)
Implements StreamingDecoder.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtual |
Starts the processing.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Resets decoder state and prepares for new Vorbis stream.
This method clears all decoder state, resizes the PCM output buffer, and initializes Vorbis structures. Call this before feeding header packets.
Implements StreamingDecoder.
|
inlineoverridevirtualinherited |
Reimplemented from AudioWriter.
|
inlineprotected |
Converts float PCM to interleaved int16 PCM and stores in pcmout_buffer.
pcm | Pointer to float PCM array [channels][samples] |
samples | Number of samples |
channels | Number of channels |
|
inlineoverridevirtual |
Process a single read operation - to be called in the loop.
Reads a chunk of data from the input stream, decodes it, and writes the decoded PCM data to the output stream.
Implements StreamingDecoder.
|
inlineinherited |
Process all available data.
Convenience method that calls copy() repeatedly until all available data has been processed.
|
inlineprotected |
Decodes an audio packet and writes PCM to output.
packet | Ogg Vorbis audio packet |
|
inlineoverridevirtual |
Releases the reserved memory.
Implements StreamingDecoder.
|
inlineoverridevirtual |
Cleans up all Vorbis decoder structures.
Implements StreamingDecoder.
|
inlineprotected |
Initializes the Vorbis decoder after header parsing.
|
inlinevirtualinherited |
Returns true to indicate that the decoding result is PCM data.
Reimplemented in CopyDecoder, DecoderNetworkFormat, GGWaveDecoder, and ContainerM4A.
|
inlineoverridevirtual |
Provides "audio/ogg".
Implements StreamingDecoder.
|
inlineoverridevirtual |
checks if the class is active
Implements StreamingDecoder.
|
inlineoverridevirtual |
Returns true if decoder is active.
Implements StreamingDecoder.
|
inlineprotected |
Parses a Vorbis header packet.
packet | Ogg Vorbis header packet |
header_packets | Index of header packet (0, 1, 2) |
|
inlineoverrideprotectedvirtual |
Reads bytes from the input stream.
Derived classes must implement this to read data from their input source.
data | Buffer to store the read data |
len | Maximum number of bytes to read |
Implements StreamingDecoder.
|
inlineoverridevirtualinherited |
for most decoders this is not needed
Implements AudioWriter.
Reimplemented in GGWaveDecoder, DecoderALAC, CodecChain, DSFDecoder, DecoderL8, OpusAudioDecoder, CodecNOP, and G7xxDecoder.
|
inlineoverrideprotectedvirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
|
inlinevirtualinherited |
Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
Reimplemented in DecoderALAC, and MultiDecoder.
|
inlineinherited |
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlinevirtualinherited |
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
out_stream | The AudioOutput to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlinevirtualinherited |
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
out_stream | The AudioStream to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
|
inlinevirtualinherited |
Defines the output Stream.
Sets where the decoded PCM audio data will be written to.
out_stream | The Print stream to write decoded audio data to |
Reimplemented in StreamingDecoderAdapter, and MultiStreamingDecoder.
|
inlineoverridevirtualinherited |
Defines where the decoded result is written to.
Implements AudioWriter.
Reimplemented in DecoderBase64, MP3DecoderMAD, DecoderAdapter, CodecNOP, ADPCMDecoderXQ, APTXDecoder, Codec2Decoder, CopyDecoder, G722Decoder, GSMDecoder, ILBCDecoder, LC3Decoder, DecoderNetworkFormat, SBCDecoder, WavIMADecoder, GGWaveDecoder, AACDecoderFDK, AACDecoderHelix, ADPCMDecoder, ADTSDecoder, DecoderBasic, CodecChain, DecoderFloat, G7xxDecoder, DecoderL16, MTSDecoder, OpusAudioDecoder, MTSDecoderTSDemux, WAVDecoder, AVIDecoder, ContainerM4A, MultiDecoder, MetaDataFilterDecoder, MP3DecoderMini, BinaryContainerDecoder, OSCContainerDecoder, MP3DecoderHelix, and OggContainerDecoder.
|
inlineoverridevirtual |
Feeds a Vorbis packet (header or audio) to the decoder.
The first three packets must be Vorbis headers. Subsequent packets are audio. PCM output is written to the Print stream set via setOutput().
data | Pointer to packet data |
len | Length of packet data |
Implements AudioWriter.