[thumbuki.com]

III. Portamento and Glide

In the synthesizer world, the terms "portamento" and "glide" usually carry the same meaning. That is to pitch bend continuously between two notes until the desired note is reached. In this document, portamento and glide have two distinct meanings. Portamento means to continuously shift from the last pitch to the current pitch starting at the beginning of a new note. Glide means to continuously shift from the current pitch to the next pitch starting sometime during the current note, finishing the process the moment the next note begins.

Score Functions

Perhaps the simplest method in Csound to use to achieve a portamento or glide effect is by utilizing four specific score functions: +, ., ppx and npx. The + adds the previous p-field 2 and previous p-field 3. The . carries the previous value from the same p-field. Command ppx grabs a user specified previous p-field value. Command npx grabs a value from a following user specified p-field.

Figure 3.1    The arrows indicate where the specialized score functions look to grab p-field values.
Figure 3.2    The arrows indicate the direction in which p-field data values are copied in relation to the score functions in figure 3.1.

Portamento

The portamento in this example uses two elements to achieve the pitch bend. The first is an envelope that modulates pitch. The second is the ppx score command for reading the pitch of the last note instance.

Envelope kenv2 is a straight forward attack-sustain envelope. The envelope starts with the value of ippch, which is set equal to cpspch(p7). The rise time is equal to itime, or p8. The pitch is then sustained with the value of ipch, or cpspch(p6), for the remaining duration of the note.

The magic happens when kenv2 is used in conjunction with the score command ppx. After the initial note is triggered in the score, the previous p-field score command is used in the proceeding note events to look at the prior note pitch. This is done by entering the value pp6 for p7 in the score. The initial value of kenv2 is then set to the previous pitch value.

You might notice that the same mechanism used for portamenting pitch is also using for amplitude in this example.

Figure 3.3    Portamento utilizing an envelope and the ppx score command.
instr 1
    idur  = p3
    iamp  = p4
    ipamp = p5
    ipch  = cpspch(p6)
    ippch = cpspch(p7)
    itime = p8

    kenv1 linseg ipamp, itime, iamp, idur - itime, iamp
    kenv2 linseg ippch, itime, ipch, idur - itime, ipch
    aosc  oscil  kenv1, kenv2, 1, -1

    out aosc
endin
f1 0 2 2 1 -1

i1 0 1     10000 0   7.04 7.04 1
i1 + .     .     pp4 7.11 pp6  .1
i1 + .1666 .     pp4 8.04 pp6  .05
i1 + .     .     pp4 8.01 pp6  .
i1 + .     .     pp4 7.09 pp6  .
i1 + .     .     pp4 8.04 pp6  .05
i1 + .     .     pp4 8.01 pp6  .
i1 + .     .     pp4 7.09 pp6  .
i1 + .     .     pp4 8.02 pp6  .
i1 + .     .     pp4 7.11 pp6  .
i1 + .     .     pp4 7.07 pp6  .
i1 + 1     .     pp4 8.07 pp6  .05
i1 + .5    .     pp4 8.06 pp6  .
i1 + .     .     pp4 8.04 pp6  .
e
Figure 3.4    Orchestra and score code for east301.csd.

Glide

Glide works on the very same principles as the previous portamento example. The difference is that glide works in reverse. kenv2 in this example is a sustain-rise envelope, causing the pitch bend to happen at the end of a note. And the score command npx is used to read future score values.

Figure 3.5    Glide utilizing an envelope and the npx score command.
instr 1
    idur  = p3
    iamp  = p4
    inamp = p5
    ipch  = cpspch(p6)
    inpch = cpspch(p7)
    itime = p8

    kenv1 linseg iamp, idur - itime, iamp, itime, inamp
    kenv2 linseg ipch, idur - itime, ipch, itime, inpch
    aosc  oscil  kenv1, kenv2, 1, -1

    out aosc
endin
f1 0 2 2 1 -1

i1 0 1     10000 np4 7.04 np6  .5
i1 + .     .     np4 7.11 np6  .1
i1 + .1666 .     np4 8.04 np6  .05
i1 + .     .     np4 8.01 np6  .
i1 + .     .     np4 7.09 np6  .
i1 + .     .     np4 8.04 np6  .05
i1 + .     .     np4 8.01 np6  .
i1 + .     .     np4 7.09 np6  .
i1 + .     .     np4 8.02 np6  .
i1 + .     .     np4 7.11 np6  .
i1 + .     .     np4 7.07 np6  .
i1 + 1     .     np4 8.07 np6  .05
i1 + .5    .     np4 8.06 np6  .
i1 + .     .     0   8.04 8.04 .
e
Figure 3.6    Orchestra and score code for east302.csd.