Skip to content
Walt K edited this page Jan 23, 2021 · 4 revisions

This function starts the real-time audio subsystem. C-side real-time hooks must first be registered with the rtaudio_register function, see example below. The flag is passed to the initialization hook, and volume is used to initialize the sound output volume.

Parameter Description
samplerate Integer sampling rate (e.g. 8000 Hz) On Android, only 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000, are valid
volume normalized output volume (0.0-1.0)

Example

Real-time audio example (straight echo of input to output):

(c-declare  #<<end-of-c-declare
void rtaudio_register(void (*)(int), void (*)(float), void (*)(float*,float*),void (*)(void));
float buffer;
void my_realtime_init(int flag) { buffer=0; }  
void my_realtime_input(float v) { buffer=v; }  
void my_realtime_output(float *v1,float *v2) { *v1=*v2=buffer; } 
void my_realtime_close() { buffer=0; }
end-of-c-declare
)
..
(c-initialize "rtaudio_register(my_realtime_init,my_realtime_input,my_realtime_output,my_realtime_close);")
..
(rtaudio-start 8000 1.0)
..
Clone this wiki locally