arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
audio_tools::ResampleStream< T > Class Template Reference

Flexible Stream class which can be used to resample audio data between different sample rates. More...

#include <Resample.h>

Inheritance diagram for audio_tools::ResampleStream< T >:
audio_tools::AudioStreamX audio_tools::AudioStream audio_tools::Stream audio_tools::AudioBaseInfoDependent audio_tools::AudioBaseInfoSource audio_tools::Print

Public Member Functions

 ResampleStream (Print &out, ResamplePrecision precision=Medium)
 Construct a new Resample Stream object which supports resampling on it's write operations. More...
 
 ResampleStream (Stream &in, ResamplePrecision precision=Medium)
 Construct a new Resample Stream object which supports resampling both on read and write. More...
 
int available () override
 Determines the available bytes from the final source stream. More...
 
int availableForWrite () override
 Determines the number of bytes which are available for write. More...
 
bool begin () override
 
bool begin (int channels, int fromRate, int toRate)
 Defines the channels and sample rates.
 
bool begin (ResampleConfig info)
 Defines the channels and sample rates from the AudioBaseInfo. Please call setFromInfo() or setFromSampleRate() before.
 
ResampleConfig defaultConfig ()
 Returns an empty configuration object.
 
size_t readBytes (uint8_t *src, size_t byte_count) override
 Reads the up/downsampled bytes. More...
 
float resampleFactor ()
 
void setAudioInfo (AudioBaseInfo info) override
 Handle Change of the source sampling rate - and channels! More...
 
size_t write (const uint8_t *src, size_t byte_count) override
 Writes the data up or downsampled to the final destination. More...
 
- Public Member Functions inherited from audio_tools::AudioStreamX
 AudioStreamX (AudioStreamX const &)=delete
 
virtual int available () override
 
AudioStreamXoperator= (AudioStreamX const &)=delete
 
virtual int peek () override
 
virtual int read () override
 
virtual size_t readBytes (uint8_t *buffer, size_t length) override
 
virtual size_t write (const uint8_t *buffer, size_t size) override
 
virtual size_t write (uint8_t) override
 
- Public Member Functions inherited from audio_tools::AudioStream
 AudioStream (AudioStream const &)=delete
 
virtual AudioBaseInfo audioInfo () override
 
virtual int availableForWrite () override
 
virtual bool begin ()
 
virtual void end ()
 
virtual void flush () override
 
 operator bool ()
 
AudioStreamoperator= (AudioStream const &)=delete
 
virtual size_t readBytes (char *buffer, size_t length)
 
virtual size_t readBytes (uint8_t *buffer, size_t length) STREAM_WRITE_OVERRIDE=0
 
virtual void setAudioInfo (AudioBaseInfo info) override
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi) override
 
virtual StreamtoStreamPointer ()
 
virtual size_t write (const uint8_t *buffer, size_t size) override=0
 
- Public Member Functions inherited from audio_tools::Stream
virtual int available ()
 
virtual int peek ()
 
virtual int read ()
 
virtual size_t readBytes (uint8_t *buffer, size_t len)
 
virtual void setTimeout (size_t t)
 
- Public Member Functions inherited from audio_tools::Print
virtual int availableForWrite ()
 
virtual void flush ()
 
virtual int print (char c, PrintCharFmt spec)
 
virtual int print (const char *msg)
 
virtual int print (int number)
 
virtual int println (const char *msg="")
 
virtual size_t write (const char *buffer, size_t size)
 
virtual size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
virtual size_t write (uint8_t ch)
 
- Public Member Functions inherited from audio_tools::AudioBaseInfoDependent
virtual AudioBaseInfo audioInfo ()=0
 
virtual void setAudioInfo (AudioBaseInfo info)=0
 
virtual bool validate (AudioBaseInfo &info)
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi)=0
 

Protected Attributes

ResampleParameterEstimator calc
 
ResampleConfig cfg
 
Resample< T > down
 
float factor
 
ResamplePrecision precision
 
Resample< T > up
 
- Protected Attributes inherited from audio_tools::AudioStream
AudioBaseInfo info
 
AudioBaseInfoDependentp_notify =nullptr
 

Additional Inherited Members

- Protected Member Functions inherited from audio_tools::AudioStream
virtual int not_supported (int out)
 

Detailed Description

template<typename T>
class audio_tools::ResampleStream< T >

Flexible Stream class which can be used to resample audio data between different sample rates.

Author
Phil Schatzmann
Template Parameters
Tdata type of audio data

Constructor & Destructor Documentation

◆ ResampleStream() [1/2]

template<typename T >
audio_tools::ResampleStream< T >::ResampleStream ( Print out,
ResamplePrecision  precision = Medium 
)
inline

Construct a new Resample Stream object which supports resampling on it's write operations.

Parameters
out
precision

◆ ResampleStream() [2/2]

template<typename T >
audio_tools::ResampleStream< T >::ResampleStream ( Stream in,
ResamplePrecision  precision = Medium 
)
inline

Construct a new Resample Stream object which supports resampling both on read and write.

Parameters
out
precision

Member Function Documentation

◆ available()

template<typename T >
int audio_tools::ResampleStream< T >::available ( )
inlineoverridevirtual

Determines the available bytes from the final source stream.

Reimplemented from audio_tools::AudioStreamX.

◆ availableForWrite()

template<typename T >
int audio_tools::ResampleStream< T >::availableForWrite ( )
inlineoverridevirtual

Determines the number of bytes which are available for write.

Reimplemented from audio_tools::AudioStream.

◆ begin()

template<typename T >
bool audio_tools::ResampleStream< T >::begin ( )
inlineoverridevirtual

Reimplemented from audio_tools::AudioStream.

◆ readBytes()

template<typename T >
size_t audio_tools::ResampleStream< T >::readBytes ( uint8_t *  src,
size_t  byte_count 
)
inlineoverridevirtual

Reads the up/downsampled bytes.

Reimplemented from audio_tools::AudioStreamX.

◆ setAudioInfo()

template<typename T >
void audio_tools::ResampleStream< T >::setAudioInfo ( AudioBaseInfo  info)
inlineoverridevirtual

Handle Change of the source sampling rate - and channels!

Reimplemented from audio_tools::AudioStream.

◆ write()

template<typename T >
size_t audio_tools::ResampleStream< T >::write ( const uint8_t *  src,
size_t  byte_count 
)
inlineoverridevirtual

Writes the data up or downsampled to the final destination.

Reimplemented from audio_tools::AudioStreamX.


The documentation for this class was generated from the following file: