27#ifndef ASYNC_AUDIO_GENERATOR_INCLUDED
28#define ASYNC_AUDIO_GENERATOR_INCLUDED
133 : pos(0), fq(0.0), level(0.0), sample_rate(INTERNAL_SAMPLE_RATE),
134 waveform(wf), power(0.0)
174 power = pow(10.0, pwr_db / 10.0f) / 2;
212 static const int BLOCK_SIZE = 128;
233 level = sqrt(2 * power);
247 void writeSamples(
void)
251 float buf[BLOCK_SIZE];
252 for (
int i=0; i<BLOCK_SIZE; ++i)
257 buf[i] = level * sin(2 * M_PI * fq * (pos+i) / sample_rate);
260 buf[i] = level * (sin(2 * M_PI * fq * (pos+i) / sample_rate)
270 }
while (written != 0);
This file contains the base class for an audio source.
A class for generating periodic audio signals.
void enable(bool enable)
Enable or disable the generator.
void allSamplesFlushed(void)
The registered sink has flushed all samples.
void setPower(float pwr_db)
Set the power of the generated signal.
Waveform
The type of waveform to generate.
void resumeOutput(void)
Resume audio output to the sink.
void setFq(double tone_fq)
Set the audio frequency.
~AudioGenerator(void)
Destructor.
void setWaveform(Waveform wf)
Set which waveform to use.
AudioGenerator(Waveform wf=SIN)
Contructor.
The base class for an audio source.
int sinkWriteSamples(const float *samples, int len)
Namespace for the asynchronous programming classes.