OPCODE GUIDE: MATH, PYTHON/ SYSTEM, PLUGINS
+, -, *, /, ^, % are the usual signs for addition, subtraction, multiplication, division, raising to a power and modulo. The precedence is like that used in common mathematics (* binds stronger than + etc.), but you can change this behaviour with parentheses: 2^(1/12) returns 2 raised by 1/12 (= the 12st root of 2), while 2^1/12 returns 2 raised by 1, and the result divided by 12.
abs(x) returns the absolute value of a number.round(x), ceil(x), floor(x) round a number to the nearest, the next higher or the next lower integer.
Trigonometric Functionssininv(x), cosinv(x), taninv(x) and taninv2(x) perform the arcsine, arccosine and arctangent functions.
&& and || are the symbols for a logical "and" and "or". Note that you can use here parentheses for defining the precedence, too, for instance: if (ival1 < 10 && ival2 > 5) || (ival1 > 20 && ival2 < 0) then ...
MIDI To Frequency
cpsmidi converts a MIDI note number from a triggered instrument to the frequency in Hertz.
cpsmidinn does the same for any input values (i- or k-rate).
Other opcodes convert to Csound's pitch- or octave-class system. They can be found here.
Frequency To MIDI
Csound has no own opcode for the conversion of a frequency to a midi note number, because this is a rather simple calculation. You can find a User Defined Opcode for rounding to the next possible midi note number or for the exact translation to a midi note number and a cent value as fractional part.
Cent Values To Frequency
cent converts a cent value to a multiplier. For instance, cent(1200) returns 2, cent(100) returns 1.059403. If you multiply this with the frequency you reference to, you get frequency of the note which corresponds to the cent interval.
ampdb returns the amplitude equivalent of the dB value. ampdb(0) returns 1, ampdb(-6) returns 0.501187, and so on.
ampdbfs returns the amplitude equivalent of the dB value, according to what has been set as 0dbfs (1 is recommended, the default is 15bit = 32768). So ampdbfs(-6) returns 0.501187 for 0dbfs=1, but 16422.904297 for 0dbfs=32768.
dbamp returns the decibel equivalent of the amplitude value, where an amplitude of 1 is the maximum. So dbamp(1) -> 0 and dbamp(0.5) -> -6.020600.dbfsamp returns the decibel equivalent of the amplitude value set by the 0dbfs statement. So dbfsamp(10) is 20.000002 for 0dbfs=0 but -70.308998 for 0dbfs=32768.
Scaling of signals from an input range to an output range, like the "scale" object in Max/MSP, is not implemented in Csound, because it is a rather simple calculation. It is available as User Defined Opcode: Scali (i-rate), Scalk (k-rate) or Scala (a-rate).
PYTHON AND SYSTEM
pyinit initializes the Python interpreter.
pyrun runs a Python statement or block of statements.
pyexec executes a script from a file at k-time, i-time or if a trigger has been received.
pycall invokes the specified Python callable at k-time or i-time.
pyeval evaluates a generic Python expression and stores the result in a Csound k- or i-variable, with optional trigger.
pyassign assigns the value of the given Csound variable to a Python variable possibly destroying its previous content.
getcfg returns various Csound configuration settings as a string at init time.
dssiinit loads a plugin.
dssiactivate activates or deactivates a plugin if it has this facility.
dssilist lists all available plugins found in the LADSPA_PATH and DSSI_PATH global variables.
dssiaudio processes audio using a plugin.
dssictls sends control information to a plugin's control port.
vstinit loads a plugin.
vstmidiout sends midi data to a plugin.
vstnote sends a midi note with a definite duration.
vstinfo outputs the parameter and program names for a plugin.
vstbankload loads an .fxb bank.
vstprogset sets the program in a .fxb bank.vstedit opens the GUI editor for the plugin, when available.