Csound Csound-dev Csound-tekno Search About

[Csnd] Notes silencing previous notes from same instrument when global or in Zak space

Date2020-05-13 22:48
FromRyan Jeffares
Subject[Csnd] Notes silencing previous notes from same instrument when global or in Zak space
Hey everyone,

I noticed something while using the Zak opcodes to route audio from multiple instruments to a single output, and subsequently got the same problem when trying it with global audio signals. The following code will generate a random sequence of notes on each bang of the metro, with the notes ringing out over eachother:

instr trigger
    ktrig metro 0.2
    ktime init 0
    if (ktrig == 1) then
        while (ktime <= 1) do    ; For 1 second
            krand random 0, 7      
            knote table krand, 1  ; Pick a random MIDI note from a table
            event "i", 2, ktime, 0.5, knote
            ktime += 0.1   ; Increment our time
            od    
        ktime = 0        ; Reset the timer
    endif  
endin

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    outs asig, asig
endin

</CsInstruments>
<CsScore>
f1 0 7 -2 60 62 64 65 67 69 71
i"trigger" 0 20
</CsScore>
</CsoundSynthesizer>


However, when the audio is routed using the Zak opcodes such as this (with zak initialised and the output instrument turned on of course):

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    zaw asig, 0
endin

instr output
    asig zar 0
    outs asig, asig
    zacl 0, 1
endin


Or when the output of pluck is assigned to a global a rate which is then output in the output instrument, each quick successive note will cut the previous one off entirely. This happens whether zacl is used to clear the variable in zak space or not, or whether the global is cleared or not after the output. I can't figure out why this would happen, maybe it's a bug? Or maybe someone could explain it to me. Cheers!
Ryan
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

Date2020-05-13 23:02
FromJohn ff
SubjectRe: [Csnd] Notes silencing previous notes from same instrument when global or in Zak space
You need to accumulate in zak not just write

On 13 May 2020, at 22:49, Ryan Jeffares <ryandjeffares@gmail.com> wrote:
Hey everyone,

I noticed something while using the Zak opcodes to route audio from multiple instruments to a single output, and subsequently got the same problem when trying it with global audio signals. The following code will generate a random sequence of notes on each bang of the metro, with the notes ringing out over eachother:

instr trigger
    ktrig metro 0.2
    ktime init 0
    if (ktrig == 1) then
        while (ktime <= 1) do    ; For 1 second
            krand random 0, 7      
            knote table krand, 1  ; Pick a random MIDI note from a table
            event "i", 2, ktime, 0.5, knote
            ktime += 0.1   ; Increment our time
            od    
        ktime = 0        ; Reset the timer
    endif  
endin

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    outs asig, asig
endin

</CsInstruments>
<CsScore>
f1 0 7 -2 60 62 64 65 67 69 71
i"trigger" 0 20
</CsScore>
</CsoundSynthesizer>


However, when the audio is routed using the Zak opcodes such as this (with zak initialised and the output instrument turned on of course):

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    zaw asig, 0
endin

instr output
    asig zar 0
    outs asig, asig
    zacl 0, 1
endin


Or when the output of pluck is assigned to a global a rate which is then output in the output instrument, each quick successive note will cut the previous one off entirely. This happens whether zacl is used to clear the variable in zak space or not, or whether the global is cleared or not after the output. I can't figure out why this would happen, maybe it's a bug? Or maybe someone could explain it to me. Cheers!
Ryan
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

Date2020-05-14 15:09
FromRyan Jeffares
SubjectRe: [Csnd] Notes silencing previous notes from same instrument when global or in Zak space
Thanks John all sorted now!
Ryan

On Wed, 13 May 2020 at 23:03, John ff <jpff@codemist.co.uk> wrote:
You need to accumulate in zak not just write

On 13 May 2020, at 22:49, Ryan Jeffares <ryandjeffares@gmail.com> wrote:
Hey everyone,

I noticed something while using the Zak opcodes to route audio from multiple instruments to a single output, and subsequently got the same problem when trying it with global audio signals. The following code will generate a random sequence of notes on each bang of the metro, with the notes ringing out over eachother:

instr trigger
    ktrig metro 0.2
    ktime init 0
    if (ktrig == 1) then
        while (ktime <= 1) do    ; For 1 second
            krand random 0, 7      
            knote table krand, 1  ; Pick a random MIDI note from a table
            event "i", 2, ktime, 0.5, knote
            ktime += 0.1   ; Increment our time
            od    
        ktime = 0        ; Reset the timer
    endif  
endin

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    outs asig, asig
endin

</CsInstruments>
<CsScore>
f1 0 7 -2 60 62 64 65 67 69 71
i"trigger" 0 20
</CsScore>
</CsoundSynthesizer>


However, when the audio is routed using the Zak opcodes such as this (with zak initialised and the output instrument turned on of course):

instr 2
    kenv madsr 0.01, 0.01, 0.5, 1
    kfreq = cpsmidinn(p4)
    asig pluck kenv, kfreq, i(kfreq), 0, 1
    zaw asig, 0
endin

instr output
    asig zar 0
    outs asig, asig
    zacl 0, 1
endin


Or when the output of pluck is assigned to a global a rate which is then output in the output instrument, each quick successive note will cut the previous one off entirely. This happens whether zacl is used to clear the variable in zak space or not, or whether the global is cleared or not after the output. I can't figure out why this would happen, maybe it's a bug? Or maybe someone could explain it to me. Cheers!
Ryan
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
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