1.6 KiB
1.6 KiB
Write stream to Audio output
@tableofcontents
Objectifs:
- Understand write audio stream
The writing work nearly like the read turoral. Then we will just see what has change.
File configuration:
@snippet write.cpp audio_river_sample_write_config_file
Create your write interface:
Generic code: @snippet write.cpp audio_river_sample_create_write_interface
Here we create an interface with:
- The frequency of 48000 Hz.
- The default Low level definition channel
- A data interface of 16 bits samples coded in [-32768..32767]
- Select input interaface name "speaker"
set data callback:
The best way to get data is to instanciate a simple callback. The callback is called when sample are needed and you have the nbChunk/frequency to generate the data, otherwise you can generate error in data stream.
@snippet write.cpp audio_river_sample_set_callback
Callback inplementation:
Simply declare your function and do what you want inside.
@snippet write.cpp audio_river_sample_callback_implement
Full Sample:
@snippet write.cpp audio_river_sample_write_all