[Csnd] Line segments between tied notes
Date | 2020-12-19 18:34 |
From | Søren Jakobsen |
Subject | [Csnd] Line segments between tied notes |
Hello! Can someone tell me the 'correct' way to continue line segments between tied notes - perhaps also explain me why the linseg opcode only takes i-rate parameters? I am looking for a dynamic way to cut short ongoing line segments and continue them with other line segments, e.g. to make a release on note off events: |
Date | 2020-12-19 19:19 |
From | Steven Yi |
Subject | Re: [Csnd] Line segments between tied notes |
Hi Søren, Maybe this article I wrote a long while ago will be useful: https://csoundjournal.com/2005fall/tiedNotes.html It can be a little tricky with tied notes if you want to grab the current value that was set from a previous note. You have to be careful not to initialize and overwrite values in these cases and instead to check previous values at init time and use them as the starting values for your code like linseg. Steven On Sat, Dec 19, 2020 at 1:34 PM Søren Jakobsen |
Date | 2020-12-19 20:48 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
Hi Steven! Thanks for the tip and for writing this article - I have actually seen the article before, and now I just tried to study the code a bit more:) If I understand your code correctly it seems to support a scenario which is a bit different from my example - your glissando instrument seems to record the final value of the line/lineseg from the previous note and uses that for the continuation. In my example however the note is cut off before the line(segment) finishes - the value at that point - whatever it may be - is the one I would like to continue from. If it were only possible to use k-rate variables for the linseg opcode I believe this would be very simple to implement. Søren On 12/19/20, Steven Yi |
Date | 2020-12-19 21:42 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
I just found the following 'solution'. To get the linseg value at a given time - with the 'i' function - I apparently need to use a second instrument. I wonder if there is not a less awkward way to do this? |
Date | 2020-12-20 08:19 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
Sorry to post again.. I just found that for actually tied events (csound doesn't seem to treat note off events as tied) I can do the following. For some reason (?) however I'm hearing a click when the tied note sets in. |
Date | 2020-12-20 09:32 |
From | Eduardo Moguillansky |
Subject | Re: [Csnd] Line segments between tied notes |
I have this example regarding tied notes from a course I gave, it ties both amplitude and pitch, but the same can be used for many other things: <CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> sr = 44100 ksmps = 64 nchnls = 2 0dbfs = 1 instr 1 idur = abs(p3) iamp = p4 ipitch = p5 itie tival if itie == 0 && p3 < 0 then ; start note ioldamp = 0 ioldpitch = ipitch endif aamp cosseg ioldamp, idur, iamp kpitch linseg ioldpitch, idur, ipitch asig oscili aamp, mtof(kpitch), -1, -1 outch 1, asig ioldpitch = ipitch ioldamp = iamp endin </CsInstruments> <CsScore> i 1.1 0 -2 0.4 66 i 1.1 2 -2 0.4 67 i 1.1 4 2 0 67 i 1.2 0 -2 0.4 60 i 1.2 2 -2 0.4 59 i 1.2 4 -2 0 59 f 0 10 </CsScore> </CsoundSynthesizer> On 20.12.20 09:19, Søren Jakobsen
wrote:
Sorry to post again.. I just found that for actually tied events (csound doesn't seem to treat note off events as tied) I can do the following. For some reason (?) however I'm hearing a click when the tied note sets in. <CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr=44100 ksmps=32 nchnls=1 0dbfs=1 gka init 0.0 instr 1 gka linseg i(gka), 2, 1 asig poscil3 interp(gka, 0, 1), 300 outs asig endin </CsInstruments> <CsScore> i 1 0 -1 i 1 1 -1 e 2 </CsScore> </CsoundSynthesizer> On 12/19/20, Søren Jakobsen <sorenkj@gmail.com> wrote:I just found the following 'solution'. To get the linseg value at a given time - with the 'i' function - I apparently need to use a second instrument. I wonder if there is not a less awkward way to do this? <CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr=44100 ksmps=32 nchnls=1 0dbfs=1 gidur init 1 gka init 0.0 gkoff init 0 instr 1 cggoto (gkoff == 1), skip gka linseg 0, 2, 1 skip: asig poscil3 gka, 300 outs asig endin instr 2 ia = i(gka) gkoff = 1 gka linseg ia, gidur, 0 endin </CsInstruments> <CsScore> i 1 0 -1 i 2 0.5 1 e 2 </CsScore> </CsoundSynthesizer> On 12/19/20, Søren Jakobsen <sorenkj@gmail.com> wrote:Hi Steven! Thanks for the tip and for writing this article - I have actually seen the article before, and now I just tried to study the code a bit more:) If I understand your code correctly it seems to support a scenario which is a bit different from my example - your glissando instrument seems to record the final value of the line/lineseg from the previous note and uses that for the continuation. In my example however the note is cut off before the line(segment) finishes - the value at that point - whatever it may be - is the one I would like to continue from. If it were only possible to use k-rate variables for the linseg opcode I believe this would be very simple to implement. Søren On 12/19/20, Steven Yi <stevenyi@gmail.com> wrote:Hi Søren, Maybe this article I wrote a long while ago will be useful: https://csoundjournal.com/2005fall/tiedNotes.html It can be a little tricky with tied notes if you want to grab the current value that was set from a previous note. You have to be careful not to initialize and overwrite values in these cases and instead to check previous values at init time and use them as the starting values for your code like linseg. Steven On Sat, Dec 19, 2020 at 1:34 PM Søren Jakobsen <sorenkj@gmail.com> wrote:Hello! Can someone tell me the 'correct' way to continue line segments between tied notes - perhaps also explain me why the linseg opcode only takes i-rate parameters? I am looking for a dynamic way to cut short ongoing line segments and continue them with other line segments, e.g. to make a release on note off events: <CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr=44100 ksmps=32 nchnls=1 0dbfs=1 gidur init 1 instr 1 xtratim gidur ka init 0.0 krel release if (krel == 1) then ka linseg 1, gidur, 0 ;instead of '1' I would have liked to use ka (so the value does not jump from 0.5 to 1) else ka linseg 0, 2, 1 endif asig poscil3 ka, 300 outs asig endin </CsInstruments> <CsScore> i 1 0 -1 i -1 1 e 2 </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 hereCsound 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 hereCsound 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 |
Date | 2020-12-20 09:36 |
From | thorin kerr |
Subject | Re: [Csnd] Line segments between tied notes |
Eduardo beat me to it. Was going to say tival might be your missing ingredient. e.g. this version won't click, because the 'itied' value on the tied note, can be used to skip the initialisation of the poscile opcode. instr 1 itied tival gka linseg i(gka), 2, 1 asig poscil3 interp(gka, 0, 1), 300, -1, -itied outs asig, asig endin Thorin On Sun, Dec 20, 2020 at 6:19 PM Søren Jakobsen <sorenkj@gmail.com> wrote: Sorry to post again.. I just found that for actually tied events |
Date | 2020-12-20 11:13 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
Thank you Eduardo and Thorin. Thorin's 'trick' solved my issue with tied notes! Now I just still have the issue with note off events - I was hoping it could be solved as follows, but for some reason (?) the 'i' function does not return the current envelope value on note off events (unlike with tied note events). |
Date | 2020-12-20 12:06 |
From | Eduardo Moguillansky |
Subject | Re: [Csnd] Line segments between tied notes |
The "note off" event, as you call it, is the last event in a tied note chain. One of the pargs should be amplitude. To stop the note you would create a last score statement which ramps the amplitude to 0 (this last event should have a duration > 0) On 20.12.20 12:13, Søren Jakobsen wrote: > Thank you Eduardo and Thorin. Thorin's 'trick' solved my issue with tied notes! > > Now I just still have the issue with note off events - I was hoping it > could be solved as follows, but for some reason (?) the 'i' function > does not return the current envelope value on note off events (unlike > with tied note events). > > |
Date | 2020-12-20 12:21 |
From | thorin kerr |
Subject | Re: [Csnd] Line segments between tied notes |
Not sure your approach is going to work with linsegs. I think i(gka) is always going to pick up the value of gka when the instrument is initialised (i.e. the value when the instrument starts). There's an opcode by Joachim Heintz from the CsUDO database called Linek, which accepts krate arguments.Not sure this would help... but for ties, envelopes and releases, here's an approach I use. This uses a UDO called 'declickr', which observes ties but adds a release envelope. <CsoundSynthesizer> <CsOptions> -o dac </CsOptions> <CsInstruments> sr=44100 ksmps=32 nchnls=1 0dbfs=1 gka init 0.0 ;declicks attacks and decays. ;Doesn't interrupt tied notes. ;Adds a release envelope. opcode declickr, a, ajjoj itie tival ain, irisetime, idectime, itype,iinvert xin irisetm = (irisetime == -1 ? 0.003 : irisetime) idectm = (idectime == -1 ? 0.08 : idectime) if (iinvert != -1) then aenv1 transegr itie, 0.003, 0, 1, irisetm, -itype, iinvert, 0,0,iinvert,idectm, itype, 1 aenv2 linseg 1, abs(p3)+idectm-0.004, 1, 0.004,(p3 < 0 ? 1:0);transegr 1,0,0,1,0.08,0,0 aenv = aenv2 * aenv1 else aenv transegr itie, irisetm, itype, 1, 0, 0, 1, idectm, itype, 0 endif xout ain * aenv ; apply envelope and write output endop instr 1 itied tival gka linseg i(gka), 2, 1 asig poscil3 interp(gka, 0, 1), 300, -1, -itied asig declickr asig, 0.001, 1.7 ; 1.7 second 'release'. outs asig endin </CsInstruments> <CsScore> i 1 0 -1 i 1 1 1 e 4 </CsScore> </CsoundSynthesizer> On Sun, Dec 20, 2020 at 9:13 PM Søren Jakobsen <sorenkj@gmail.com> wrote: Thank you Eduardo and Thorin. Thorin's 'trick' solved my issue with tied notes! |
Date | 2020-12-20 12:25 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
I'm afraid you misunderstand my problem - in my case the amplitude of the signal is not known at the time the note is turned off (so can also not be specified as a parameter). Also, the note off event apparently does not trigger an i-time pass, so it can not be handled as a tied note (using tival opcode). On 12/20/20, Eduardo Moguillansky |
Date | 2020-12-20 14:34 |
From | Søren Jakobsen |
Subject | Re: [Csnd] Line segments between tied notes |
Great, transegr/linsegr is indeed the solution! Now both ties and note offs are handled neatly:) I am still hearing some very small clicks but I think that must be an issue with my soundcard.. |