Set sampling rate, output channels, etc.
rtsetparams(sampling_rate, num_channels [, buffer_size ])
Set the sampling rate, number of output channels, and (optionally) the buffer size for an RTcmix session.
You must call rtsetparams before calls to rtinput, rtoutput, or instruments. You can only call rtsetparams once in a script.
sampling_rate
The sampling rate for all synthesis and processing. Any input sound files must have this rate, and the output sound file will have this rate. Similarly, the input and output devices (audio hardware) will have this rate.
num_channels
The number of output channels. This affects any file opened for writing by rtoutput, as well as the audio output device.
buffer_size
The number of sample frames in each buffer. RTcmix instruments process sound in buffer-sized chunks. The buffer size determines the latency for real-time applications, such as sending sound from a microphone into a reverb instrument. For situations like that, you’ll want to reduce the buffer_size to minimize the delay between the input signal and its processed output. You can have a buffer_size as small as 64 or even 32, depending on the audio driver and machine load.
The default buffer_size is 4096 sample frames. At a sampling rate of 44100 kHz, this gives a latency of nearly 0.1 seconds, which is unsuitable for real-time work.
To have an audio device that handles input and output at the same, you must turn on the record option before calling rtsetparams. Do this with set_option (by saying set_option(“record = 1”)).
If you want to write a sound file that has more channels than your audio device permits, turn off the audio device with set_option before calling rtsetparams (by saying set_option(“audio = off”)).
rtsetparams(44100, 2)
sets up the session for 44100 sampling rate and two output channels.
rtsetparams(44100, 4, 128)
sets up the session for 44100 sampling rate, four output channels, and a buffer size of 128 sample frames.
set_option("record=TRUE")
rtsetparams(44100, 2, 64)
rtinput("AUDIO")
sets up the session for real-time processing of a signal reaching RTcmix from the audio device. You must turn on full duplex operation to tell the audio device to handle input and output simultaneously.