Async 1.8.0
AsyncAudioFsf_demo.cpp

An example of how to use the Async::AudioFsf class

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <AsyncAudioIO.h>
#include <AsyncAudioFsf.h>
// Read samples from the soundcard, filter it and then output it to the same
// soundcard
int main(int argc, const char **argv)
{
Async::AudioIO audio_io("alsa:plughw:0", 0);
Async::AudioSource *prev_src = &audio_io;
// A bandpass filter centered at 1000Hz with an approximate passband
// bandwidth of 400Hz and a stopband attenuation of about 40dB.
const size_t N = 128; // N/fs=125Hz binwidth
float coeff[N/2+1];
std::memset(coeff, 0, sizeof(coeff));
coeff[6] = 0.39811024; // 750Hz
coeff[7] = 1.0; // 875Hz
coeff[8] = 1.0; // 1000Hz
coeff[9] = 1.0; // 1125Hz
coeff[10] = 0.39811024; // 1250Hz
Async::AudioFsf fsf(N, coeff);
prev_src->registerSink(&fsf, true);
prev_src = &fsf;
prev_src->registerSink(&audio_io);
prev_src = 0;
{
std::cout << "*** ERROR: Could not open audio device" << std::endl;
exit(1);
}
app.exec();
return 0;
}
A Frequency Sampling Filter implementation.
Contains a class for handling audio input/output to an audio device.
The core class for writing asyncronous cpp applications.
A Frequency Sampling Filter implementation.
A class for handling audio input/output to an audio device.
bool open(Mode mode)
Open the audio device in the specified mode.
@ MODE_RDWR
Both read and write.
static void setSampleRate(int rate)
Set the sample rate used when doing future opens.
The base class for an audio source.
bool registerSink(AudioSink *sink, bool managed=false)
Register an audio sink to provide samples to.
An application class for writing non GUI applications.
void exec(void)
Execute the application main loop.