Csound Csound-dev Csound-tekno Search About

[Csnd] nice working version of fractional voice legato

Date2022-04-29 01:07
FromIain Duncan
Subject[Csnd] nice working version of fractional voice legato
Attachmentsfrac-voice-legato.csd  
Hi folks and Steven, I have figured out a fairly elegant solution to my fractional voice legato problem and figured I'd share in case it's of use to anyone. 

This is intended to be used for hybrid modulars with the csound6~ object in Max. It allows creating multiple voices from fractional inums, with automatic legato if durations of the fractional voice overlap, without having to resort to negative pfields. (thus allowing legato transitions in a context where you might not know when scheduling a note whether the next note should be tied or not).

The solution was to have all voices turn themselves on with ihold, and just have the notes turn themselves off when p3 expires to get detached ones. Might be helpful to someone!

Thanks again Steven for your help in getting here! (I am eagerly looking forward to your new parser... )
iain

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
; ==============================================
<CsInstruments>

sr = 48000
ksmps = 16
nchnls = 2
0dbfs = 1

; pitch envelope instrument
; each fractional voice reads from its own kchan "frq.10" etc.
instr 1
    S_frq_chan = sprintf("frq.%d", (frac(p1) * 100))
    ihold
    kfrq = chnget:k(S_frq_chan)
    asig =  vco2(.1, kfrq * 1.00, 2, 0.5)
    asig += vco2(.1, kfrq * 1.002, 2, 0.51)
    asig += vco2(.1, kfrq * 0.997, 2, 0.49)
    outs asig, asig
endin

; pitch envelope instrument
; starts fresh if detached, ramps from last val if tied
instr 2
  S_frq_chan = sprintf("frq.%d", (frac(p1) * 100))
  ihold
  ifrq_dest = cpsmidinn(p4)
  iglide_time init 0.5

  if (tival:i() == 0) then
    kfrq init cpsmidinn(p4)
    ifrq_start init cpsmidinn(p4)
  else
    ifrq_start = i(kfrq)    
  endif

  kfrq  linseg  ifrq_start, iglide_time, ifrq_dest, p3 - iglide_time, ifrq_dest
  chnset kfrq, S_frq_chan

  if timeinsts:k() >= p3 then
    turnoff
  endif
endin


</CsInstruments>
; ==============================================
<CsScore>
f0 8
i 1.1 0 -1 110
i 1.2 0 -1 110
i 1.3 0 -1 110

i 2.1 0 2.2 48
i 2.2 0 2.2 52
i 2.3 0 2.2 55

i 2.1 2 1.0 55
i 2.2 2 1.0 59
i 2.3 2 1.0 62

i 2.1 4 1.0 48
i 2.2 4 1.0 52
i 2.3 4 1.0 55

</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

Date2022-06-11 22:30
FromPartev Sarkissian <0000060b2ef1338e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] nice working version of fractional voice legato
Running a Mac, nothing happened until I added "-odac",....
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>


-Partev 



-----Original Message-----
From: Iain Duncan <iainduncanlists@GMAIL.COM>
To: CSOUND@LISTSERV.HEANET.IE
Sent: Fri, Apr 29, 2022 1:07 am
Subject: [Csnd] nice working version of fractional voice legato

Hi folks and Steven, I have figured out a fairly elegant solution to my fractional voice legato problem and figured I'd share in case it's of use to anyone. 

This is intended to be used for hybrid modulars with the csound6~ object in Max. It allows creating multiple voices from fractional inums, with automatic legato if durations of the fractional voice overlap, without having to resort to negative pfields. (thus allowing legato transitions in a context where you might not know when scheduling a note whether the next note should be tied or not).

The solution was to have all voices turn themselves on with ihold, and just have the notes turn themselves off when p3 expires to get detached ones. Might be helpful to someone!

Thanks again Steven for your help in getting here! (I am eagerly looking forward to your new parser... )
iain

<CsoundSynthesizer>
<CsOptions>
</CsOptions>

; ==============================================
<CsInstruments>

sr = 48000
ksmps = 16
nchnls = 2
0dbfs = 1

; pitch envelope instrument
; each fractional voice reads from its own kchan "frq.10" etc.
instr 1
    S_frq_chan = sprintf("frq.%d", (frac(p1) * 100))
    ihold
    kfrq = chnget:k(S_frq_chan)
    asig =  vco2(.1, kfrq * 1.00, 2, 0.5)
    asig += vco2(.1, kfrq * 1.002, 2, 0.51)
    asig += vco2(.1, kfrq * 0.997, 2, 0.49)
    outs asig, asig
endin

; pitch envelope instrument
; starts fresh if detached, ramps from last val if tied
instr 2
  S_frq_chan = sprintf("frq.%d", (frac(p1) * 100))
  ihold
  ifrq_dest = cpsmidinn(p4)
  iglide_time init 0.5

  if (tival:i() == 0) then
    kfrq init cpsmidinn(p4)
    ifrq_start init cpsmidinn(p4)
  else
    ifrq_start = i(kfrq)    
  endif

  kfrq  linseg  ifrq_start, iglide_time, ifrq_dest, p3 - iglide_time, ifrq_dest
  chnset kfrq, S_frq_chan

  if timeinsts:k() >= p3 then
    turnoff
  endif
endin


</CsInstruments>
; ==============================================
<CsScore>
f0 8
i 1.1 0 -1 110
i 1.2 0 -1 110
i 1.3 0 -1 110

i 2.1 0 2.2 48
i 2.2 0 2.2 52
i 2.3 0 2.2 55

i 2.1 2 1.0 55
i 2.2 2 1.0 59
i 2.3 2 1.0 62

i 2.1 4 1.0 48
i 2.2 4 1.0 52
i 2.3 4 1.0 55

</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