locsend — Distributes the audio signals of a previous locsig opcode.
locsend depends upon the existence of a previously defined locsig. The number of output signals must match the number in the previous locsig. The output signals from locsend are derived from the values given for distance and reverb in the locsig and are ready to be sent to local or global reverb units (see example below). The reverb amount and the balance between the 2 or 4 channels are calculated in the same way as described in the Dodge book (an essential text!).
asig some audio signal kdegree line 0, p3, 360 kdistance line 1, p3, 10 a1, a2, a3, a4 locsig asig, kdegree, kdistance, .1 ar1, ar2, ar3, ar4 locsend ga1 = ga1+ar1 ga2 = ga2+ar2 ga3 = ga3+ar3 ga4 = ga4+ar4 outq a1, a2, a3, a4 endin instr 99 ; reverb instrument a1 reverb2 ga1, 2.5, .5 a2 reverb2 ga2, 2.5, .5 a3 reverb2 ga3, 2.5, .5 a4 reverb2 ga4, 2.5, .5 outq a1, a2, a3, a4 ga1=0 ga2=0 ga3=0 ga4=0
In the above example, the signal, asig, is sent around a complete circle once during the duration of a note while at the same time it becomes more and more “distant” from the listeners' location. locsig sends the appropriate amount of the signal internally to locsend. The outputs of the locsend are added to global accumulators in a common Csound style and the global signals are used as inputs to the reverb units in a separate instrument. For an example, see locsig.
locsig is useful for quad and stereo panning as well as fixed placed of sounds anywhere between two loudspeakers. Below is an example of the fixed placement of sounds in a stereo field. It uses the file locsend_stereo.csd.
Example 524. Example of the locsend opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform -odac ;;;realtime audio out ;-iadc ;;;uncomment -iadc if realtime audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o locsend_stereo.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ga1 init 0 ga2 init 0 instr 1 krevsend = p4 aout diskin2 "drumsMlp.wav", 1, 0, 1 kdegree line 0, p3, 180 ;left to right kdistance line 1, p3, 30 a1, a2 locsig aout, kdegree, kdistance, p4 ar1, ar2 locsend ga1 = ga1+ar1 ga2 = ga2+ar2 outs a1, a2 endin instr 99 ; reverb instrument a1 reverb2 ga1, 2.5, .5 a2 reverb2 ga2, 2.5, .5 outs a1, a2 ga1 = 0 ga2 = 0 endin </CsInstruments> <CsScore> ; sine wave. f 1 0 16384 10 1 i 1 0 4 .1 ;with reverb i 1 + 4 0 ;no reverb i99 0 7 e </CsScore> </CsoundSynthesizer>
A few notes:
;place the sound in the left speaker and near: i1 0 1 0 1 ;place the sound in the right speaker and far: i1 1 1 90 25 ;place the sound equally between left and right and in the middle ground distance: i1 2 1 45 12 e
The next example shows a simple intuitive use of the distance value to simulate Doppler shift. The same value is used to scale the frequency as is used as the distance input to locsig.
kdistance line 1, p3, 10 kfreq = (ifreq * 340) / (340 + kdistance) asig oscili iamp, kfreq, 1 kdegree line 0, p3, 360 a1, a2, a3, a4 locsig asig, kdegree, kdistance, .1 ar1, ar2, ar3, ar4 locsend