Open a new sound file for writing.
rtoutput(“file_name” [, “header_type” ] [, “data_format” ])
Parameters inside the [brackets] are optional.
Call rtoutput to open a new sound file for subsequent writing by real-time instruments.
After rtoutput creates a sound file, it prints information about the file, such as the header type and sampling rate (unless the print_off scorefile command has been issued).
“file_name”
A text string with the name of a sound file, in double-quotes. If the file already exists, the script will terminate with an error, unless you’ve turned on file clobbering with set_option (by saying set_option(“clobber = on”)). If you name the file with a recognized suffix, that suffix will determine the header type, unless overridden by a “header_type” string. Recognized suffixes: “.wav’’, “.aif’’, “.aiff’’, “.aifc’’, “.snd’’ (NeXT/Sun), “.au’’ (NeXT/Sun), “.sf’’ (IRCAM), and “.raw’’.
“header_type”
The type of header to use for the sound file, as a double-quoted string. Note that if you name the file with a recognized suffix (see above), you don’t need to specify a header type in this way.
AIFF is the default if no header type is given.
“data_format”
The type of data format to use for the sound file, as a double-quoted string.
NOTE: The sampling rate and number of channels are specified in a call to rtsetparams at the beginning of the script.
“short” is the default if no data format is given.
If you don’t want RTcmix to play while you’re writing a file, use set_option to turn off playing before you invoke rtsetparams, by saying set_option(“audio = off”).
The case of the header_type and data_format arguments is not significant, nor is their order.
All formats are big-endian, except for “wav,” which is always little-endian, and “raw,” which has host byte order.
If you ask for “aiff” and “float” (or “normfloat”), you’ll get “aifc” format instead, because AIFF doesn’t support floating-point files.
Although most soundfile programs now deal with nearly all soundfile types, few of them expect floating-point files to use the unnormalized range of values that RTcmix uses by default (-32768.0–32767.0 and beyond). When writing floating-point files that you want to open in other programs, use the “normfloat” format, where the values are normalized to fit within the -1.0–1.0.
If you want to use them in MiXViews editor, choose the “next” header type. Many programs don’t read AIFC files, maybe because they assume these are always compressed.
rtsetparams(22050, 2)
rtoutput("mysound")
writes a stereo, 16-bit linear AIFF file with 22050 sampling rate.
rtsetparams(44100, 1)
set_option("audio = off", "clobber = on")
rtoutput("myothersound", "wav", "float")
writes a mono, 32-bit floating-point WAV file with 44100 sampling rate. RTcmix will write over any existing file with the same name, and will not play audio while writing.