arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
audio_tools::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 audio_tools::SineWaveGenerator< T >:
audio_tools::SoundGenerator< T > audio_tools::FastSineGenerator< T > audio_tools::SquareWaveGenerator< T >

Public Member Functions

 SineWaveGenerator (float amplitude=32767.0, float phase=0.0)
 
bool begin () override
 
bool begin (AudioBaseInfo info) override
 
bool begin (AudioBaseInfo info, uint16_t frequency)
 
bool begin (int channels, int sample_rate, uint16_t frequency=0)
 
virtual AudioBaseInfo defaultConfig () override
 
virtual T readSample () override
 Provides a single sample. More...
 
virtual void setAudioInfo (AudioBaseInfo info) override
 
void setFrequency (uint16_t frequency) override
 Defines the frequency - after the processing has been started. More...
 
- Public Member Functions inherited from audio_tools::SoundGenerator< T >
virtual AudioBaseInfo audioInfo ()
 
virtual bool begin ()
 
virtual bool begin (AudioBaseInfo info)
 
virtual AudioBaseInfo defaultConfig ()
 
virtual void end ()
 ends the processing
 
virtual bool isActive ()
 Checks if the begin method has been called - after end() isActive returns false.
 
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 ()=0
 Provides a single sample. More...
 
virtual size_t readSamples (T *data, size_t sampleCount=512)
 Provides the samples into simple array - which represents 1 channel.
 
virtual size_t readSamples (T src[][2], size_t frameCount)
 Provides the samples into a 2 channel array.
 
virtual void setAudioInfo (AudioBaseInfo info)
 
virtual void setFrequency (uint16_t frequency)
 

Protected Member Functions

void logStatus ()
 

Protected Attributes

float double_Pi = PI * 2.0
 
float m_amplitude = 1.0
 
float m_cycles = 0.0
 
float m_deltaTime = 0.0
 
volatile float m_frequency = 0
 
float m_phase = 0.0
 
- Protected Attributes inherited from audio_tools::SoundGenerator< T >
bool active = false
 
bool activeWarningIssued = false
 
AudioBaseInfo info
 
int output_channels = 1
 

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

◆ begin() [1/2]

template<class T >
bool audio_tools::SineWaveGenerator< T >::begin ( )
inlineoverridevirtual

Reimplemented from audio_tools::SoundGenerator< T >.

◆ begin() [2/2]

template<class T >
bool audio_tools::SineWaveGenerator< T >::begin ( AudioBaseInfo  info)
inlineoverridevirtual

Reimplemented from audio_tools::SoundGenerator< T >.

◆ defaultConfig()

template<class T >
virtual AudioBaseInfo audio_tools::SineWaveGenerator< T >::defaultConfig ( )
inlineoverridevirtual

Reimplemented from audio_tools::SoundGenerator< T >.

◆ readSample()

template<class T >
virtual T audio_tools::SineWaveGenerator< T >::readSample ( )
inlineoverridevirtual

◆ setAudioInfo()

template<class T >
virtual void audio_tools::SineWaveGenerator< T >::setAudioInfo ( AudioBaseInfo  info)
inlineoverridevirtual

Reimplemented from audio_tools::SoundGenerator< T >.

◆ setFrequency()

template<class T >
void audio_tools::SineWaveGenerator< T >::setFrequency ( uint16_t  frequency)
inlineoverridevirtual

Defines the frequency - after the processing has been started.

Reimplemented from audio_tools::SoundGenerator< T >.


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