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