Friday, July 21, 2017

ex3A03. Performance pass increment listen

# ex3A03.py
# Performance pass increment listen

from moduleCsound import *

tags(1)

header(ksmps=441)

add("""
;build a table containing a sine wave
giSine     ftgen      0, 0, 2^10, 10, 1
""")

add("""
instr Rise
kFreq      init       100
aSine      poscil     .2, kFreq, giSine
           outs       aSine, aSine
;increment frequency by 10 Hz for each k-cycle
kFreq      =          kFreq + 10
;print out the frequency for the last k-cycle
kLast      release
 if kLast == 1 then
           printk     0, kFreq
 endif
endin

instr Partials
;initialize kCount
kCount     init       100
;get new frequency if kCount equals 100, 200, ...
 if kCount % 100 == 0 then
kFreq      =          kCount
 endif
aSine      poscil     .2, kFreq, giSine
           outs       aSine, aSine
;increment kCount
kCount     =          kCount + 1
;print out kFreq whenever it has changed
           printk2    kFreq
endin
""")

tags(2)

add("""
i "Rise" 0 3
i "Partials" 4 31
""")

tags(3)

writeRun(__file__)

Output (Spectrograph view):


No comments:

Post a Comment

ex3A05. Audio Vector