Skip to content

Quick Start Tutorial

Make an Instrument, patch it to the output, and send an event.

Beep
;; make an instrument
instr myoscil
  asig oscil p4,p5
  send fillarray(asig) ; send audio to the patch array
endin

;Route audio output of myoscil to "outs"
patchsig "myoscil", "outs"                               ; Send audio to the output.

;schedule an event
schedule "myoscil",0,0.25,0.6,cpstuni(0,gi_CurrentScale)
Evaluate this code in your editor. You can evaluate it all at once, or start with the instrument, then the patchsig line, then the schedule event.

You should hear go beep.

What just happened?

  • We used a named Instrument, instead of a number.

    • cslc uses named instruments for patching audio.
  • We used the send UDO.

    • This sends audio to a global audio array.
    • Note that we didn't need to worry about audio channels. patchsig assumes all source channels will be sent to all destination inputs. For example, a mono source to a stereo destination copies the source to both inputs.
  • We used patchsig to connect the instrument to the output.

    • patchig retrieves the audio from the global audio array, and routes it to a destination.

gi_CurrentScale and pitch conversion

In the schedule event, we used a pitch conversion function, cpstuni, to convert '0' into a frequency value. The pitch lookup table was gi_Current_scale, which is a global table included in cslc. By default this table is set to a 7 note diatonic major scale in 31edo beginning with 0 on middle C (261.625565 hz). This means the octave above is numbered 7, the octave below is -7. Many of the event generation UDO's use cpstuni internally, so this pitch conversion is automatic. See the reference documentation for scalemode

Loops

Setting up a repeating loop is a common process when live coding. Lets see what this could look like:

Repetitive Beeps
;; make an instrument
instr myoscil
  asig oscil p4,p5
  send fillarray(asig) ; send audio to the patch array
endin

;Route audio output of myoscil to "outs"
patchsig "myoscil", "outs"                               ; Send audio to the output.

;schedule a looped event
loopevent fillarray_i(n("myoscil"),0,0.25,0.6,0), fillarray_i,(0,2,4) fillarray_i(0.5),1

Using loopevent

loopevent takes three arrays and an on/off switch.

The first array looks a lot like the scheduled event we had earlier. We've filled the array with pfields we used for schedule. See the reference documentation for loopevent

  • loopevent uses arrays, the first of which has all the pfields of a score event.

  • Because these are numerical arrays, for p1 we wrap the string "myoscil" with n("myoscil"). n is just a wrapper for the Csound opcode nstrnum which returns the instrument number.

  • For p5, cpstuni is not required to convert the pitch. loopevent uses cpstuni internally. loopevent also converts p2, and p3 for tempo changes. p4 assumes 0dbfs=1

  • fillarray_i is a version of fillarray that runs at init-time when used in inline code.

The second array specifies pitches in a scale called gi_CurrentScale.

The third array is an array of rhythmic intervals. In this case, a single repetitive note every 0.5 beats.

Finally, '1' at the end turns the loop on or off.

Practice Livecoding

Try changing the values in the loopevent arrays, then re-evaluate to see the effect.

What next?

Start going through the topics. You will find an example at the bottom of almost every page. Try copying the examples into your editor, evaluating them, and then modifying them to see what happens.

The topics are reference pages like a manual, but they also introduce concepts in cslc in a rough order, starting with time and tempo, scales and tuning, to more advanced examples in event generation and patching.