arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
audio_tools::SineFromTable< T > Class Template Reference

A sine generator based on a table. The table is created based using degress where one full wave is 360 degrees. More...

#include <SoundGenerator.h>

Inheritance diagram for audio_tools::SineFromTable< T >:
audio_tools::SoundGenerator< T >

Public Member Functions

 SineFromTable (float amplitude=32767.0)
 
bool begin ()
 
bool begin (AudioBaseInfo info, float frequency)
 
bool begin (int channels, int sample_rate, uint16_t frequency=0)
 
readSample ()
 Provides a single sample. More...
 
void setAmplitude (float amplitude)
 Defines the new amplitude (volume)
 
void setFrequency (float freq)
 
void setMaxAmplitudeStep (float step)
 To avoid pops we do not allow to big amplitude changes at once and spread them over time.
 
- 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

interpolate (float angle)
 
map (T x, T in_min, T in_max, T out_min, T out_max)
 
void updateAmplitudeInSteps ()
 

Protected Attributes

float amplitude
 
float amplitude_to_be
 
float angle = 0
 
float base_frequency = 1.0
 
bool is_first = true
 
float max_amplitude_step = 50
 
float step = 1.0
 
float step_new = 1.0
 
const float values [181] = {0, 0.0174524, 0.0348995, 0.052336, 0.0697565, 0.0871557, 0.104528, 0.121869, 0.139173, 0.156434, 0.173648, 0.190809, 0.207912, 0.224951, 0.241922, 0.258819, 0.275637, 0.292372, 0.309017, 0.325568, 0.34202, 0.358368, 0.374607, 0.390731, 0.406737, 0.422618, 0.438371, 0.45399, 0.469472, 0.48481, 0.5, 0.515038, 0.529919, 0.544639, 0.559193, 0.573576, 0.587785, 0.601815, 0.615661, 0.62932, 0.642788, 0.656059, 0.669131, 0.681998, 0.694658, 0.707107, 0.71934, 0.731354, 0.743145, 0.75471, 0.766044, 0.777146, 0.788011, 0.798636, 0.809017, 0.819152, 0.829038, 0.838671, 0.848048, 0.857167, 0.866025, 0.87462, 0.882948, 0.891007, 0.898794, 0.906308, 0.913545, 0.920505, 0.927184, 0.93358, 0.939693, 0.945519, 0.951057, 0.956305, 0.961262, 0.965926, 0.970296, 0.97437, 0.978148, 0.981627, 0.984808, 0.987688, 0.990268, 0.992546, 0.994522, 0.996195, 0.997564, 0.99863, 0.999391, 0.999848, 1, 0.999848, 0.999391, 0.99863, 0.997564, 0.996195, 0.994522, 0.992546, 0.990268, 0.987688, 0.984808, 0.981627, 0.978148, 0.97437, 0.970296, 0.965926, 0.961262, 0.956305, 0.951057, 0.945519, 0.939693, 0.93358, 0.927184, 0.920505, 0.913545, 0.906308, 0.898794, 0.891007, 0.882948, 0.87462, 0.866025, 0.857167, 0.848048, 0.838671, 0.829038, 0.819152, 0.809017, 0.798636, 0.788011, 0.777146, 0.766044, 0.75471, 0.743145, 0.731354, 0.71934, 0.707107, 0.694658, 0.681998, 0.669131, 0.656059, 0.642788, 0.62932, 0.615661, 0.601815, 0.587785, 0.573576, 0.559193, 0.544639, 0.529919, 0.515038, 0.5, 0.48481, 0.469472, 0.45399, 0.438371, 0.422618, 0.406737, 0.390731, 0.374607, 0.358368, 0.34202, 0.325568, 0.309017, 0.292372, 0.275637, 0.258819, 0.241922, 0.224951, 0.207912, 0.190809, 0.173648, 0.156434, 0.139173, 0.121869, 0.104528, 0.0871557, 0.0697565, 0.052336, 0.0348995, 0.0174524, 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::SineFromTable< T >

A sine generator based on a table. The table is created based using degress where one full wave is 360 degrees.

Author
Phil Schatzmann

Member Function Documentation

◆ begin()

template<class T >
bool audio_tools::SineFromTable< T >::begin ( )
inlinevirtual

Reimplemented from audio_tools::SoundGenerator< T >.

◆ readSample()

template<class T >
T audio_tools::SineFromTable< T >::readSample ( )
inlinevirtual

Provides a single sample.

Implements audio_tools::SoundGenerator< T >.


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