arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
audio_tools::PWMAudioStreamESP32 Class Reference

Audio output to PWM pins for the ESP32. The ESP32 supports up to 16 channels. More...

#include <PWMAudioESP32.h>

Inheritance diagram for audio_tools::PWMAudioStreamESP32:
audio_tools::PWMAudioStreamBase audio_tools::AudioPrint Print audio_tools::AudioBaseInfoDependent audio_tools::AudioBaseInfoSource

Public Member Functions

virtual void end ()
 
- Public Member Functions inherited from audio_tools::PWMAudioStreamBase
virtual int availableForWrite ()
 
bool begin ()
 
bool begin (PWMConfig config)
 starts the processing using Streams
 
bool begin (uint16_t sampleRate, uint8_t channels, PWMCallbackType cb)
 
PWMConfig config ()
 
virtual PWMConfig defaultConfig ()
 
virtual void end ()
 
uint32_t framesPerSecond ()
 
virtual void pwmWrite (int channel, int value)=0
 
virtual void setAudioInfo (AudioBaseInfo info)
 updates the sample rate dynamically More...
 
uint32_t underflowsPerSecond ()
 
virtual size_t write (const uint8_t *wrt_buffer, size_t size)
 
- Public Member Functions inherited from audio_tools::AudioPrint
virtual AudioBaseInfo audioInfo () override
 
virtual int availableForWrite ()
 
virtual bool doRelease ()
 If true we need to release the related memory. More...
 
void flush ()
 
virtual void setAudioInfo (AudioBaseInfo info) override
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi) override
 
virtual size_t write (const uint8_t *buffer, size_t size) override=0
 
virtual size_t write (uint8_t ch) override
 
- Public Member Functions inherited from Print
virtual int availableForWrite ()
 
void clearWriteError ()
 
virtual void flush ()
 
int getWriteError ()
 
size_t print (char)
 
size_t print (const __FlashStringHelper *)
 
size_t print (const char[])
 
size_t print (const Printable &)
 
size_t print (const String &)
 
size_t print (double, int=2)
 
size_t print (int, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned char, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t println (char)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const char[])
 
size_t println (const Printable &)
 
size_t println (const String &s)
 
size_t println (double, int=2)
 
size_t println (int, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned char, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (void)
 
size_t write (const char *buffer, size_t size)
 
size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
virtual size_t write (uint8_t)=0
 
- 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 Member Functions

float frequency (int resolution)
 determiens the PWM frequency based on the requested resolution
 
void logPins ()
 
virtual int maxChannels ()
 
virtual int maxOutputValue ()
 provides the max value for the configured resulution More...
 
int maxUnsignedValue (int resolution)
 provides the max value for the indicated resulution
 
virtual void pwmWrite (int channel, int value)
 write a pwm value to the indicated channel. The max value depends on the resolution More...
 
virtual void setupPWM ()
 Setup LED PWM. More...
 
virtual void setupTimer ()
 Setup ESP32 timer with callback. More...
 
virtual void startTimer ()
 when we get the first write -> we activate the timer to start with the output of data More...
 
- Protected Member Functions inherited from audio_tools::PWMAudioStreamBase
virtual int maxChannels ()=0
 
virtual int maxOutputValue ()=0
 
virtual int nextValue ()
 determines the next scaled value
 
void playNextFrame ()
 
void playNextFrameCallback ()
 
void playNextFrameStream ()
 writes the next frame to the output pins
 
virtual void setupPWM ()=0
 
virtual void setupTimer ()=0
 
virtual void startTimer ()
 when we get the first write -> we activate the timer to start with the output of data More...
 
void updateStatistics ()
 
- Protected Member Functions inherited from Print
void setWriteError (int err=1)
 

Protected Attributes

Vector< PinInfopins
 
hw_timer_t * timer = nullptr
 
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED
 
- Protected Attributes inherited from audio_tools::PWMAudioStreamBase
PWMConfig audio_config
 
NBuffer< uint8_t > * buffer = nullptr
 
uint32_t frame_count = 0
 
uint32_t frames_per_second = 0
 
bool is_timer_started = false
 
uint32_t time_1_sec
 
uint32_t underflow_count = 0
 
uint32_t underflow_per_second = 0
 
PWMCallbackType user_callback = nullptr
 
- Protected Attributes inherited from audio_tools::AudioPrint
AudioBaseInfo cfg
 
AudioBaseInfoDependentp_notify =nullptr
 
uint8_t tmp [MAX_SINGLE_CHARS]
 
int tmpPos =0
 

Friends

void defaultPWMAudioOutputCallback ()
 separate method that can be defined as friend so that we can access protected information More...
 

Detailed Description

Audio output to PWM pins for the ESP32. The ESP32 supports up to 16 channels.

Author
Phil Schatzmann

Member Function Documentation

◆ end()

virtual void audio_tools::PWMAudioStreamESP32::end ( )
inlinevirtual

Reimplemented from audio_tools::PWMAudioStreamBase.

◆ maxChannels()

virtual int audio_tools::PWMAudioStreamESP32::maxChannels ( )
inlineprotectedvirtual

◆ maxOutputValue()

virtual int audio_tools::PWMAudioStreamESP32::maxOutputValue ( )
inlineprotectedvirtual

provides the max value for the configured resulution

Implements audio_tools::PWMAudioStreamBase.

◆ pwmWrite()

virtual void audio_tools::PWMAudioStreamESP32::pwmWrite ( int  channel,
int  value 
)
inlineprotectedvirtual

write a pwm value to the indicated channel. The max value depends on the resolution

Implements audio_tools::PWMAudioStreamBase.

◆ setupPWM()

virtual void audio_tools::PWMAudioStreamESP32::setupPWM ( )
inlineprotectedvirtual

Setup LED PWM.

Implements audio_tools::PWMAudioStreamBase.

◆ setupTimer()

virtual void audio_tools::PWMAudioStreamESP32::setupTimer ( )
inlineprotectedvirtual

Setup ESP32 timer with callback.

Implements audio_tools::PWMAudioStreamBase.

◆ startTimer()

virtual void audio_tools::PWMAudioStreamESP32::startTimer ( )
inlineprotectedvirtual

when we get the first write -> we activate the timer to start with the output of data

Reimplemented from audio_tools::PWMAudioStreamBase.

Friends And Related Function Documentation

◆ defaultPWMAudioOutputCallback

void defaultPWMAudioOutputCallback ( )
friend

separate method that can be defined as friend so that we can access protected information

timer callback: write the next frame to the pins


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