Title: Investigating Sound
1Investigating Sound
Score Macros Legato Distortions
- Prof. Jerry Breecher
- Fall 2006
2Score Macros
instr 503 kenv linen p4, .3, p3, .3 asig
oscil kenv, cpspch(p5), 1 out
asig endin
instr 504 kenv1 linen p4, .3, p3,
.3 kenv2 linseg 0, p3.9, p4, p3.1, 0 asig1
oscil kenv1, cpspch(p5), 1 asig2 oscil
kenv1, cpspch(p5)p7, 2 asig3 oscil kenv2,
cpspch(p5)p6, 3 amix asig1 asig2
asig3 aflt butterlp amix, p8p9 out
aflt endin
Example4.01
f 1 0 4096 10 1 0 1 define C
8.00 define Csharp 8.01 define Dflat
8.01 define D 8.02 define
Dsharp 8.03 define Eflat
8.03 define E 8.04 define F
8.05 i 503 0 1 1000 C. i 503 1
1 2000 D. i 503 2 1 3000 E. i
503 3 1 4000 F.
f 1 0 4096 10 16 15 14 13 12 11 10 9 8 7 6 5 4 3
2 1 f 2 0 4096 10 16 0 14 0 12 0 10 0 8 0 6 0 4 0
f 3 0 4096 10 16 0 0 13 0 0 10 0 0 7 0 0 4 0 0
1 define ARG(A) 6.345 1.03 A. 234.9
i 504 0 1 23000 8.00
ARG(2.0) i 504 4 24000 8.04
ARG(5.0)
Example4.02
3Score Macros
This lets you have a separate file and then make
it part of your score include filename
f1 0 4096 10 1 i 507 0 2 10000 9.2 s f0
1 s include my_section1 s include
my_section1
my_section1 i 507 1.000 10.652 2000 9.67 i
507 1.652 10.895 3000 9.74 i 507 2.547 10.591 400
0 9.77 i 507 3.138 10.389 5000 9.79 i
507 3.527 10.347 6000 9.60 i 507 3.874 10.436 700
0 9.63 i 507 4.310 10.700 8000 9.68
Example4.03
This lets you repeat numerous times in the
example, repeat 3 times and each time the
variable NN takes on the value 1, 2, 3, R3 NN
- Section goes until an s, r, or e
directive
instr 508 k1 expon p4, p3,
.001 a1 oscil k1,cpspch(p5),1 out
a1 endin
f1 0 4096 10 1 r3 CNT i 508 0 .25 10000
CNT.00 2 i . . gt CNT.02 3 i .
. gt CNT.04 5 i . . 20000
CNT.05 8 e
Example4.04
4Score Syntax Statements
These are various things you can use in your
score. You can find these at
http//www.csounds.com/man/qr/score.htm
f "table number" "action time" "size" "GEN
routine" arg1 arg2...arg... f0 "action time"
(Dummy ftable for padding score sections with
silence and reporting on progress of long running
jobs). b "base clock time" (Effective prior to
score sorting. This time base is pre-warped.) v
"time warp factor" (Locally variable time warping
of score events.) t 0 "initial tempo" "time in
beats" "tempo2""time in beats" "tempo3" "time
in... a 0 "begin time advance in beats"
"duration of time advance in beats" i "instrument
number" "start" "duration" p4 p5 p... s
(marks end of section and restarts score counting
from time 0) m "score location name" (marks a
score section with a name) n "score location
name" (named score section is re-read into the
score file at this location) r "integer repeat
count" "a macro name" (begins a new repeating
sections) e (marks end of score - optional)
5Score Syntax P-Field Substitution
These are various things you can use in your
score. You can find these at
http//www.csounds.com/man/qr/score.htm
. (carries same p-field value from preceding "i"
statement with like instrument ) (determines
current start from sum of preceeding durations by
adding p2 p3 from previous "i" statement. legal
in p2 only.) x (determines current start of
instrument from sum of preceeding written event
by adding last p2 to x. legal in p2 only.) -x
(determines current start of instrument from sum
of preceeding written event by subtracting x from
last p2. legal in p2 only.) npx (replace with
p-field(x) value from next note statement illegal
in p1 p2 p3.) ppx (replace with p-field(x) value
from previous note statement illegal in p1 p2
p3.) lt (p-field replaced by value derived
from linear interpolation between previous and
subsequent "anchor" values in same p-field.
illegal in p1 p2 p3) gt (p-field replaced by
value derived from linear interpolation between
previous and subsequent "anchor" values in same
p-field. illegal in p1 p2 p3) ) (p-field
replaced by value derived from exponential
interpolation between previous and subsequent
"anchor" values in same p-field. illegal in p1 p2
p3) ( (p-field replaced by value derived from
exponential interpolation between previous and
subsequent "anchor" values in same p-field.
illegal in p1 p2 p3) (p-field replaced by
value derived from random value in the range
between previous and subsequent "anchor" values
in same p-field. illegal in p1 p2 p3)
6Portamento
Changing the frequency over the duration of the
note
Example4.10.orc
sr 44100 kr
4410 ksmps 10 nchnls
1 instr 1801 kfr
linseg p5, p3.1, p6, p3.9, p6 p5
FREQ OF LAST NOTE asig oscil p4, kfr, 1
p6 FREQ FOR THIS NOTE
out asig endin
Example4.10.sco
f 1 0 8193 10 1 i 1801 0
0.4 10000 440 440 i 1801 . .
pp6 660 i 1801 . . pp6 550
7Global Control
Example4.11.orc
Using a global variable to change multiple
instruments
sr 44100 kr 4410 ksmps
10 nchnls 2 galamp init
0 INITIAL VALUE gazero init 0
Always zero instr 411 galamp oscil
1, p5, 1 This controls rate between
left and right endin instr 412
This is the left instrument aosc
oscil p4, p5, 2 outs galamp aosc,
gazero endin instr 413
This is the right instrument aosc oscil
p4, p5, 2 outs gazero, (1 - galamp )
aosc endin
f 1 0 8193 10 1 used
for left/right f 2 0 8192 10 1 0.9 0.3 0.7
0.5 generates the sound i 411 0 10
10000 0.5 this is the left right control i
412 0 10 10000 50 this is the left
sound i 413 0 10 10000 440 this is
the right sound
Example4.11.sco
8Legato
The indicator for a tied note is driven from the
score
Example4.12.sco
f 1 0 1024 10 1 0.95 0.1 0.05 0.01
0.001 BASIC P-FIELDS ... CONTEXT P-FIELDS INS
ST DUR AMP PITCH PREVPCH NEXTAMP i 702
0 -1 10000 7.03 7.03 np4 i 702 .
4000 8.00 pp5 np4 i 702 . .
22000 7.06 pp5 np4 POSITIVE DUR (P3)
FOR LAST TIED NOTE i 702 . 1 4000 7.08
pp5 0
Note that P3 can have a negative value this
indicates a tied note. The score also contains
pp5 which means use the previous P5
value. np4 means use the next P4 value here.
9Legato
ir is a special symbol thats set to the tie
value ( or -) il is special if il -1, then
tells csound to not reinitialize the phase. The
command tigoto says go to a label in the code if
the note is tied. The commands igoto and kgoto
are conditional gotos. The send the code to a
label based on if a previous condition is true or
false.
Example4.12.orc
instr 702 idur abs(p3)
MAIN INIT BLOCK ipch1
cpspch(p6) ipch2 cpspch(p5) kpch
ipch2 iport 0.1
100msec PORTAMENTO iatt 0.05
DEFAULT DURS FOR AMPLITUDE
RAMPS idec 0.05 ASSUME
THIS IS A TIED NOTE iamp p4
SO START AT p4 LEVEL... i1 -1
... AND KEEP PHASE CONTINUITY
ir tival CONDITIONAL
INIT BLOCKTIED NOTE? tigoto start i1
0 FIRST NOTE
RESET PHASE iamp 0
AND ZERO iamp start
10Legato
Example4.12.orc
The indicator for a tied note is driven from the
score
start iadjust iatt idec
if idur gt iadjust igoto doamp ADJUST
RAMP DURATIONS FOR SHORT... iatt idur/2
- 0.005 ... NOTES, 10msecs LIMIT idec
iatt ENSURE NO
ZERO-DUR SEGMENTS iadjust idur-0.01
iport 0.005 MAKE
AMPLITUDE RAMP... doamp
... (arate FOR CLEANNESS) AND... ilen
idur - iadjust ... SKIP PITCH
RAMP GENERATION... amp linseg iamp,
iatt, p4, ilen, p4, idec, p7 if ir 0
p6 p5 kgoto slur ...IF FIRST NOTE OR
TIE. MAKE PITCH RAMP, PORTAMENTO AT START OF
NOTE kpramp linseg ipch1, iport, ipch2,
idur-iport, ipch2 kpch kpramp slur
MAKE THE
NOTE aamp amp asig oscili
aamp, kpch, 1, i1 out asig
endin