arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
I2SCodecStream Class Reference

I2S Stream which also sets up a codec chip and i2s. More...

#include <I2SCodecStream.h>

Inheritance diagram for I2SCodecStream:
AudioStream Stream AudioInfoSupport AudioInfoSource Print AudioBoardStream

Public Member Functions

 I2SCodecStream ()=default
 Default Constructor (w/o codec)
 
 I2SCodecStream (AudioBoard &board)
 Default constructor: for available AudioBoard values check audioboard variables in https://pschatzmann.github.io/arduino-audio-driver/html/group__audio__driver.html Further information can be found in https://github.com/pschatzmann/arduino-audio-driver/wiki.
 
 I2SCodecStream (AudioBoard *board)
 Provide board via pointer.
 
virtual AudioInfo audioInfo () override
 
virtual int available () override
 Provides the available audio data.
 
virtual int availableForWrite () override
 Provides the available audio data.
 
bool begin ()
 
virtual bool begin (I2SCodecConfig cfg)
 Starts the I2S interface.
 
AudioBoard & board ()
 Provides the board.
 
I2SCodecConfig defaultConfig (RxTxMode mode=TX_MODE)
 Provides the default configuration.
 
I2SDriverdriver ()
 Provides the i2s driver.
 
void end ()
 Stops the I2S interface.
 
virtual void flush () override
 
GpioPin getKey (int pos)
 Provides the gpio for the indicated key pos.
 
GpioPin getPinID (PinFunction function)
 Provides the gpio for the indicated function.
 
GpioPin getPinID (PinFunction function, int pos)
 Provides the gpio for the indicated function.
 
DriverPins & getPins ()
 Provides access to the pin information.
 
float getVolume ()
 Provides the actual volume (0.0 - 1.0)
 
bool hasBoard ()
 checks if a board has been defined
 
 operator bool ()
 
virtual size_t readBytes (uint8_t *data, size_t length) override
 Reads the audio data.
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual void setAudioInfo (AudioInfo info)
 updates the sample rate dynamically
 
void setBoard (AudioBoard &board)
 (re)defines the board
 
void setBoard (AudioBoard *board)
 (re)defines the board
 
bool setMute (bool mute)
 Mute / unmote.
 
virtual void setNotifyAudioChange (AudioInfoSupport &bi) override
 
bool setPAPower (bool active)
 Sets the output of the PA Power Pin.
 
bool setVolume (float vol)
 sets the volume (range 0.0 - 1.0)
 
virtual bool validate (AudioInfo &info)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Writes the audio data to I2S.
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

bool beginCodec (I2SCodecConfig info)
 
virtual int not_supported (int out, const char *msg="")
 
void refillReadBuffer ()
 
void setupI2SPins ()
 We use the board pins if they are available.
 
sample_bits_t toCodecBits (int bits)
 
i2s_format_t toFormat (I2SFormat fmt)
 
samplerate_t toRate (int rate)
 

Protected Attributes

int _timeout = 10
 
I2SCodecConfig cfg
 
CodecConfig codec_cfg
 
I2SStream i2s
 
AudioInfo info
 
bool is_active = false
 
AudioBoard * p_board = nullptr
 
AudioInfoSupportp_notify =nullptr
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
float volume = -1.0f
 

Detailed Description

I2S Stream which also sets up a codec chip and i2s.

Author
Phil Schatzmann

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