csound-expression-1.0.4: library to make electronic music

Safe HaskellSafe-Inferred

Csound.Opcode.Data

Contents

Description

Data

Synopsis

Buffer and Function tables

Reading From Tables

table :: Sig -> Tab -> SigSource

Accesses table values by direct indexing.

 ares table andx, ifn [, ixmode] [, ixoff] [, iwrap]
 ires table indx, ifn [, ixmode] [, ixoff] [, iwrap]
 kres table kndx, ifn [, ixmode] [, ixoff] [, iwrap]

doc: http://www.csounds.com/manual/html/table.html

tablei :: Sig -> Tab -> SigSource

Accesses table values by direct indexing with linear interpolation.

 ares tablei andx, ifn [, ixmode] [, ixoff] [, iwrap]
 ires tablei indx, ifn [, ixmode] [, ixoff] [, iwrap]
 kres tablei kndx, ifn [, ixmode] [, ixoff] [, iwrap]

doc: http://www.csounds.com/manual/html/tablei.html

table3 :: Sig -> Tab -> SigSource

Accesses table values by direct indexing with cubic interpolation.

 ares table3 andx, ifn [, ixmode] [, ixoff] [, iwrap]
 ires table3 indx, ifn [, ixmode] [, ixoff] [, iwrap]
 kres table3 kndx, ifn [, ixmode] [, ixoff] [, iwrap]

doc: http://www.csounds.com/manual/html/table3.html

tab_i :: D -> Tab -> DSource

Fast table opcodes. Faster than table and tablew because don't allow wrap-around and limit and don't check index validity. Have been implemented in order to provide fast access to arrays. Support non-power of two tables (can be generated by any GEN function by giving a negative length value).

 ir tab_i indx, ifn[, ixmode]

doc: http://www.csounds.com/manual/html/tab.html

tab :: Sig -> Tab -> SigSource

Fast table opcodes. Faster than table and tablew because don't allow wrap-around and limit and don't check index validity. Have been implemented in order to provide fast access to arrays. Support non-power of two tables (can be generated by any GEN function by giving a negative length value).

 kr tab kndx, ifn[, ixmode]
 ar tab xndx, ifn[, ixmode]

doc: http://www.csounds.com/manual/html/tab.html

Signal Input and Output, Sample and Loop Playback, Soundfonts

Signal Input And Output

inch :: CsdTuple a => [Sig] -> aSource

Reads from numbered channels in an external audio signal or stream.

 ain1[, ...] inch kchan1[,...]

doc: http://www.csounds.com/manual/html/inch.html

outch :: [(Sig, Sig)] -> SE ()Source

Writes multi-channel audio data, with user-controllable channels, to an external device or stream.

 outch kchan1, asig1 [, kchan2] [, asig2] [...]

doc: http://www.csounds.com/manual/html/outch.html

Sample Playback With Optional Looping

flooper2 :: Sig -> Sig -> Sig -> Sig -> Sig -> Tab -> SigSource

This opcode implements a crossfading looper with variable loop parameters and three looping modes, optionally using a table for its crossfade shape. It accepts non-power-of-two tables for its source sounds, such as deferred-allocation GEN01 tables.

 asig flooper2 kamp, kpitch, kloopstart, kloopend, kcrossfade, ifn \
       [, istart, imode, ifenv, iskip]

doc: http://www.csounds.com/manual/html/flooper2.html

sndloop :: Sig -> Sig -> Sig -> D -> D -> (Sig, Sig)Source

This opcode records input audio and plays it back in a loop with user-defined duration and crossfade time. It also allows the pitch of the loop to be controlled, including reversed playback.

 asig, krec sndloop ain, kpitch, ktrig, idur, ifad

doc: http://www.csounds.com/manual/html/sndloop.html

File Input and Output

Sound File Input

soundin :: CsdTuple a => Str -> aSource

Reads audio data from an external device or stream. Up to 24 channels may be read before v5.14, extended to 40 in later versions.

 ar1[, ar2[, ar3[, ... a24]]] soundin ifilcod [, iskptim] [, iformat] \
      [, iskipinit] [, ibufsize]

doc: http://www.csounds.com/manual/html/soundin.html

diskin2 :: CsdTuple a => Str -> Sig -> aSource

Reads audio data from a file, and can alter its pitch using one of several available interpolation types, as well as convert the sample rate to match the orchestra sr setting. diskin2 can also read multichannel files with any number of channels in the range 1 to 24 in versions before 5.14, and 40 after. . diskin2 allows more control and higher sound quality than diskin, but there is also the disadvantage of higher CPU usage.

 a1[, a2[, ... aN]] diskin2 ifilcod, kpitch[, iskiptim \
       [, iwrap[, iformat [, iwsize[, ibufsize[, iskipinit]]]]]]

doc: http://www.csounds.com/manual/html/diskin2.html

mp3in :: Str -> (Sig, Sig)Source

Reads stereo audio data from an external MP3 file.

 ar1, ar2 mp3in ifilcod[, iskptim, iformat, iskipinit, ibufsize]

doc: http://www.csounds.com/manual/html/mp3in.html

Sound File Queries

filelen :: Str -> DSource

Returns the length of a sound file.

 ir filelen ifilcod, [iallowraw]

doc: http://www.csounds.com/manual/html/filelen.html

filesr :: Str -> DSource

Returns the sample rate of a sound file.

 ir filesr ifilcod [, iallowraw]

doc: http://www.csounds.com/manual/html/filesr.html

filenchnls :: Str -> DSource

Returns the number of channels in a sound file.

 ir filenchnls ifilcod [, iallowraw]

doc: http://www.csounds.com/manual/html/filechnls.html

filepeak :: Str -> DSource

Returns the peak absolute value of a sound file.

 ir filepeak ifilcod [, ichnl]

doc: http://www.csounds.com/manual/html/filepeak.html

filebit :: Str -> DSource

Returns the number of bits in each sample in a sound file.

 ir filebit ifilcod [, iallowraw]

doc: http://www.csounds.com/manual/html/filebit.html

Sound File Output

fout :: [Sig] -> SE ()Source

fout outputs N a-rate signals to a specified file of N channels.

 fout ifilename, iformat, aout1 [, aout2, aout3,...,aoutN]

doc: http://www.csounds.com/manual/html/fout.html

Non-Soundfile Input And Output

Converters of Data Types

class Val a => Nums a Source

Floating number types: Sig or D.

Instances

Rate conversions

downsamp :: Sig -> SigSource

Modify a signal by down-sampling.

 kres downsamp asig [, iwlen]

doc: http://www.csounds.com/manual/html/downsamp.html

upsamp :: Sig -> SigSource

Modify a signal by up-sampling.

 ares upsamp ksig

doc: http://www.csounds.com/manual/html/upsamp.html

interp :: Sig -> SigSource

Converts a control signal to an audio signal using linear interpolation.

 ares interp ksig [, iskip] [, imode]

doc: http://www.csounds.com/manual/html/interp.html

Amplitude conversions

ampdb :: Nums a => a -> aSource

Returns the amplitude equivalent of the decibel value x. Thus:

  • 60 dB = 1000
  • 66 dB = 1995.262
  • 72 dB = 3891.07
  • 78 dB = 7943.279
  • 84 dB = 15848.926
  • 90 dB = 31622.764
 ampdb(x)  (no rate restriction)

doc: http://www.csounds.com/manual/html/ampdb.html

ampdbfs :: Nums a => a -> aSource

Returns the amplitude equivalent of the full scale decibel (dB FS) value x. The logarithmic full scale decibel values will be converted to linear 16-bit signed integer values from −32,768 to +32,767.

 ampdbfs(x)  (no rate restriction)

doc: http://www.csounds.com/manual/html/ampdbfs.html

dbamp :: Nums a => a -> aSource

Returns the decibel equivalent of the raw amplitude x.

 dbamp(x)  (init-rate or control-rate args only)

doc: http://www.csounds.com/manual/html/dbamp.html

dbfsamp :: Nums a => a -> aSource

Returns the decibel equivalent of the raw amplitude x, relative to full scale amplitude. Full scale is assumed to be 16 bit. New is Csound version 4.10.

 dbfsamp(x)  (init-rate or control-rate args only)

doc: http://www.csounds.com/manual/html/dbfsamp.html

Pitch conversions

cent :: Nums a => a -> aSource

Calculates a factor to raise/lower a frequency by a given amount of cents.

 cent(x) (no rate restriction)

doc: http://www.csounds.com/manual/html/cent.html

cpsmidinn :: Nums a => a -> aSource

Converts a Midi note number value to cycles-per-second.

 cpsmidinn (MidiNoteNumber)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/cpsmidinn.html

cpsoct :: Nums a => a -> aSource

Converts an octave-point-decimal value to cycles-per-second.

 cpsoct(oct) (no rate restriction)

doc: http://www.csounds.com/manual/html/cpsoct.html

cpspch :: Nums a => a -> aSource

Converts a pitch-class value to cycles-per-second.

 cpspch (pch)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/cpspch.html

octave :: Nums a => a -> aSource

Calculates a factor to raise/lower a frequency by a given amount of octaves.

 octave(x) (no rate restriction)

doc: http://www.csounds.com/manual/html/octave.html

octcps :: Nums a => a -> aSource

Converts a cycles-per-second value to octave-point-decimal.

 octcps (cps)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/octcps.html

octmidinn :: Nums a => a -> aSource

Converts a Midi note number value to octave-point-decimal.

 octmidinn (MidiNoteNumber)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/octmidinn.html

octpch :: Nums a => a -> aSource

Converts a pitch-class value to octave-point-decimal.

 octpch (pch)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/octpch.html

pchmidinn :: Nums a => a -> aSource

Converts a Midi note number value to octave point pitch-class units.

 pchmidinn (MidiNoteNumber)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/pchmidinn.html

pchoct :: Nums a => a -> aSource

Converts an octave-point-decimal value to pitch-class.

 pchoct (oct)  (init- or control-rate args only)

doc: http://www.csounds.com/manual/html/pchoct.html

semitone :: Nums a => a -> aSource

Calculates a factor to raise/lower a frequency by a given amount of semitones.

 semitone(x) (no rate restriction)

doc: http://www.csounds.com/manual/html/semitone.html

Integer and fractional parts

fracD :: D -> DSource

Fractional part of the number.

floorD :: D -> DSource

Floor operator for numbers.

ceilD :: D -> DSource

Ceiling operator for numbers.

intD :: D -> DSource

Integer part of the number.

roundD :: D -> DSource

Round operator for numbers.

fracSig :: Sig -> SigSource

Fractional part of the signal.

floorSig :: Sig -> SigSource

Floor operator for signals.

ceilSig :: Sig -> SigSource

Ceiling operator for signals.

intSig :: Sig -> SigSource

Integer part of the number for signals.

roundSig :: Sig -> SigSource

Round operator for signals.

Printing and Strings

Simple Printing

printi :: [D] -> SE ()Source

These units will print orchestra init-values.

 print iarg [, iarg1] [, iarg2] [...]

doc: http://www.csounds.com/manual/html/print.html

printk :: D -> Sig -> SE ()Source

Prints one k-rate value at specified intervals.

 printk itime, kval [, ispace]

doc: http://www.csounds.com/manual/html/printk.html

Formatted Printing

String Variables

sprintf :: Str -> [D] -> StrSource

sprintf write printf-style formatted output to a string variable, similarly to the C function sprintf(). sprintf runs at i-time only.

 Sdst sprintf Sfmt, xarg1[, xarg2[, ... ]]

doc: http://www.csounds.com/manual/html/sprintf.html

sprintfk :: Str -> [Sig] -> StrSource

sprintfk writes printf-style formatted output to a string variable, similarly to the C function sprintf(). sprintfk runs both at initialization and performance time.

 Sdst sprintfk Sfmt, xarg1[, xarg2[, ... ]]

doc: http://www.csounds.com/manual/html/sprintfk.html

String Manipulation And Conversion

strcat :: Str -> Str -> StrSource

Concatenate two strings and store the result in a variable. strcat runs at i-time only. It is allowed for any of the input arguments to be the same as the output variable.

 Sdst strcat Ssrc1, Ssrc2

doc: http://www.csounds.com/manual/html/strcat.html

strcatk :: Str -> Str -> StrSource

Concatenate two strings and store the result in a variable. strcatk does the concatenation both at initialization and performance time. It is allowed for any of the input arguments to be the same as the output variable.

 Sdst strcatk Ssrc1, Ssrc2

doc: http://www.csounds.com/manual/html/strcatk.html