Audio Output

Because Csound is all about generating audio signals, perhaps it’s not surprising that several methods are available for getting audio out of (and into) Csound while it’s running.

If you’re using CsoundQt, you will normally produce real-time output to your system’s audio driver by clicking the Run button. If you’re running Csound from the command line, you’ll need to specify an output using the -odac command-line argument. (See the section on command-line arguments in Chapter 2 for more details.) Likewise, output can be directed to a disk file using CsoundQt’s Render button or by specifying an output filename from the command line.

Normally, these outputs will tap directly into the out (or, if nchnls=2, into the outs) opcode, which is used throughout this book. These are not the only options, however.

Audio input from a previously recorded file was covered earlier in this chapter, in the “Sample Playback” section. Real-time audio input is discussed in Chapter 10, “Using Csound with MIDI, OSC, Pd, Python, and Live Audio.”

out and outs

Let’s suppose your score has five instrument instances (which could be the same instrument or different ones) running at the same time. Each instrument generates an ongoing audio signal and then sends it to the output via the outs opcode. Without any hand-holding on the user’s part, Csound transparently mixes all of these signals to produce a single output audio stream.

If your orchestra header specifies nchnls=1, your orchestra will be monaural, so use out with a single argument:


  out asig

If nchnls=2, use outs:


  outs asigL, asigR

Needless to say, the left and right signals to outs need not be different; if they’re the same, you’ll get a monaural output.

In the event that you have an audio system with more than two channels, you’ll need to use outc, which accepts an arbitrary number of audio signals. With two audio variables as input arguments, outc is exactly the same as outs.

fout

In some circumstances, such as producing submixes as separate audio files, standard rendering won’t do the job. Instead of, or in addition to, outs, you can use fout. The only thing that’s at all tricky about fout is specifying the format in which you want the file saved. You can refer to the manual for details, but briefly, an argument of 14 will give you a standard 16-bit .WAV file, while 24 will give you a standard 16-bit .AIFF file.

If you’re using fout in a mixer/output instrument, in order to collect the signals from several instruments before writing the result to disk, you need to be aware that, unlike the outs family opcodes, fout does not zero the audio variables after using them. This can be done manually or using the clear opcode.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.181