This uses many different kinds of opcodes best understood in isolation without dealing with interactions. I will do that over the next three Examples. However, this example is important to understand what csound could do with only a few lines of code.
# ex1C02.py
# RMS Feedback System
from moduleCsound import *
tags(1)
header(ksmps=32)
# global sine table with 1024 points
add("giSine ftgen 0, 0, 2^10, 10, 1 ;table with a sine wave")
# delayr is used to create a delay line of 1 second
# We may use any number of taps, <=1, such as 0.5.
# delayw will write to delay line some sound
# Here that sound is initial input (asnd) and a feedback
# We only use taps at ade1+0.1 (audio a1) and ade2+0.1 (audio a2)
# We do not use a0, in the example.
# Only a1 is used to create signal for the outs opcode.
add("""
instr 1
a3 init 0
kamp linseg 0, 1.5, 0.2, 1.5, 0 ;envelope for initial input
asnd poscil kamp, 440, giSine ;initial input
if p4 == 1 then ;choose between two sines ...
adel1 poscil 0.0523, 0.023, giSine
adel2 poscil 0.073, 0.023, giSine,.5
else ;or a random movement for the delay lines
adel1 randi 0.05, 0.1, 2
adel2 randi 0.08, 0.2, 2
endif
a0 delayr 1 ;delay line of 1 second
a1 deltapi adel1 + 0.1 ;first reading
a2 deltapi adel2 + 0.1 ;second reading
krms rms a3 ;rms measurement
delayw asnd + exp(-krms) * a3 ;feedback depending on rms
a3 reson -(a1+a2), 3000, 7000, 2 ;calculate a3
aout linen a1/3, 1, p3, 1 ;apply fade in and fade out
outs aout, aout
endin
""")
tags(2)
add("""
i 1 0 60 1 ;two sine movements of delay with feedback
i 1 61 . 2 ;two random movements of delay with feedback
""")
tags(3)
writeRun(__file__)
No comments:
Post a Comment