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);
~AudioGenerator(void)
Destructor.
void allSamplesFlushed(void)
The registered sink has flushed all samples.
A class for generating periodic audio signals.
This file contains the base class for an audio source.
AudioGenerator(Waveform wf=SIN)
Contructor.
void setPower(float pwr_db)
Set the power of the generated signal.
void setWaveform(Waveform wf)
Set which waveform to use.
void setFq(double tone_fq)
Set the audio frequency.
void enable(bool enable)
Enable or disable the generator.
int sinkWriteSamples(const float *samples, int len)
Namespace for the asynchronous programming classes.
Waveform
The type of waveform to generate.
The base class for an audio source.
void resumeOutput(void)
Resume audio output to the sink.