;
; "Tied Note Example"
; by Steven Yi
;
; Example instruments and score written for "Exploring Tied Notes in Csound" article in The Csound Journal, Volume 1, Issue 1.
;
; Generated by blue 0.99.7 (http://csounds.com/stevenyi/blue/index.html)
;
<CsoundSynthesizer>
<CsOptions>
-odac --env:SSDIR="/Users/now/Music/drum kits/808s/" --default-paths
</CsOptions>
<CsInstruments>
sr=96000
ksmps=24
nchnls=2
0dbfs=1
opcode tieStatus,i,0
itie tival
if (itie == 0 && p3 < 0) ithen
; this is an initial note within a group of tied notes
itiestatus = 0
elseif (p3 < 0 && itie == 1) ithen
; this is a middle note within a group of tied notes
itiestatus = 1
elseif (p3 > 0 && itie == 1) ithen
; this is an end note out of a group of tied notes
itiestatus = 2
elseif (p3 > 0 && itie == 0) ithen
; this note is a standalone note
itiestatus = -1
endif
xout itiestatus
endop
instr 1 ;Normal Instrument
idur = abs(p3)
icps init cpspch(p4)
iskip tival
itie1 tieStatus
itab = ftgenonce(1, 0 ,2^16, -10 , 1)
; Init pitch for untied note
tigoto skipInit
kcps init icps
kcps lag icps,0.5 ; Drift towards
; ioldpch init ipch
indx = 1
imax = 5
asig vco ampdb(-18), kcps,1
loop:
print(indx)
kL lfo 0.1+indx*0.05,0.6
asigd vdelay asig,kL,0.3
asigdR vdelay asig,kL,0.3
asigL = asig
asigR = asig
asigLd,asigRd pan2 asigd, indx*.05
asigL += asigLd
asigR += asigRd
asigLd,asigRd pan2 asigdR, indx*.050221+0.5
asigL += asigLd
asigR += asigRd
; asig = asig*kenv
loop_le indx, 1, imax, loop
asigL lowpass2 asigL, 5000, 2
asigR lowpass2 asigR, 5000, 2
outs asigL*(1/(imax+1)),asigR*(1/(imax+1))
skipInit:
;inewpch = ipch
;kpchline linseg ioldpch, .2, inewpch, idur - .05, inewpch
;ioldpch = inewpch
;it1 = 0
;if (itie1 == -1) then
; kenv adsr .05, .05, .9, .05
; it1 =0
;elseif (itie1 == 0) then
; kenv linseg 0, .05, 1, .2, 1
; it1=0
;
;elseif (itie1 == 1) then
; kenv init 1
; it1 = -1
;
;elseif (itie1 == 2) then
; kenv linseg 1, idur - .05, 1, .5, 0
; it1 = -1
;
; endif
; prints("Im a tied note!")
endin
gi1 ftgen 0,0,2^10,9, 1,3,0, 3,1,0, 9,0.333,180
instr 2
kcps init cpspch(p4)
ke = 0
if p5 == 1 then
ke=1
endif
ke linsegr 1,0.1,0
skipke:
as oscil ke*0.1,kcps
kor = 0.2
as distort as,0.2,gi1
; as1 distort as1,0.22222,gi1
out as, as
endin
</CsInstruments>
<CsScore>
r8
t 0 130
i2 0 1.5 6.0 0
i2 3 1.5 5.07
i2 4.5 .5 5.08
i2 5 1.5 5.03
i2 6.5 1.5 5.03
s
</CsScore>
</CsoundSynthesizer>
In this code release of linseg spoils loop, i can change envelope with if that connected to p5 but it makes it without release and clicks, and its, redundant i think?
if i do it with r or n in score it waits note off of instrument i dont want it i want it like with retyping the same values with i statements that continue loop. or with { } and p2 is like [0+$index.]. Seems like unresolvable but mb someone knows what can be done other than deleting release.
Need release of last note to fade into start of the loop