FLOSS Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

CSOUND Español

OPCODE GUIDE: MATH, PYTHON/ SYSTEM, PLUGINS

MATHS

  • MATHEMATICAL CALCULATIONS

    • Arithmetic Operations

      +, -, *, /, ^, % 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.

      exp(x), log(x), log10(x) and sqrt(x) return e raised to the xth power, the natural log of x, the base 10 log of x, and the square root of x.

      abs(x) returns the absolute value of a number.

      int(x) and frac(x) return the integer respective the fractional part of a number.

      round(x), ceil(x), floor(x) round a number to the nearest, the next higher or the next lower integer.
    • Trigonometric Functions

      sin(x), cos(x), tan(x) perform a sine, cosine or tangent function.

      sinh(x), cosh(x), tanh(x) perform a hyperbolic sine, cosine or tangent function.

      sininv(x), cosinv(x), taninv(x) and taninv2(x) perform the arcsine, arccosine and arctangent functions.
    • Logic Operators

      && 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 ...

      ! is the symbol for logical "not". For example: if (kx != 2) then ... would serve a conditional branch if variable kx was not equal to '2'.

  • CONVERTERS

    • 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.

    • Amplitude Converters

      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 

      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

  • PYTHON OPCODES

    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.

  • SYSTEM OPCODES

    getcfg returns various Csound configuration settings as a string at init time.

    system / system_i call an external program via the system call.

PLUGINS

  • PLUGIN HOSTING

    • LADSPA

      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.

    • VST

      vstinit loads a plugin.

      vstaudio / vstaudiog return a plugin's output.

      vstmidiout sends midi data to a plugin.

      vstparamset / vstparamget sends and receives automation data to and from the 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.

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.