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

Software Implementation of a Simple DAC - We quantize a digital int16_t sample my mapping the value to the range of 0b0 to info.output_bits number of 1, where the intensity is represented by the number of ones. This is very similar to PWM! More...

#include <AudioDAC.h>

Inheritance diagram for SimpleDAC:
OversamplingDAC AudioOutput Print AudioInfoSupport AudioInfoSource

Public Member Functions

virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
 
virtual int availableForWrite () override
 
virtual bool begin ()
 
virtual bool begin (AudioInfo info)
 
bool begin (DACInfo cfg) override
 starts the Delta Sigma DAC
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
virtual DACInfo defaultConfig ()
 
virtual void end ()
 Stops the output.
 
virtual void flush ()
 
bool isBlocking ()
 
virtual bool isDeletable ()
 If true we need to release the related memory in the destructor.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
virtual uint32_t outputFrameCount ()
 To be used for testing, we just count the number of frames that were sent to output.
 
uint32_t outputRate () override
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
 
void setBlocking (bool blocking)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual void startTimer ()
 
TimerAlarmRepeatingtimer ()
 
virtual size_t write (const uint8_t *data, size_t len)
 Writes the audio data to the output buffer.
 
virtual size_t write (uint8_t c)
 Writes a single byte (of audio data) to the output buffer.
 
virtual void writeSilence (size_t len)
 

Protected Member Functions

size_t availableFramesToWrite () override
 determines how many frames we can write to the buffer
 
void notifyAudioChange (AudioInfo info)
 
void quantize (int16_t audioValue, int left_right_idx) override
 updates the buffer with analog value (represented by number of 1)
 
virtual void reset ()
 Releases the memory.
 
void writePins ()
 

Protected Attributes

int _timeout = 10
 
bool active
 
uint8_t * active_count =nullptr
 
int bit_counter = 0
 
RingBuffer< uint8_t > buffer = RingBuffer<uint8_t>(DEFAULT_BUFFER_SIZE)
 
uint8_t bytes_per_sample = 2
 
AudioInfo cfg
 
int32_t * cummulated_error = nullptr
 
int current_bit = -1
 
int32_t * current_values = nullptr
 
const int fixedPosValue =0x007fff00
 
DACInfo info
 
bool is_active = false
 
bool is_blocking = true
 
bool is_notify_active = true
 
int32_t * last_values = nullptr
 
Vector< AudioInfoSupport * > notify_vector
 
DACOut out
 
TimerAlarmRepeating timer_object
 
SingleBuffer< uint8_t > tmp {MAX_SINGLE_CHARS}
 
int tmpPos = 0
 
uint8_t write_buffer [4]
 
int write_buffer_pos = 0
 

Friends

void dacTimerCallback (void *ptr)
 

Detailed Description

Software Implementation of a Simple DAC - We quantize a digital int16_t sample my mapping the value to the range of 0b0 to info.output_bits number of 1, where the intensity is represented by the number of ones. This is very similar to PWM!

Author
Phil Schatzmann

Member Function Documentation

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes n 0 values (= silence)

Parameters
len

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