ihold and graceful turnoff of fractional instruments
Date | 2017-03-27 14:22 |
From | Forrest Curo |
Subject | ihold and graceful turnoff of fractional instruments |
I'm using fractional instrument numbers, and ihold for instances triggered by different midi-keyboard notes no problem unless I hit that same key before the note has quite reached bottom.I want to gently ramp each instance down as its key is released -- turnoff at zero amplitude. And then? -- The new note replaces the one that's been decaying? Can I let the two instances briefly co-exist? Forrest Curo San Diego |
Date | 2017-03-27 15:24 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Better question: How do tigoto and tival apply to notes sustained by ihold? On Mon, Mar 27, 2017 at 6:22 AM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-03-27 16:44 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Or: Is it better to just use negative p3 throughout, no ihold in the first place, turnoff when envelope -->0 ? On Mon, Mar 27, 2017 at 7:24 AM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-03-29 07:26 |
From | Oeyvind Brandtsegg |
Subject | Re: ihold and graceful turnoff of fractional instruments |
If you use negative p3, and then turn off when a note off is received, and use a release stage envelope, (you probably do all of the above already?), *and* make the envelope start from the value it previously left off at (see below), then you should get smooth transition between notes. The one thing you won't get is overlapping instances if it is retriggered before it has completed the release. But the new instance will pick up smoothly and take over from the releasing segment. If you really want overlapping instances upon re-trig, you will need to use a counter in addition to the note number to find your fractional instr numbers. For example: instr num 2, note number 69, would in your care be p1= 2.069 (right?), then you could use an additional counter looping from 0 to 9, so the first time the instr is triggered you have p1 = 2.0690, the second time it will be 2.0691, then 2.0692 etc. It will be a bit of a pain to ensure you turn off the correct instance at all times, as far as I remember, having done this some time in the past (don't have the details in front of me any longer, sorry) In the simpler case, if you are content with making a smooth take-over when the note is re-triggered, you can write the current value if the envelope to a chn channel, and then read this value at init, starting the envelope from that value. (code untested, just writing off the top of my head, beware of typos) istart chnget "amp" iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linsegr istart, iattacktime, 1.0, idectime, isustainlevel, 1, isustainlevel, ireleasetime chnset kenv, "amp" Instead of the simple name "amp" you would need to use a channel name indicating the instance (fractional instr num). Something like: i_nstance = int(frac(p1)*1000) Sname sprintf "amp_%i", i_nstance istart chnget Sname Oeyvind 2017-03-27 8:44 GMT-07:00 Forrest Curo <treegestalt@gmail.com>:
Oeyvind Brandtsegg Professor of Music Technology NTNU 7491 Trondheim Norway Cell: +47 92 203 205 http://www.partikkelaudio.com/ http://crossadaptive.hf.ntnu.no http://gdsp.hf.ntnu.no/ http://soundcloud.com/brandtsegg http://flyndresang.no/ http://soundcloud.com/t-emp |
Date | 2017-03-29 13:41 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Thanks! (I'd been temporarily overwhelmed with this poem busting loose, internet fuss&bother, emotional overwhelm.)I maybe shouldn't have waited for an answer,but yours covers it quite thoroughly. On Tue, Mar 28, 2017 at 11:26 PM, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote:
|
Date | 2017-03-29 22:18 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
This is a question to be explored for me, not trivial. For now, testing EXAMPLE 07B01_MidiInstrTrigger.csd of floss manual, I discovered today that for good performance it is needed this McCurdy indication (in 3_monoSynth.csd): instr 128 Best A.S. Il 29/03/2017 14:41, Forrest Curo ha
scritto:
|
Date | 2017-03-31 23:30 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Like this (_no_ iholds)? San Diego-------------
tigoto secondtime
secondtime:
endit:
makenoise:
if (kmp != 0) kgoto outmit; On Wed, Mar 29, 2017 at 2:18 PM, Andrea Strappa <a_strappa@tin.it> wrote:
|
Date | 2017-03-31 23:41 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Ow! Is linseg's first output its starting value? -- or does it begin with the next point along the line? (If kmp starts at zero, this thing will always begin by shutting itself off.)On Fri, Mar 31, 2017 at 3:30 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-01 13:06 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
'initmp = kmp' it's no good. Perhaps did you mean write 'initmp = i(kmp)'? Would you send an essential-full-well-running csd? A.S. Il 01/04/2017 00:41, Forrest Curo ha scritto: > initmp = kmp 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 |
Date | 2017-04-01 14:02 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
It really is no good. Will send a working csd soon, I hope!I did a simple test of what happens when you print out the values, ran into the bug you found & fixed it the same way, then found out that yes, if if the lineseg starts from 0 that will certainly be the first value generated. On Sat, Apr 1, 2017 at 5:06 AM, Andrea Strappa <a_strappa@tin.it> wrote: 'initmp = kmp' |
Date | 2017-04-01 19:58 |
From | Oeyvind Brandtsegg |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Perhaps I misunderstand something, but isn't this a variation on: istart chnget "amp" iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linsegr istart, iattacktime, 1.0, idectime, isustainlevel, 1, isustainlevel, ireleasetime chnset kenv, "amp" ... which in many ways could be a simpler approach And, yes, linseg starts from the value set in the first argument. So, in the example stated here, it will start from the value the "(same) envelope reached during the previous instance. If the release was interrupted, it will start from wherever it left off. If it was allowed to reach zero and turn off, then the next envelope will start from zero. 2017-04-01 6:02 GMT-07:00 Forrest Curo <treegestalt@gmail.com>:
Oeyvind Brandtsegg Professor of Music Technology NTNU 7491 Trondheim Norway Cell: +47 92 203 205 http://www.partikkelaudio.com/ http://crossadaptive.hf.ntnu.no http://gdsp.hf.ntnu.no/ http://soundcloud.com/brandtsegg http://flyndresang.no/ http://soundcloud.com/t-emp |
Date | 2017-04-01 21:05 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Looks like. (The only thing not working in what I considered the simpler approach has been something in my logic not properly keeping the last value of kenv between changes. Since I end up retriggering the note when I release the midi key, my mistake is producing a nice effect!) On Sat, Apr 1, 2017 at 11:58 AM, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote:
|
Date | 2017-04-01 21:48 |
From | Oeyvind Brandtsegg |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Yes, it may be doable without the chngets, but I find them a convenient way to hold a "global" value in this case. To do it without chngets, you probably would go into the tie-reinit things you use in your approach. But I'm not so familiar with them. 2017-04-01 13:05 GMT-07:00 Forrest Curo <treegestalt@gmail.com>:
Oeyvind Brandtsegg Professor of Music Technology NTNU 7491 Trondheim Norway Cell: +47 92 203 205 http://www.partikkelaudio.com/ http://crossadaptive.hf.ntnu.no http://gdsp.hf.ntnu.no/ http://soundcloud.com/brandtsegg http://flyndresang.no/ http://soundcloud.com/t-emp |
Date | 2017-04-01 23:38 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Me either. I wouldn't have thought that approach would be simpler, but there it is! So the chngets aren't really connecting to anything outside the instrument, just connecting the end to the beginning to make that value available on the next i pass... On Sat, Apr 1, 2017 at 1:48 PM, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote:
|
Date | 2017-04-02 12:44 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Yesterday I found this solution: ;----------------sustain pedal - solution for beat again notes
(different invocations of instrument)
------------------------------------ You have to insert this snippet in EXAMPLE 07B04_MidiMultiTrigg.csd (Floss manual, example by Joachim Heintz, using code of Victor Lazzarini ). Probably there are better solutions (with loop_lt or phasor...). I began to explore loop_lt, but I have impression that in the manual the variables are mistaked. What do you think? All the best Andrea S.
Il 02/04/2017 00:38, Forrest Curo ha
scritto:
|
Date | 2017-04-02 22:59 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
My use of Oeyvind's example is working, and thus I've got a working chunk of csd for Andrea S (You will need to put in your own midi configuration [or Csound API program, as I'm using] to call instr 3 with fractional p1 and may well want a less eccentric choice for a sound-generating opcode) ---------- instr 3; p4 velocity, p5 frequency, p6 preset # ; Call this one with p3 == -1 for all notes i_nstance = p1; Oeyvind had int(frac(p1)*1000) Sname sprintf "amp%f", i_nstance istart chnget Sname iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linsegr istart, iattacktime, 1.0, idectime, isustainlevel, 1, ireleasetime chnset kenv, Sname ivel = p4 kimp = ivel *.000001 ;This value is 'VOLUME CONTROL' impy = 65; inote = 60 kifr = p5 ipre = p6 aoutl,aoutr sfplay3 impy,inote, kimp,kifr,ipre, 1 outs kenv*aoutl, kenv*aoutr endin On Sun, Apr 2, 2017 at 4:44 AM, Andrea Strappa <a_strappa@tin.it> wrote:
|
Date | 2017-04-03 05:49 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
It really does need to use to set the channel name to something it can dependably recognize when the triggering key is raised.i_nstance = int(frac(p1)*1000) Sname sprintf "amp%i", i_nstance On Sun, Apr 2, 2017 at 2:59 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-03 20:49 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
sfplay opcode in my example is probably the problem; Forrest CuroI expect it would reinitialize when the noteoff-or-velocity=0 note tried to tie in. On Sun, Apr 2, 2017 at 9:49 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-03 21:51 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Yes, I eliminate the click -- but also the noteoff, alas by putting tigoto bypass ... " The envelope, if I'm sending noteon/note-offs via Csound API, doesn't know it's been released. On Mon, Apr 3, 2017 at 12:49 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-03 22:14 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Fixed: (This triggers the release segment of the envelope from Oeyvind's envelope example, even though the sound-generating opcode it's applied to doesn't know anything's changed.): kvel = p4 if(kvel != 0) goto leaveon turnoff2 p1, 5, 1 leaveon: On Mon, Apr 3, 2017 at 1:51 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-03 22:32 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Attachments | release_with_sustain_03.csd |
I send my solution to avoid click on repercussion same note with sustain pedal, adapting Victor Lazzarini and Joachim Heintz example (thank you!). At last it appears the message: "WARNING: MIDI note overlaps with
key ... on same channel" (I hope it is not serious). About your example, Forrest, I not addressed yet to API connections. Or you adapt it to a canonical csound front end, or you send me same instruction for api connection, because i'm willing to study it. A. S.
Il 03/04/2017 22:51, Forrest Curo ha
scritto:
|
Date | 2017-04-04 00:07 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Andrea, I've been getting the csd I had to work, not yet up to making one someone else could use. [Sorry! I'm not that good at this! Will try.] Starting with someone else's example... from Floss manual [then adding another instrument to use that]:An instrument with volume controlled by Oeyvind's envelope should do it if you add a reasonable oscillator. (Mine was unreasonable. Let's see, hope this works): ---------------- <CsoundSynthesizer> <CsOptions> -+rtmidi=portmidi -Ma -odac </CsOptions> <CsInstruments> ;Example by Andrés Cabrera sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 massign 0, 1 ;assign all MIDI channels to instrument 1 ; and the key to call fractional numbered instrument iCps cpsmidi ;get the frequency from the key pressed iAmp ampmidi 0dbfs * 0.3 ;get the amplitude turnoff endin instr 2 i_nstance = int(frac(p1)*1000) Sname sprintf "amp_%i", i_nstance istart chnget Sname ; (is 0 until chnset inserts a value) iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linesegr istart, iattacktime, 1.0, idectime, isustainlevel, ireleasetime, 0 chnset kenv, "amp"; (send new value back for next note of same number) ;back to original example except using the envelope aOut poscil iAmp, iCps ;generate a sine tone aOut = aOut* kenv------------ ? I have not yet tested this... On Mon, Apr 3, 2017 at 2:32 PM, Andrea Strappa <a_strappa@tin.it> wrote:
|
Date | 2017-04-04 00:14 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
linsegr -- NOT "linesegr" On Mon, Apr 3, 2017 at 4:07 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-04 01:09 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
That will NOT work, even when debugged -- if your keyboard sends a real "note off" message instead of the old "note on with velocity zero" equivalent. What I kludged to deal with that -- should work (and does, in a limited way) but I'm losing notes with this.<CsoundSynthesizer> <CsOptions> -+rtmidi=portmidi -Ma -odac </CsOptions> <CsInstruments> ;from Example by Andrés Cabrera sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 massign 0, 1 ;assign all MIDI channels to instrument 1 instr 1 ;NOW I'M ADDING A TIED NOTE INSTRUMENT: kplay init 1 ikey =0 ivelocity = 0 midinoteonkey ikey, ivelocity ; we need velocity to detect note-offs ; and the key to call fractional numbered instrument iCps cpsmidi ;get the frequency from the key pressed iAmp ampmidi 0dbfs * 0.3 ;get the amplitude instrum = (2000 + ikey)/1000 if (kplay == 0) kgoto playednote event "i", instrum, 0, -1, ivelocity, ikey, iCps, iAmp printf "velocity is %i \n", 1, ivelocity kplay =0 playednote: krel release if (krel != 1) kgoto keepon ;if in release-stage stay in release section event "i", instrum, 0, -1, 0, ikey, iCps, iAmp turnoff keepon: endin instr 2 iCps = p6; (was set by instrument 1 from midi note) iAmp = p7 ;NOW OEYVIND's CODE FOR ENVELOPE i_nstance = int(frac(p1)*1000) Sname sprintf "amp_%i", i_nstance istart chnget Sname ; (is 0 until chnset inserts a value) iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linsegr istart, iattacktime, 1.0, idectime, isustainlevel, ireleasetime, 0 chnset kenv, "amp"; (send new value back for next note of same number) bypass: kvel = p4 if(kvel != 0) goto leaveon turnoff2 p1, 5, 1 kvel =1 leaveon: ;back to original example except using the envelope aOut poscil iAmp, iCps ;generate a sine tone aOut = aOut* kenv outs aOut, aOut ;write it to the output endin </CsInstruments> <CsScore> </CsScore> </CsoundSynthesizer> On Mon, Apr 3, 2017 at 4:14 PM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2017-04-04 08:41 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
I'll test it in the next few days. Soon, I hope. I have some task now. A. S. Il 04/04/2017 01:14, Forrest Curo ha
scritto:
|
Date | 2017-04-04 08:50 |
From | Andrea Strappa |
Subject | Re: ihold and graceful turnoff of fractional instruments |
I remember that in McCurdy arpeggiator.csd there's a device for this. Here:
You can try it. I can't today. Perhaps someone of csound gurus
will help us... A. S.
Il 04/04/2017 02:09, Forrest Curo ha
scritto:
|
Date | 2017-04-04 14:17 |
From | Forrest Curo |
Subject | Re: ihold and graceful turnoff of fractional instruments |
Oeyvind took a look and fixed it "(but it is late, so I might be wrong)" and now I've fixed what he'd missed while tired------------- <CsoundSynthesizer> <CsOptions> -+rtmidi=portmidi -Ma -odac </CsOptions> <CsInstruments> ;from Example by Andrés Cabrera sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 massign 0, 1 ;assign all MIDI channels to instrument 1 instr 1 ikey =0 ivelocity = 0 iCps cpsmidi ;get the frequency from the key pressed iAmp ampmidi 0dbfs * 0.3 ;get the amplitude ; we'll need this to call fractional numbered instrument midinoteonkey ikey, ivelocity instrum = (2000 + ikey)/1000 event_i "i", instrum, 0, -1, iAmp , iCps xtratim 1/kr krelease release if krelease > 0 then event "i", -instrum, 0, 0.1, iAmp , iCps endif endin instr 2 iAmp = p4; (was set by instrument 1 from midi note) iCps = p5 ;NOW OEYVIND's CODE FOR ENVELOPE i_nstance = int(frac(p1)*1000) Sname sprintf "amp_%i", i_nstance istart chnget Sname ; (is 0 until chnset inserts a value) iattacktime = 0.1 idectime = 0.3 isustainlevel = 0.4 ireleasetime = 1.5 kenv linsegr istart, iattacktime, 1.0, idectime, isustainlevel, ireleasetime, 0 chnset kenv, "amp"; (send new value back for next note of same number) ;back to original midi example except using the envelope aOut poscil iAmp, iCps ;generate a sine tone aOut = aOut* kenv outs aOut, aOut ;write it to the output endin </CsInstruments> <CsScore> </CsScore> </CsoundSynthesizer> On Tue, Apr 4, 2017 at 12:50 AM, Andrea Strappa <a_strappa@tin.it> wrote:
|