arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SineWaveGenerator< T > Class Template Reference

Generates a Sound with the help of sin() function. If you plan to change the amplitude or frequency (incrementally), I suggest to use SineFromTable instead. More...

#include <SoundGenerator.h>

Inheritance diagram for SineWaveGenerator< T >:
SoundGenerator< T > FastSineGenerator< T > SquareWaveGenerator< T >

Public Member Functions

 SineWaveGenerator (float amplitude=0.9f *NumberConverter::maxValueT< T >(), float phase=0.0f)
 
virtual AudioInfo audioInfo ()
 Provides the AudioInfo.
 
bool begin () override
 
bool begin (AudioInfo info) override
 
bool begin (AudioInfo info, float frequency)
 
bool begin (int channels, int sample_rate, float frequency)
 
virtual AudioInfo defaultConfig () override
 Provides the default configuration.
 
virtual void end ()
 ends the processing
 
virtual bool isActive ()
 
virtual size_t readBytes (uint8_t *buffer, size_t lengthBytes)
 Provides the data as byte array with the requested number of channels.
 
virtual T readSample () override
 Provides a single sample.
 
void setAmplitude (float amp)
 
virtual void setAudioInfo (AudioInfo info) override
 Defines/updates the AudioInfo.
 
void setFrequency (float frequency) override
 Defines the frequency - after the processing has been started.
 

Protected Member Functions

void logStatus ()
 
size_t readBytesFrames (uint8_t *buffer, size_t lengthBytes, int frames, int channels)
 
size_t readBytesFromBuffer (uint8_t *buffer, size_t lengthBytes, int frame_size, int channels)
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
const float double_Pi = PI * 2.0f
 
AudioInfo info
 
float m_amplitude = 1.0f
 
float m_cycles = 0.0f
 
float m_deltaTime = 0.0f
 
volatile float m_frequency = 0.0f
 
float m_phase = 0.0f
 
RingBuffer< uint8_t > ring_buffer {0}
 

Detailed Description

template<class T>
class audio_tools::SineWaveGenerator< T >

Generates a Sound with the help of sin() function. If you plan to change the amplitude or frequency (incrementally), I suggest to use SineFromTable instead.

Author
Phil Schatzmann

Member Function Documentation

◆ isActive()

virtual bool isActive ( )
inlinevirtualinherited

Checks if the begin method has been called - after end() isActive returns false


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