#include <AsyncAudioIO.h>
#include <math.h> #include <iostream> #include <AsyncCppApplication.h> #include <AsyncAudioIO.h> using namespace std; using namespace Async; class MyClass : public SigC::Object { public: MyClass(void) { audio_io = new AudioIO("/dev/dsp"); audio_io->open(AudioIO::MODE_RDWR); audio_io->audioRead.connect(slot(this, &MyClass::onAudioRead)); /* Or just coonect the AudioIO object to itself... */ //audio_io->audioRead.connect(slot(audio_io, &AudioIO::write)); short samples[8000]; for (int i=0; i<8000; ++i) // Put a sine wave into the buffer { samples[i] = static_cast<short int>(10000 * sin(2*M_PI*440*i/8000)); } int samples_written = audio_io->write(samples, 8000); cout << "Wrote " << samples_written << " samples...\n"; } ~MyClass(void) { delete audio_io; } private: AudioIO *audio_io; int onAudioRead(short *samples, int count) { //cout << count << " samples read...\n"; return audio_io->write(samples, count); } }; int main(int argc, char **argv) { CppApplication app; MyClass my_class; app.exec(); }
Definition at line 130 of file AsyncAudioIO.h.
|
|
The different modes to open a device in.
Definition at line 136 of file AsyncAudioIO.h. |
|
|
Default constructor.
|
|
|
Destructor.
|
|
|
|
|
|
Close the adio device.
|
|
|
|
|
|
Definition at line 218 of file AsyncAudioIO.h. |
|
|
Check if the audio device is capable of full duplex operation.
|
|
|
Definition at line 224 of file AsyncAudioIO.h. |
|
|
Open the audio device in the specified mode.
|
|
|
Find out how many samples there are in the output buffer.
|
|
||||||||||||
|
Write samples to the audio device.
|
|
|
Definition at line 284 of file AsyncAudioIO.h. |
|
|
This signal is emitted when all samples in the buffer has been flushed. When an application is done writing samples to the audio device it should call the flush-method. When all samples has been flushed from the audio device, this signal is emitted. Definition at line 249 of file AsyncAudioIO.h. |
|
|
A signal that is emitted when a block of audio has been received from the audio device.
Definition at line 232 of file AsyncAudioIO.h. |
|
|
A signal that is emitted when the write buffer is full.
Definition at line 239 of file AsyncAudioIO.h. |
1.4.4