Microtonal, just intonation, electronic music software Microtonal, just intonation, electronic music software
Login   |  Site Map

the pitch bend archive

2005-10-03 at 17:00

Csound Opcodes

Csound is the leading open-source sound/music-synthesis software. Csound is a very powerful tool with a complement of over 1000 available, pre-programmed opcodes. This article is an easy-to-use online reference for those Csound opcodes. It'll start out with only a few entries, but will grow with time in a complete reference of the Csound opcodes. This table is meant to be a quick-reference summary rather than an in-depth guide. For in-depth information, just refer to the Csound Canonical Reference Manual. Please send all requests, entries, and corrections to The Pitch Bend. For those who are new to Csound, please consult our Introduction to Csound Opcode Usage


areson, aresonk, balance, buzz, delay, delay1, delayr, delayw, expon, foscil, foscili, grain, linen, linseg, loscil, loscil3, oscil, oscil1, oscil1i, oscil3, oscili, oscilikt, osciliktp, oscilikts, osciln, oscils, oscilx, out, outs, outq, outh, outo, outx, out32, phasor, phasorbnk, pluck, print, printk, printk2, printks, prints, reson, resonk, resonr, resonx, resonxk, resony, resonz

MIDI-Related Opcodes: Currently, this quick-reference's focus is on the Csound core components. Hence, it doesn't provide entries for those opcodes that are used for interfacing with and controlling MIDI devices: ampmidi, chanctrl, cpsmidi, cpsmidib, cpstmid, ctrl14, ctrl21, ctrl7, ctrlinit, initc14, initc21, init7, linenr, linsegr, massign, mclock, mdelay, midic14, midic21, midic7, midichannelaftertouch, midichn, midicontrolchange, midictrl, mididefault, midiin, midinoteoff, midinoteoncps, midinoteonkey, midinoteonct, midinoteonpch, midion, midion2, midiout, midipitchbend, midipolyaftertouch, midiprogramchange, miditempo, moscil, mrtmsg, noteoff, noteon, noteondur, noteondur2, notnum, nrpn, octmidi, octmidib, outiat, outic, outic14, outipat, outipb, outipc, outkat, outkc, outkc14, outkpat, outkpb, outkpc, pchmidi, pchmidib, pgmassign, s16b14, s32b14, slider16, slider16f, slider32, slider32f, slider64, slider64f, slider8, veloc, fluidCCi, fluidCCk, fluidControl, vstmidiout, vstnote


Introduction to Csound Opcode Usage

Each Csound opcode expects to receive as its arguments a certain list of parameters in a certain order. A Csound .orc file reads these parameters either directly from assignment statements within the .orc file itself if they do not change, or from the note-event statements in the .sco file if they do change. These parameters are known internally to Csound as "p1, "p2", "p3", etc., the numbers corresponding with the order in which the parameters appear from left-to-right in the note-event statements of the .sco file. The first three parameters are standardized with the following meanings:

Following these, p4 is typically used for the amplitude of the note-event, and p5 is typically used for the frequency. After that, each parameter is specific to the opcode being referenced. Parameters may be assigned variable names so that the Csound code is more meaningful to the human reader.

Note that the parameters are given here as variables (corresponding exactly to the descriptions in the Csound Canonical Reference Manual), whose names are intended to give a concise description of the purpose of that parameter, and whose first letter signifies the rate at which that parameter will be computed, thus:

Examples of parameter names and their meanings:

Note that the variable name can be any string of characters (letters or numbers), as long as the first character is the correct letter for the desired computation rate. Using meaningful variable names makes the Csound code easier to understand.


areson

A notch filter whose transfer functions are the complements of the reson opcode. areson is a filter whose transfer functions is the complement of reson. Thus areson is a notch filter whose transfer functions represents the “filtered out” aspects of their complements. However, power scaling is not normalized in areson but remains the true complement of the corresponding unit. Thus an audio signal, filtered by parallel matching reson and areson units, would under addition simply reconstruct the original spectrum.

usage

  • ares areson asig, kcf, kbw [, iscl] [, iskip]

parameters

  • asig -- The input audio signal.
  • kcf -- The center frequency of the filter, or frequency position of the peak response.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

aresonk

A notch filter whose transfer functions are the complements of the resonk opcode. aresonk is a filter whose transfer functions is the complement of resonk. Thus aresonk is a notch filter whose transfer functions represents the “filtered out” aspects of their complements. However, power scaling is not normalized in aresonk but remains the true complement of the corresponding unit. Thus an audio signal, filtered by parallel matching reson and aresonk units, would under addition simply reconstruct the original spectrum.

usage

  • kres aresonk ksig, kcf, kbw [, iscl] [, iskip]

parameters

  • ksig -- The input control-rate signal.
  • kcf -- The center frequency of the filter, or frequency position of the peak response.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

balance

Adjust one audio signal according to the values of another. balance outputs a version of asig, amplitude-modified so that its rms power is equal to that of a comparator signal acomp. Thus a signal that has suffered loss of power (eg., in passing through a filter bank) can be restored by matching it with, for instance, its own source. It should be noted that gain and balance provide amplitude modification only - output signals are not altered in any other respect.

usage

  • ares balance asig, acomp, [, ihp] [, iskip]

parameters

  • asig -- The input audio signal. This is the signal, whose gain will be modified.
  • acomp -- The comparator signal.
  • ihp -- Half-power point (in Hz) of a special internal low-pass filter. The default value is 10.
  • iskip -- (default = 0). Initial disposition of internal data space.

buzz

The buzz opcode continuously generates a set of harmonically related cosine partials. The primary use for buzz is to produce wave-train pulses that contain a complex set of harmonics, which is useful as an input for subtractive synthesis. This opcode is related to the GEN11 routine, which generates a static set of wave-train pulses.

usage

  • ares buzz xamp, xcps, knh, ifn [, iphs]

parameters

  • xamp -- Output amplitude scaling factor. The buzz units generate an additive set of harmonically related cosine partials of fundamental frequency xcps, and whose amplitudes are scaled so their summation peak equals xamp.
  • xcps -- Output frequency in Hertz (Hz).
  • knh -- Total number of harmonics requested. New in Csound version 3.57, knh defaults to one. If knh is negative, the absolute value is used.
  • ifn -- Table number of a stored function containing a sine wave. A large table of at least 8192 points is recommended.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

delay

Delays an input signal by some time interval. A signal can be read from or written into a delay path, or it can be automatically delayed by some time interval.

usage

  • ares delay asig, idlt [, iskp]

parameters

  • asig -- The input audio signal to be delayed.
  • idlt -- Requested delay time in seconds. This can be as large as available memory will permit. The space required for n seconds of delay is 4n * sr bytes. It is allocated at the time the instrument is first initialized, and returned to the pool at the end of a score section.
  • iskip -- (optional, default=0) Initial disposition of delay-loop data space (see reson). The default value is 0.

delay1

Delays an input signal by one sample. delay1 is a special form of delay that serves to delay the audio signal asig by just one sample. It is thus functionally equivalent to the delay opcode but is more efficient in both time and space. This unit is particularly useful in the fabrication of generalized non-recursive filters.

usage

  • ares delay1 asig, [, iskp]

parameters

  • asig -- The input audio signal to be delayed.
  • iskip -- (optional, default=0) Initial disposition of delay-loop data space (see reson). The default value is 0.

delayr

Reads from an automatically established digital delay line. delayr reads from an automatically established digital delay line, in which the signal retrieved has been resident for idlt seconds. This unit must be paired with and precede an accompanying delayw unit. Any other Csound statements can intervene.

usage

  • ares delayr idlt [, iskp]

parameters

  • idlt -- Requested delay time in seconds. This can be as large as available memory will permit. The space required for n seconds of delay is 4n * sr bytes. It is allocated at the time the instrument is first initialized, and returned to the pool at the end of a score section.
  • iskip -- (optional, default=0) Initial disposition of delay-loop data space (see reson). The default value is 0.

delayw

Writes the audio signal to a digital delay line. delayw writes asig into the delay area established by the preceding delayr unit. Viewed as a pair, these two units permit the formation of modified feedback loops, etc. However, there is a lower bound on the value of idlt, which must be at least 1 control period (or 1/kr).

usage

  • ares delayw asig

parameters

  • asig -- The audio-signal to write to the delay buffer.

expon

expon generates a curve between two points or levels in time. expon is especially useful for providing a smooth control or audio signal that's used for "sweeping" another control input from one level to another in an exponential manner.

usage

  • ares expon ia, idur, ib
  • kres expon ia, idur, ib

parameters

  • ia -- Starting value or level. This value may not be zero.
  • idur -- The duration in seconds for producing the exponential curve.
  • ib -- Value or level after idur seconds.

foscil

foscil is a composite unit that effectively banks two oscil opcodes in the familiar Chowning FM setup, wherein the audio-rate output of one generator is used to modulate the frequency input of another (the "carrier"). Effective carrier frequency = kcps * xcar, and modulating frequency = kcps * xmod. For integral values of xcar and xmod, the perceived fundamental will be the minimum positive value of kcps * (xcar -- n * xmod), n = 1,1,2,... The input kndx is the index of modulation (usually time-varying and ranging 0 to 4 or so) which determines the spread of acoustic energy over the partial positions given by n = 0,1,2,.., etc. ifn should point to a stored sine wave. Previous to version 3.50, xcar and xmod could be k-rate only.

usage

  • ares foscil xamp, kcps, xcar, xmod, kndx, ifn [ ,iphs]

parameters

  • xamp -- Output amplitude scaling factor.
  • kcps -- Frequency in Hertz (Hz) is the base-frequency for both the carrier and the modulator.
  • xcar -- The carrier-frequency-scaling factor. kcps is multiplied by this factor to obtain the carrier frequency.
  • xmod -- The modulator-frequency-scaling factor. kcps is multiplied by this factor to obtain the modulating frequency.
  • kndx -- The modulating index.
  • ifn -- Function table number, which is defined in the Csound score.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

foscili

Basic frequency modulated oscillator with linear interpolation. foscili differs from foscil in that the standard procedure of using a truncated phase as a sampling index is here replaced by a process that interpolates between two successive lookups. Interpolating generators will produce a noticeably cleaner output signal, but they may take as much as twice as long to run. Adequate accuracy can also be gained without the time cost of interpolation by using large stored function tables of 2K, 4K or 8K points if the space is available.

usage

  • ares foscili xamp, kcps, xcar, xmod, kndx, ifn [ ,iphs]

parameters

  • xamp -- Output amplitude scaling factor.
  • kcps -- Frequency in Hertz (Hz) is the base-frequency for both the carrier and the modulator.
  • xcar -- The carrier-frequency-scaling factor. kcps is multiplied by this factor to obtain the carrier frequency.
  • xmod -- The modulator-frequency-scaling factor. kcps is multiplied by this factor to obtain the modulating frequency.
  • kndx -- The modulating index.
  • ifn -- Function table number, which is defined in the Csound score.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

grain

grain is used for generating granular-synthesis textures. The grain opcode uses a function table as the source of a single stream of grains with grain density controlled by the parameters xdens. A second f-table is used for generating the envelope. Each grain starts at a random position within the source f-table and sustains for a duration specified by kgdur.

usage

  • ares grain xamp, xpitch, xdens, kampoff, kpitchoff, kgdur, igfn, iwfn, imgdur [, igrnd]

parameters

  • xamp -- Amplitude of each grain.
  • xpitch -- Grain pitch. To use the original frequency of the input sound, use the formula: sndsr / ftlen(igfn) where sndsr is the original sample rate of the igfn sound.
  • xdens -- Density of grains measured in grains per second. If this is constant then the output is synchronous granular synthesis, very similar to fof. If xdens has a random element (like added noise), then the result is more like asynchronous granular synthesis.
  • kampoff -- Maximum amplitude deviation from kamp. This means that the maximum amplitude a grain can have is kamp + kampoff and the minimum is kamp. If kampoff is set to zero then there is no random amplitude for each grain.
  • kpitchoff -- Maximum pitch deviation from kpitch in Hz. Similar to kampoff.
  • kgdur -- Grain duration in seconds. The maximum value for this should be declared in imgdur. If kgdur at any point becomes greater than imgdur, it will be truncated to imgdur.
  • igfn -- The f-table number of the grain waveform. This can be just a sine wave or a sampled sound.
  • iwfn -- F-table number of the amplitude envelope used for the grains (see also GEN20).
  • imgdur -- Maximum grain duration in seconds. This the biggest value to be assigned to kgdur.
  • igrnd -- if non-zero, turns off grain offset randomness. This means that all grains will begin reading from the beginning of the igfn table. If zero (the default), grains will start reading from random igfn table positions.

linen

Used for applying a straight-line rise and decay pattern. Can be used for applying an envelope to an existing audio signal. linen is used in two primary manners: (a) using the linen output to "wrap" another audio signal in an envelope or (b) passing an audio signal into an a-rate linen's input amplitude signal (xamp) to "wrap" the input signal in the envelope.

usage

  • ares linen xamp, irise, idur, idec
  • kres linen kamp, irise, idur, idec

parameters

  • xamp, kamp -- Input amplitude signal. Can be used to accept an audio signal to be "wrapped" or can accept an i-rate signal that specifies a fixed amplitude level.
  • irise -- Rise time in seconds. A zero or negative value indicates no rise modification.
  • idur -- overall duration in seconds. A zero or negative value will cause initialization to be skipped.
  • idec -- decay time in seconds. Zero means no decay. An idec > idur will cause a truncated decay.

notes

Rise modifications are applied for the first irise seconds, and decay from time idur - idec. If these periods are separated in time there will be a steady state during which amp will be unmodified. If linen rise and decay periods overlap then both modifications will be in effect for that time. If the overall duration idur is exceeded in performance, the final decay will continue on in the same direction, going negative.

linseg

Used to trace a series of line segments between specified points. Can be used for applying an envelope to an existing audio signal. linseg is used in two primary manners: (a) using the linseg output to "wrap" another audio signal in an envelope or (b) passing an audio signal into an a-rate linseg's input amplitude signal (xamp) to "wrap" the input signal in the envelope.

usage

  • ares linseg ia, idur1, ib [, idur2] [, ic] [...]
  • kres linseg ia, idur1, ib [, idur2] [, ic] [...]

parameters

  • ia -- starting value.
  • ib, ic, etc. -- value after dur1 seconds, etc.
  • idur1 -- duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.
  • idur2, idur3, etc. -- duration in seconds of subsequent segments. A zero or negative value will terminate the initialization process with the preceding point, permitting the last-defined line or curve to be continued indefinitely in performance. The default is zero.

notes

These units generate control or audio signals whose values can pass through 2 or more specified points. The sum of dur values may or may not equal the instrument's performance time: a shorter performance will truncate the specified pattern, while a longer one will cause the last-defined segment to continue on in the same direction.

loscil

Read sampled sound (mono or stereo) from a table, with optional sustain and release looping. loscil is the basic unit for building a sampling synthesizer. Given a sufficient set of recorded piano tones, for example, this unit can resample them to simulate the missing tones. Locating the sound source nearest a desired pitch can be done via table lookup. Once a sampling instrument has begun, its turnoff point may be unpredictable and require an external release envelope; this is often done by gating the sampled audio with linenr, which will extend the duration of a turned-off instrument by a specific period while it implements a decay.

loscil samples the ftable audio at a-rate determined by kcps, then multiplies the result by xamp. The sampling increment for kcps is dependent on the table's base-note frequency ibas, and is automatically adjusted if the orchestra sr value differs from that at which the source was recorded. In this unit, ftable is always sampled with interpolation.

usage

  • ares loscil xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] [, imod2,] [, ibeg2]
    [, iend2]

parameters

  • xamp -- The amplitude of the output signal.
  • kcps -- The frequency of the output signal in cycles per second.
  • ifn -- Function table number, typically denoting an AIFF sampled sound segment with prescribed looping points. The source file may be mono or stereo.
  • ibas -- Base frequency in Hz of the recorded sound. This optionally overrides the frequency given in the AIFF file, but is required if the file did not contain one. The default value is 261.626 Hz, i.e. middle C.
  • imod1, imod2 -- Play modes for the sustain and release loops. A value of 1 denotes normal looping, 2 denotes forward and backward looping, 0 denotes no looping. The default value (-1) will defer to the mode and the looping points given in the source file. (Default = -1).
  • ibeg1, iend1, ibeg2, iend2 -- Begin and end points of the sustain and release loops. These are measured in sample frames from the beginning of the file, so will look the same whether the sound segment is monaural or stereo.

loscil3

Read sampled sound from a table using cubic interpolation. loscil3 is the same as loscil except with the exception of the interpolation method employed.

usage

  • ares loscil3 xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] [, imod2,] [, ibeg2]
    [, iend2]

parameters

  • xamp -- The amplitude of the output signal.
  • kcps -- The frequency of the output signal in cycles per second.
  • ifn -- Function table number, typically denoting an AIFF sampled sound segment with prescribed looping points. The source file may be mono or stereo.
  • ibas -- Base frequency in Hz of the recorded sound. This optionally overrides the frequency given in the AIFF file, but is required if the file did not contain one. The default value is 261.626 Hz, i.e. middle C.
  • imod1, imod2 -- Play modes for the sustain and release loops. A value of 1 denotes normal looping, 2 denotes forward and backward looping, 0 denotes no looping. The default value (-1) will defer to the mode and the looping points given in the source file. (Default = -1).
  • ibeg1, iend1, ibeg2, iend2 -- Begin and end points of the sustain and release loops. These are measured in sample frames from the beginning of the file, so will look the same whether the sound segment is monaural or stereo.

oscil

A table-based oscillator. The waveform-table passed as a parameter is incrementally, modulo-N sampled to obtain sample heights, which are then multiplied by the amplitude parameter.

usage

  • ares oscil xamp, xcps, ifn [ ,iphs]
  • kres oscil kamp, kcps, ifn [ ,iphs]

parameters

  • xamp, kamp -- Output amplitude.
  • xcps, kcps -- Frequency in Hertz (Hz) for the output signal. The frequency is used internally to determine how large the steps are between successive samples.
  • ifn -- Function table number, which is defined in the Csound score.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

oscil1

Accesses table values by incrementally sampling values. oscil1 accesses values by sampling once through the function table at a rate determined by idur. For the first idel seconds, the point of scan will reside at the first location of the table; it will then begin moving through the table at a constant rate, reaching the end in another idur seconds; from that time on (i.e. after idel + idur seconds) it will remain pointing at the last location. Each value obtained from sampling is then multiplied by an amplitude factor kamp before being written into the result.

usage

  • kres oscil1 idel, kamp, idur, ifn

parameters

  • idel -- Delay in seconds before oscil1 incremental sampling begins.
  • kamp -- Amplitude scaling factor.
  • idur -- Duration in seconds to sample through the oscil1 table just once. A zero or negative value will cause all initialization to be skipped.
  • ifn -- Function table number. oscil1i require the extended guard point.

oscil1i

Accesses table values by incrementally sampling with linear interpolation. oscil1i is an interpolating unit in which the fractional part of index is used to interpolate between adjacent table entries. The smoothness gained by interpolation is at some small cost in execution time (see also oscili), but the interpolating and non-interpolating units are otherwise interchangeable.

usage

  • kres oscil1i idel, kamp, idur, ifn

parameters

  • idel -- Delay in seconds before oscil1 incremental sampling begins.
  • kamp -- Amplitude scaling factor.
  • idur -- Duration in seconds to sample through the oscil1 table just once. A zero or negative value will cause all initialization to be skipped.
  • ifn -- Function table number. oscil1i require the extended guard point.

oscil3

A table-based oscillator with cubic interpolation. oscil3 differs from oscil in that the standard procedure of using a truncated phase as a sampling index is replaced with a process that interpolates between two successive table entries/samples.

usage

  • ares oscil3 xamp, xcps, ifn [ ,iphs]
  • kres oscil3 kamp, kcps, ifn [ ,iphs]

parameters

  • xamp, kamp -- Output amplitude.
  • xcps, kcps -- Frequency in Hertz (Hz) for the output signal. The frequency is used internally to determine how large the steps are between successive samples.
  • ifn -- Function table number, which is defined in the Csound score.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

oscili

A table-based oscillator with linear interpolation. oscili differs from oscil in that the standard procedure of using a truncated phase as a sampling index is replaced with a process that interpolates between two successive table entries/samples.

usage

  • ares oscili xamp, xcps, ifn [ ,iphs]
  • kres oscili kamp, kcps, ifn [ ,iphs]

parameters

  • xamp, kamp -- Output amplitude.
  • xcps, kcps -- Frequency in Hertz (Hz) for the output signal. The frequency is used internally to determine how large the steps are between successive samples.
  • ifn -- Function table number, which is defined in the Csound score.
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.

oscilikt

A linearly interpolated oscillator that allows changing the table number at k-rate. oscilikt is very similar to oscili, but allows changing the table number at k-rate. It is slightly slower than oscili (especially with high control rate), although also more accurate as it uses a 31-bit phase accumulator, as opposed to the 24-bit one used by oscili.

usage

  • ares oscilikt xamp, xcps, kfn [ ,iphs] [, istor]
  • kres oscilikt kamp, kcps, kfn [ ,iphs] [, istor]

parameters

  • xamp, kamp -- Output amplitude.
  • xcps, kcps -- Frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than sr (and recommended to be less than sr/2).
  • kfn -- Function table number. Can be varied at control rate (useful to “morph” waveforms, or select from a set of band-limited tables generated by GEN30).
  • iphs -- Specifies a phase offset. This parameter is denoted as fraction-of-a-cycle units. For instance, 0 indicates no phase shift, while a value of .5 indicates a phase-shift of 1/2 a cycle.
  • istor -- (Default = 0) Skip initialization.

osciliktp

A linearly interpolated oscillator that allows phase modulation. osciliktp allows phase modulation (which is actually implemented as k-rate frequency modulation, by differentiating phase input). The disadvantage is that there is no amplitude control, and frequency can be varied only at the control-rate. This opcode can be faster or slower than oscilikt, depending on the control-rate.

usage

  • ares osciliktp kcps, kfn, kphs [, istor]

parameters

  • kcps -- Frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than sr (and recommended to be less than sr/2).
  • kfn -- Function table number. Can be varied at control rate (useful to “morph” waveforms, or select from a set of band-limited tables generated by GEN30).
  • kphs -- Phase (k-rate), the expected range is 0 to 1. The absolute value of the difference of the current and previous value of kphs must be less than ksmps.
  • istor -- (Default = 0) Skip initialization.

oscilikts

A linearly interpolated oscillator with sync status that allows changing the table number at k-rate. oscilikts is the same as oscilikt except it has a sync input that can be used to re-initialize the oscillator to a k-rate phase value. It is slower than oscilikt and osciliktp.

usage

  • ares oscilikts xamps, xcps, async, kphs [, istor]

parameters

  • xamps -- Output amplitude.
  • xcps -- Frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than sr (and recommended to be less than sr/2).
  • kfn -- Function table number. Can be varied at control rate (useful to “morph” waveforms, or select from a set of band-limited tables generated by GEN30).
  • async -- Any positive value resets the phase of oscilikts to kphs. Zeroor negative values have no effect.
  • kphs -- Phase (k-rate), the expected range is 0 to 1. The absolute value of the difference of the current and previous value of kphs must be less than ksmps.
  • istor -- (Default = 0) Skip initialization.

osciln

Accesses table values at a user-defined frequency. osciln will sample several times through the stored table at a rate of ifrq times per second, after which it will output zeros. Generates audio signals only, with output values scaled by kamp. Can also be written as oscilx.

usage

  • ares osciln kamps, ifrq, ifn, itimes

parameters

  • kamp -- Output amplitude factor.
  • ifrq, itimes -- Rate and number of times through the stored table.
  • ifn -- Function table number.

oscils

A simple fast sine-wave oscillator, that uses only one multiply, and two add operations to generate one sample of output, and does not require a function table.

usage

  • ares oscils iamp, icps, iphs [, iflg]

parameters

  • iamp -- Output amplitude.
  • icps -- Frequency in Hz (may be zero or negative, however the absolute value must be less than sr/2).
  • iphs -- Starting phase, between 0 and 1.
  • iflg -- Sum of the following values:
    • 2: use double precision even if Csound was compiled to use floats. This improves quality (especially in the case of long performance time), but may be up to twice as slow.
    • 1: skip initialization

oscilx

See osciln, which is the preferred name to use instead of this opcode. Accesses table values at a user-defined frequency. osciln will sample several times through the stored table at a rate of ifrq times per second, after which it will output zeros. Generates audio signals only, with output values scaled by kamp. Can also be written as oscilx.

usage

  • ares oscilx kamps, ifrq, ifn, itimes

parameters

  • kamp -- Output amplitude factor.
  • ifrq, itimes -- Rate and number of times through the stored table.
  • ifn -- Function table number.

out

Writes mono audio data to an external device or stream. Sends mono audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, quad, hex, or oct) should agree with nchnls. But as of version 3.50, Csound will attempt to change an incorrect opcode to agree with nchnls statement.

usage

  • out asig

parameters

  • asig -- The single-channel audio signal to be outputted.

outs

Writes stereo audio data to an external device or stream. Sends stereo audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, quad, hex, or oct) should agree with nchnls. But as of version 3.50, Csound will attempt to change an incorrect opcode to agree with the nchnls statement. Opcodes can be chosen to direct sound to any particular channel: outs1 sends to stereo channel 1, outq3 to quad channel 3, etc.

usage

  • outs asig1, asig2

parameters

  • asig1, asig2 -- The 2 channels of the stereo audio signal to be outputted.

outq

Writes 4-channel audio data to an external device or stream. Sends 4-channel audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, quad, hex, or oct) should agree with nchnls. But as of version 3.50, Csound will attempt to change an incorrect opcode to agree with the nchnls statement. Opcodes can be chosen to direct sound to any particular channel: outs1 sends to stereo channel 1, outq3 to quad channel 3, etc.

usage

  • outq asig1, asig2, asig3, asig4

parameters

  • asig1, asig2, asig3, asig4 -- The 4 channels of the quadrophonic audio signal to be outputted.

outh

Writes 6-channel audio data to an external device or stream. Sends 6-channel audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, quad, hex, or oct) should agree with nchnls. But as of version 3.50, Csound will attempt to change an incorrect opcode to agree with nchnls statement.

usage

  • outh asig1, asig2, asig3, asig4, asig5, asig6

parameters

  • asig1, asig2, ... asig6 -- The 6 channels of the hexaphonic audio signal to be outputted.

outo

Writes 8-channel audio data to an external device or stream. Sends 8-channel audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, quad, hex, or oct) should agree with nchnls. But as of version 3.50, Csound will attempt to change an incorrect opcode to agree with nchnls statement.

usage

  • outo asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8

parameters

  • asig1, asig2, ... asig8 -- The 8 channels of the octaphonic audio signal to be outputted.

outx

Writes 16-channel audio data to an external device or stream.

usage

  • out32 asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8, asig9, asig10, asig11, asig12, asig13, asig14, asig15, asig16

parameters

  • asig1, asig2, ... asig16 -- The 16 channels of the hexadecaphonic audio signal to be outputted.

out32

Writes 32-channel audio data to an external device or stream.

usage

  • out32 asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8, asig10, asig11, asig12, asig13, asig14, asig15, asig16, asig17, asig18, asig19, asig20, asig21, asig22, asig23, asig24, asig25, asig26, asig27, asig28, asig29, asig30, asig31, asig32

parameters

  • asig1, asig2, ... asig32 -- The 32 channels of the 32-channel audio signal to be outputted.

phasor

Generates a normalized, moving phase value. Normalized means that the output's range is between 0 and 1, which is indicative of a position within or a portion of a single cycle. By moving, we mean that the phasor produces an oscillating phase value. Hence, if the phasor output is multiplied by a table length, it can be used for generating a periodic waveform based on the table's contents.

usage

  • ares phasor xcps [, iphs]
  • kres phasor kcps [, iphs]

parameters

  • xcps, kcps -- Frequency in Hz.
  • iphs -- An optional starting phase. This value may lie between 0 and 1.

phasorbnk

Produce an arbitrary number of normalized moving phase values. For each independent phasor, an internal phase is successively accumulated in accordance with the kcps or xcps frequency to produce a moving phase value, normalized to lie in the range 0 <= phs < 1. Each individual phasor is accessed by index kndx.

usage

  • ares phasorbnk xcps, kndx, icnt [, iphs]
  • kres phasorbnk kcps, kndx, icnt [, iphs]

parameters

  • xcps, kcps -- Frequency in Hz.
  • kndx -- Index value to access individual phasors.
  • icnt -- Maximum number of phasors to be used.
  • iphs -- Initial phase, expressed as a fraction of a cycle (0 to 1). If -1 initialization is skipped. If iphas>1 each phasor will be initialized with a random value.

pluck

Generates a naturally decaying plucked string or drum sound based on the Karplus-Strong algorithms.

usage

  • ares pluck kamp, kcps, icps, ifn, imeth [, iparam1 [, iparam2]]

parameters

  • kamp -- Output amplitude.
  • kcps -- The resampling frequency in Hertz (Hz). An internal audio buffer, filled at i-time according to ifn, is continually resampled with periodicity kcps and the resulting output is multiplied by kamp. Parallel with the sampling, the buffer is smoothed to simulate the effect of natural decay.
  • icps -- intended pitch value in Hertz (Hz), used to set up a buffer of 1 cycle of audio samples which will be smoothed over time by a chosen decay method. icps normally anticipates the value of kcps, but may be set artificially high or low to influence the size of the sample buffer.
  • ifn -- table number of a stored function used to initialize the cyclic decay buffer. If ifn == 0, a random sequence will be used instead.
  • imeth -- method of natural decay. There are six, some of which use parameters values that follow:
    1. (1) simple averaging. A simple smoothing process, uninfluenced by parameter values;
    2. (2) stretched averaging. As above, with smoothing time stretched by a factor of iparm1 (>= 1);
    3. (3) simple drum. The range from pitch to noise is controlled by a "roughness factor" in iparm1 (0 to 1). Zero gives the plucked string effect, while 1 reverses the polarity of every sample (octave down, odd harmonics). The setting .5 gives an optimum snare drum;
    4. (4) stretched drum. Combines both roughness and stretch factors. iparm1 is roughness (0 to 1), and iparm2 the stretch factor (>=1);
    5. (5) weighted averaging. As method 1, with iparm1 weighting the current sample (the status quo) and iparm2 weighting the previous adjacent one. iparm1 + iparm2 must be <=1
    6. (6) 1st order recursive filter, with coefs 0.5. Unaffected by parameter values.
  • iparm1, iparm2 -- parameter values for use by the smoothing algorithms (above). The default values are zero.

notes

  • Plucked strings (1,2,5,6) are best realized by starting with a random noise source, which is rich in initial harmonics. Drum sounds (methods 3,4) work best with a flat source (wide pulse), which produces a deep noise attack and sharp decay.
  • The original Karplus-Strong algorithm used a fixed number of samples per cycle, which caused serious quantization of the pitches available and their intonation. This implementation resamples a buffer at the exact pitch given by kcps, which can be varied for vibrato and glissando effects. For low values of the orch sampling rate (e.g. sr = 10000), high frequencies will store only very few samples (sr / icps). Since this may cause noticeable noise in the resampling process, the internal buffer has a minimum size of 64 samples. This can be further enlarged by setting icps to some artificially lower pitch.

print

Displays the init-time values to the console or an X11 window if available. print will display the current value of the i-time arguments (or expression) at every i-pass through the instrument.

usage

  • print iarg0 [, iarg1] [, iarg2]

parameters

  • iarg0, iarg1, ... iargn -- The i-rate arguments to print.

printk

Prints one k-rate value at specified intervals. printk prints one k-rate value on every k-cycle, every second or at intervals specified. First the instrument number is printed, then the absolute time in seconds, then a specified number of spaces, then the kval value. The variable number of spaces enables different values to be spaced out across the screen - so they are easier to view. This opcode can be run on every k-cycle it is run in the instrument. To every accomplish this, set itime to 0. When itime is not 0, the opcode print on the first k-cycle it is called, and subsequently when every itime period has elapsed. The time cycles start from the time the opcode is initialized - typically the initialization of the instrument.

usage

  • printk itime, kval [, ispace]

parameters

  • itime -- Time in seconds between printings.
  • kval -- The k-rate value to be printed.
  • ispace -- (Default = 0) Number of spaces to insert before printing. Value must range between 0 and 130.

printk2

Prints a control-rate variable every time its value changes. Derived from Robin Whittle's printk, prints a new value of kvar each time kvar changes. Useful for monitoring MIDI control changes when using sliders. WARNING! Don't use this opcode with normal, continuously variant k-signals, because it can hang the computer, as the rate of printing is too fast

usage

  • printk2 kvar [, inumspaces]

parameters

  • kvar -- Signal to be printed.
  • inumspaces -- (Default = 0) Number of space characters to print before the value of kvar.

printks

Prints at k-rate using the C-language printf() style syntax. printks prints numbers and text which can be i-time or k-rate values. printks is highly flexible, and if used together with cursor positioning codes, could be used to write specific values to locations in the screen as the Csound processing proceeds. This opcode can be run on every k-cycle it is run in the instrument. To every accomplish this, set itime to 0. When itime is not 0, the opcode print on the first k-cycle it is called, and subsequently when every itime period has elapsed. The time cycles start from the time the opcode is initialized - typically the initialization of the instrument.

usage

  • printks "string", itime [, kval1] [, kval2] ... [, kvaln]

parameters

  • string -- The text string to be printed. Can be up to 8192 characters and must be in double quotes.
  • itime -- Time in seconds between printings.
  • kval1, ... kvaln -- The k-rate values to be printed. These are specified in string with the standard C-value specifier (%f, %d, etc.) in the order given.

prints

Prints at i-rate using the C-language printf() style syntax. prints prints numbers and text which can be i-time values. prints is highly flexible, and if used together with cursor positioning codes, could be used to write specific values to locations in the screen as the Csound processing proceeds.

usage

  • prints "string", itime [, ival1] [, ival2] ... [, ivaln]

parameters

  • string -- The text string to be printed. Can be up to 8192 characters and must be in double quotes.
  • ival1, ... ivaln -- The init-time values to be printed. These are specified in string with the standard C-value specifier (%f, %d, etc.) in the order given.

reson

A second-order resonant bandpass filter.

usage

  • ares reson asig, kcf, kbw [, iscl] [, iskip]

parameters

  • asig -- The input audio signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resonk

A second-order resonant bandpass filter.

usage

  • kres resonk ksig, kcf, kbw [, iscl] [, iskip]

parameters

  • ksig -- The input control-rate signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resonr

A second-order, two-pole, two-zero bandpass filter with variable frequency response. resonrresonz are variations of the classic two-pole bandpass resonator (reson). Both filters have two zeroes in their transfer functions, in addition to the two poles. resonz has its zeroes located at z = 1 and z = -1. resonr has its zeroes located at +sqrt(R) and -sqrt(R), where R is the radius of the poles in the complex z-plane. The addition of zeroes to resonr and resonz results in the improved selectivity of the magnitude response of these filters at cutoff frequencies close to 0, at the expense of less selectivity of frequencies above the cutoff peak.

resonr and resonz are very close to constant-gain as the center frequency is swept, resulting in a more efficient control of the magnitude response than with traditional two-pole resonators such as reson. resonr and resonz produce a sound that is considerably different from reson, especially for lower center frequencies; trial and error is the best way of determining which resonator is best suited for a particular application.

usage

  • ares resonr asig, kcf, kbw [, iscl] [, iskip]

parameters

  • asig -- The input audio signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resonx

Emulates a stack of filters using the reson opcode. resonx is equivalent to a stack of filters consisting of more layers of reson with the same arguments, serially connected. Using a stack of a larger number of filters allows a sharper cutoff. They are faster than using a larger number instances in a Csound orchestra of the old opcodes, because only one initialization and k- cycle are needed at time and the audio loop falls entirely inside the cache memory of processor.

usage

  • ares resonx asig, kcf, kbw [, inumlayer] [, iscl] [, iskip]

parameters

  • asig -- The input audio signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • inumlayer -- Number of elements in the filter stack. Default value is 4.
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resonxk

Emulates a stack of filters using the resonk opcode. resonx is equivalent to a stack of filters consisting of more layers of resonk with the same arguments, serially connected. Using a stack of a larger number of filters allows a sharper cutoff. They are faster than using a larger number instances in a Csound orchestra of the old opcodes, because only one initialization and k- cycle are needed at time and the audio loop falls entirely inside the cache memory of processor.

usage

  • kres resonxk asig, kcf, kbw [, inumlayer] [, iscl] [, iskip]

parameters

  • ksig -- The input control-rate signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • inumlayer -- Number of elements in the filter stack. Default value is 4.
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resony

A bank of second-order bandpass filters, connected in parallel. resony is a bank of second-order bandpass filters, with k-rate variant frequency separation, base frequency and bandwidth, connected in parallel (i.e. the resulting signal is a mix of the output of each filter). The center frequency of each filter depends of kbf and ksep variables. The maximum number of filters is set to 100.

usage

  • ares resony asig, kbf, kbw [, inumlayer] [, iscl] [, iskip]

parameters

  • ksig -- The input control-rate signal.
  • kbf -- The base frequency or center frequency of the lowest filter in the bank in Hz.
  • kbw -- Bandwidth of the filter in Hz.
  • inumlayer -- Number of elements in the filter stack. Default value is 4.
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

resonz

A bandpass filter with variable frequency response. The optional initialization variables for resonr and resonz are identical to the i-time variables for reson. resonr and resonz are variations of the classic two-pole bandpass resonator (reson). Both filters have two zeroes in their transfer functions, in addition to the two poles. resonz has its zeroes located at z = 1 and z = -1. resonr has its zeroes located at +sqrt(R) and -sqrt(R), where R is the radius of the poles in the complex z-plane. The addition of zeroes to resonr and resonz results in the improved selectivity of the magnitude response of these filters at cutoff frequencies close to 0, at the expense of less selectivity of frequencies above the cutoff peak.

usage

  • ares resonz asig, kcf, kbw [, iscl] [, iskip]

parameters

  • asig -- The input audio signal.
  • kcf -- The center frequency for the resonant bandpass filter.
  • kbw -- Bandwidth of the filter (frequency difference between the upper and lower half-power points).
  • iscl -- (default = 0). Coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.
  • iskip -- (default = 0). Initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.