Csound Csound-dev Csound-tekno Search About

[Csnd] Tied filters

Date2023-06-22 12:50
Fromtjingboem
Subject[Csnd] Tied filters
Hi,
i have a question about filters and how they behave (or should behave) when notes are tied.
I am using the UDO from Steven Yi, that helps analyzing when a note is not tied, the initial note within a group of tied notes,  middle note within a group of tied notes and when it is is an end note out of a group of tied notes.

This all works well with oscillators. 
On every note i have a HP filter that moves over the note: kfrq expon 14000, p3, 500

A filter, like for example buthp, also has a skip parameter to: skip initialization if present and non-zero.
However, when a note is held (negative p3),  the filter starts at a value of 500, instead of the 14000 i set as a start value. And it keeps on falling well below the end value of 500 when more than 1 note is held.

I was expecting the first held note (the tie to the next note) to start at 14000 and i could set a time to let it drop to 500. 
I guess this is not how this works...
Can someone please explain to me why the filter starts at the end value when it encounters a tied note?

The example, generated by Blue, is this:

;
; ""
; by
;
;
;
; Generated by blue 2.8.2 (http://blue.kunstmusik.com)
;

<CsoundSynthesizer>

<CsInstruments>
sr=44100
ksmps=1
nchnls=2
0dbfs  = 1

gk_blue_auto0 init 0.0458397183
gk_blue_auto1 init 0.6618621314




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 ;untitled
event "e", 0, 0, 0.1
endin

instr 2 ;Type 1 Instrument (Monosynth)
idur = abs(p3)                                                               ; idur is always positive
ipch = p4
iamp = p5

itiestatus tieStatus                                                    
iskip tival


tigoto skipInit

ioldpch init ipch                                                               ; copy pitch
ioldamp init iamp                                                               ; copy amplitude

skipInit:
inewpch = ipch
kpchline linseg ioldpch, i(gk_blue_auto1), inewpch, idur - i(gk_blue_auto1),  inewpch ; takes care of pitch jumps
ioldpch = inewpch

kamp port iamp, i(gk_blue_auto0), ioldamp                                           ; takes care of amplitude jumps
ioldamp = -1

if (itiestatus == -1) then                                                      ; envelope for normal notes
    kenv adsr .001, .05, .9, .05
iskp    =   0
elseif (itiestatus == 0) then                                                   ; envelope for first tied note
    kenv linseg 0, .05, 1,  .2, 1
iskp    =   0
elseif (itiestatus == 1) then                                                   ; envelope for tied middle notes
    kenv init 1
iskp    =   1
elseif (itiestatus == 2) then                                                   ; release for last tied note
    kenv linseg 1, idur - .05, 1, .05, 0
iskp    =   0
endif

;aout vco2 1, kpchline, iskip
aout    flooper2    1, kpchline, 0, .5, 0.05, 1, 1, 0, 0, iskip
;aout poscil3 1, kpchline, 1, -(iskip)
kfrq expon 14000, p3, 500
aout buthp  aout, kfrq, iskp
aout = aout * kamp * kenv *.8
        outs aout, aout
prints "\nstatus of TIE = %d\n",  itiestatus                                    ; report tieStatus
prints "status of SKIP = %d\n", iskip                                           ; 1 if this note has been “tied” onto a previously held note, 0 if no tie  
prints "status of FILTER = %d\n", iskp
printk .1, kfrq
endin


</CsInstruments>
<CsScore>
f1 0 4096 10 1 ;.3 ;sine wave

f 1 0 0 1 "fox.wav" 0 0 0

i2 0.0 1.5384615385 1.0 .80
i2 1.9230769230769234 1.5384615385 0.7 .83
i2 3.8461538461538467 1.5384615385 2.7 .76
i2 5.76923076923077 1.5384615385 1.5 .70
i2 7.692307692307693 -1.5384615385 1.0 .80
i2 9.615384615384615 -1.5384615385 0.7 .83
i2 11.538461538461538 -1.5384615385 2.7 .76
i2 13.46153846153846 1.5384615385 1.5 .70
i1 15.0 0.1
e

</CsScore>
</CsoundSynthesizer>

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2023-06-23 01:52
FromST Music
SubjectRe: [Csnd] Tied filters
Hi Menno,

not sure this helps much, but I did notice you use p3 in the filter env:

kfrq expon 14000, p3, 500

If you use idur instead then each tied note starts back at 14000, although I'm not sure if that's what you're looking for. Also, the exp envelopes (even expseg) occasionally overshoot 500 (drop below) but linseg will stop when it reaches 500 Hz.

Best,
Scott

On Thu, Jun 22, 2023, 7:50 a.m. tjingboem <magknevel@gmail.com> wrote:
Hi,
i have a question about filters and how they behave (or should behave) when notes are tied.
I am using the UDO from Steven Yi, that helps analyzing when a note is not tied, the initial note within a group of tied notes,  middle note within a group of tied notes and when it is is an end note out of a group of tied notes.

This all works well with oscillators. 
On every note i have a HP filter that moves over the note: kfrq expon 14000, p3, 500

A filter, like for example buthp, also has a skip parameter to: skip initialization if present and non-zero.
However, when a note is held (negative p3),  the filter starts at a value of 500, instead of the 14000 i set as a start value. And it keeps on falling well below the end value of 500 when more than 1 note is held.

I was expecting the first held note (the tie to the next note) to start at 14000 and i could set a time to let it drop to 500. 
I guess this is not how this works...
Can someone please explain to me why the filter starts at the end value when it encounters a tied note?

The example, generated by Blue, is this:

;
; ""
; by
;
;
;
; Generated by blue 2.8.2 (http://blue.kunstmusik.com)
;

<CsoundSynthesizer>

<CsInstruments>
sr=44100
ksmps=1
nchnls=2
0dbfs  = 1

gk_blue_auto0 init 0.0458397183
gk_blue_auto1 init 0.6618621314




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 ;untitled
event "e", 0, 0, 0.1
endin

instr 2 ;Type 1 Instrument (Monosynth)
idur = abs(p3)                                                               ; idur is always positive
ipch = p4
iamp = p5

itiestatus tieStatus                                                    
iskip tival


tigoto skipInit

ioldpch init ipch                                                               ; copy pitch
ioldamp init iamp                                                               ; copy amplitude

skipInit:
inewpch = ipch
kpchline linseg ioldpch, i(gk_blue_auto1), inewpch, idur - i(gk_blue_auto1),  inewpch ; takes care of pitch jumps
ioldpch = inewpch

kamp port iamp, i(gk_blue_auto0), ioldamp                                           ; takes care of amplitude jumps
ioldamp = -1

if (itiestatus == -1) then                                                      ; envelope for normal notes
    kenv adsr .001, .05, .9, .05
iskp    =   0
elseif (itiestatus == 0) then                                                   ; envelope for first tied note
    kenv linseg 0, .05, 1,  .2, 1
iskp    =   0
elseif (itiestatus == 1) then                                                   ; envelope for tied middle notes
    kenv init 1
iskp    =   1
elseif (itiestatus == 2) then                                                   ; release for last tied note
    kenv linseg 1, idur - .05, 1, .05, 0
iskp    =   0
endif

;aout vco2 1, kpchline, iskip
aout    flooper2    1, kpchline, 0, .5, 0.05, 1, 1, 0, 0, iskip
;aout poscil3 1, kpchline, 1, -(iskip)
kfrq expon 14000, p3, 500
aout buthp  aout, kfrq, iskp
aout = aout * kamp * kenv *.8
        outs aout, aout
prints "\nstatus of TIE = %d\n",  itiestatus                                    ; report tieStatus
prints "status of SKIP = %d\n", iskip                                           ; 1 if this note has been “tied” onto a previously held note, 0 if no tie  
prints "status of FILTER = %d\n", iskp
printk .1, kfrq
endin


</CsInstruments>
<CsScore>
f1 0 4096 10 1 ;.3 ;sine wave

f 1 0 0 1 "fox.wav" 0 0 0

i2 0.0 1.5384615385 1.0 .80
i2 1.9230769230769234 1.5384615385 0.7 .83
i2 3.8461538461538467 1.5384615385 2.7 .76
i2 5.76923076923077 1.5384615385 1.5 .70
i2 7.692307692307693 -1.5384615385 1.0 .80
i2 9.615384615384615 -1.5384615385 0.7 .83
i2 11.538461538461538 -1.5384615385 2.7 .76
i2 13.46153846153846 1.5384615385 1.5 .70
i1 15.0 0.1
e

</CsScore>
</CsoundSynthesizer>

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here