minus p3 in event events?
Date | 2015-05-15 19:32 |
From | Forrest Curo |
Subject | minus p3 in event events? |
Attachments | None None |
I'm noticing that if I put a negative duration ['== held note'] in the score it's working, while with the same numbers for the same instrument, in an event line this poops out before one k-cycle. If I use '-2' in place of '60' here the instrument lasts long enough to print i-values, no longer:kp = 3 + knote/1000 if (kvel ==0 ) then kplaying[knote] = 0 turnoff2 kp, 4, 1 goto midictr elseif (kplaying[knote] !=0) then event "i", -kp, 0, 60, kvel, kquot, kmod endif kplaying[knote] = 1 event "i", kp, 0, 60, kvel, kquot, kmod |
Date | 2015-05-15 20:39 |
From | "F. Silvain" |
Subject | Re: minus p3 in event events? |
Forrest Curo, May 15 2015: > I'm noticing that if I put a negative duration ['== held note'] in the > score it's working, while with the same numbers for the same instrument, in > an event line this poops out before one k-cycle. ... > event "i", -kp, 0, 60, kvel, kquot, kmod ... I noticed, that you put a negative p1 in that line, instead of a negative p3. I've done that just yesterday with something like: event_i "i", 2, 0, -1 I don't know, if it's the event_i instead of event, but certainly p3 is negative here. The result was as expected, instr 2 runs until it is killed. Did I understand and answer your question? Ta-ta ---- Ffanci * Homepage: https://freeshell.de/~silvain * Twitter: http://twitter.com/ffanci_silvain * GitHub: https://github.com/fsilvain ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Csound-users mailing list Csound-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/csound-users Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2015-05-15 21:33 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
I guess I should have commented and/or posted that better; the negative p1 comes in if kplaying[knote] isn't zero, that is: if that note isn't already playing. If it is, kplaying[knote] will have been set to one, and the negative p1 is to squash that before starting the new note with that last line, just after 'kplaying[knote]= 1.' I'm supposed to end at that last line if kvel isn't zero and knote isn't already playing; and that's the line that starts instrument 3 just long enough to print i-variables. On the next round, kstatus should be zero again [That's what printk 0, kstatus shows] and we shouldn't be anywhere near this code until I get a midi event with velocity zero. |
Date | 2015-05-15 22:17 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
The code below demonstrates that negative p3 works with event, as expected schedule 1, 0, 1 instr 1 k1 init 0 if k1 = 0 then event "i", 2, 0, -1 k1 = 1 endif endin instr 2 a1 rand 0dbfs/2 out a1 endin ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 15 May 2015, at 21:33, Forrest Curo |
Date | 2015-05-15 22:27 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
It seems to me it's worked properly whenever I've used it before, but not here: This same code works properly with '60' in the place of the '-2's [and that's long enough for a note...]kp = 3 + knote/1000 if (kvel ==0 ) then kplaying[knote] = 0 turnoff2 kp, 4, 1 goto midictr elseif (kplaying[knote] !=0) then event "i", -kp, 0, -2, kvel, kquot, kmod endif kplaying[knote] = 1 event "i", kp, 0, -2, kvel, kquot, kmod ------------------------------ ? On Fri, May 15, 2015 at 2:17 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: The code below demonstrates that negative p3 works with event, as expected |
Date | 2015-05-15 22:41 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
Maybe your control-flow is tricking you. Possibly (I have not seen the rest of the code), the elseif() branch is being used immediately in the next k-cycle. From what you describe the results are, it makes sense that this is happening. If you use p3=60, then the negative p1 will not kill the event. ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 15 May 2015, at 22:27, Forrest Curo |
Date | 2015-05-15 23:31 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
What am I missing about the way this code gets read?!!! ie, That should take us well past the code we're talking about... to make sure of it, kstatus gets specifically reset to zero at the end of the instrument's code -- & if I print its value on each k cycle I get 0, 0, 0, 144, 0, 0...What you say is what has to be happening! -- but in the next k cycle it's supposed to reach these lines when it first starts processing the calling instrument: kstatus, kchan, knote, kvel midiin if (kstatus != 144) then goto midictr Adding the following after those lines: printf "kstatus is %d \n", kkount, kstatus produces "kstatus is 144", as it should, when-&-only-when a key is pressed or raised. ------------ Something very weird would need to be happening to bypass that specified control flow? Anyway, yes, if it does somehow come back after that first k cycle it would kill the note with -p3 but not otherwise: ie Putting i 3 0 -60 50 5 5 i -3 .01 -60 50 5 5 into the score quickly kills the note while i 3 0 60 50 5 5 i -3 .01 60 50 5 5 just gives me: 'could not find playing instr 3.000000' On Fri, May 15, 2015 at 2:41 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: Maybe your control-flow is tricking you. Possibly (I have not seen the rest of the code), the |
Date | 2015-05-15 23:35 |
From | Kevin Welsh |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Perhaps try kgoto instead of goto? On May 15, 2015 6:33 PM, "Forrest Curo" <treegestalt@gmail.com> wrote:
|
Date | 2015-05-16 00:12 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
It has to be 'elseif' ! That particular construction is always very ambiguous (to me at least) as to which prior 'if then' it's going to attach to. Explicit 'goto's & labels -- no matter how much the purists deplore them -- are much easier to predict.On Fri, May 15, 2015 at 3:35 PM, Kevin Welsh <tgrey1@gmail.com> wrote:
|
Date | 2015-05-16 07:21 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Again, without seeing the whole instr, it is hard to tell. You can use printk or printk2 to debug the branching. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland
|
Date | 2015-05-16 15:12 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Finally! -- This time I see what's wrong but do need help re how to fix it!!! For that, it would have to be coming back and finding kstatus (from midiin) still 144, which the printk's show isn't happening... -- what you were saying earlier about 'the else-if branch is being used immediately in the next control cycle...' [Spooky!] ------------- The code that's the problem is probably:it ftgen 3, 0, 129, -7, 0, 129, 0 kplaying[] genarray 1, 129 copyf2array kplaying, it So what I need is how to do the 'genarray' exactly once. (I gather the copy2array is only happening in the init phase, as I'd intended.) On Fri, May 15, 2015 at 11:21 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2015-05-16 15:18 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
kplaying[] init 129 will create an array with 129 positions (btw why 129?). ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 16 May 2015, at 15:12, Forrest Curo |
Date | 2015-05-16 15:26 |
From | jpff |
Subject | Re: minus p3 in event events? |
Attachments | None None |
You need genarray_i On Sat, 16 May 2015, Forrest Curo wrote: > Finally! -- This time I see what's wrong but do need help re how to fix it!!! > > -- what you were saying earlier about 'the else-if branch is being used > immediately in the next control cycle...' > > For that, it would have to be coming back and finding kstatus (from midiin) > still 144, which the printk's show isn't happening... > > What I think is happening instead is that the array kplaying[] is getting > befnurgled each k cycle; it's going through both branches whenever a note is > played because kplaying[knote] always starts out '!= zero' > > and so the -p1 and the p1 are both being sent to the score. > > They're both going out on the same k cycle and the error message from the > lonesome -p1 doesn't get generated because somewhere in the processing it > finds its p1, once that's been initiated. > > [Spooky!] > ------------- > The code that's the problem is probably: > > it ftgen 3, 0, 129, -7, 0, 129, 0 > kplaying[] genarray 1, 129 > copyf2array kplaying, it > > So what I need is how to do the 'genarray' exactly once. (I gather the > copy2array is only happening in the init phase, as I'd intended.) > > On Fri, May 15, 2015 at 11:21 PM, Victor Lazzarini |
Date | 2015-05-16 16:13 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
129 so I could use 1-128 rather than all the time subtracting 1? It does work with a local array! (There'd been a hitch trying to use that with a global array, resulting in a one-element array; that's why I'd gone to 129 and used genarry...)How does "linsegr" feel about receiving a negative p3? (It's in instrument 3 -- I could have sent you all of instr 2 but doesn't that have to be what's messing this up?!!!) On Sat, May 16, 2015 at 7:18 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: kplaying[] init 129 |
Date | 2015-05-16 19:15 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Negative p3 continues to work in score; the code I've got continues to work only if p3 is positive within instrument lines.------------- <CsoundSynthesizer> <CsOptions> -+rtmidi=alsa -Mhw:4,0 -o dac:hw:2,0 ;--midifile=phew.mid -m 4 -L testfif ;--midi-key-cps=4 --midi-velocity-amp=5 </CsOptions> <CsInstruments> sr = 44100 ;SAMPLE RATE ksmps = 64 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL massign 0,0 gisf1 sfload "FluidR3_GM.sf2" sfplist gisf1 ;list presets of first soundfont girat[] array 1, 16/15, 9/8, 6/5, 5/4, 4/3, 45/32, 3/2, 8/5, 5/3, 9/5, 15/8 gimode[] array 0,2,4,5,7,9,11,0,2,3,5,7,8,11,0,2,3,5,7,9,10,0,3,4,5,8,9,10; major, minor, dorian,jazzy gkoff init 0 gitonic init 60 gkpreset init 46 instr 1; initialize soundfont index gi init 0 label: gir sfpreset gi,0,gisf1,gi gi = gi +1 if gi < 128 igoto label gi = 128 gir sfpreset 80,8,gisf1,gi ;150 Sine Wave: prog:80 bank:8 endin instr 2 ; receives midi signals and responds to note messages. ;it ftgen 3, 0, 129, -7, 0, 129, 0 kplaying[] init 129 ;kplaying[] genarray 1, 129 ;copyf2array kplaying, it icount = 0 iloop: kplaying[icount] init 0 icount += 1 if (icount < 128) igoto iloop imod init 0 kkount init 0 kstatus, kchan, knote, kvel midiin kkount += 1 if (kstatus != 144) then goto midictr endif kmod = knote % 12 kquot = int(knote /12) if ((kmod == 1)||(kmod == 3)||(kmod == 6)||(kmod == 8)||(kmod == 10)) then ;if it's a black key we'll use it as a control turnoff2 3, 1, 1 ; for now, to turn off the longest-unended note of instr 3 goto midictr ; since midi did not trigger instr 1, we don't need a turnoff here. endif kmod += 1 kmod = int(kmod/2) kp = 3 + knote/1000 if (kvel ==0 ) then kplaying[knote] = 0 turnoff2 kp, 4, 1 goto midictr endif kextra active kp if (kextra !=0) then; was 'if(kplaying knote] != 0' in which case didn't get here at all! & was still silent event "i", -kp, 0, 60, kvel, kquot, kmod printf "Here I am at %d \n", kkount, icount endif kplaying[knote] = 1 event "i", kp, 0, 60, kvel, kquot, kmod ;schedkwhen 1,0, 0, kp, 0, 60, kvel, kquot, kmod ; no difference with this but see score midictr: kstatus =0 endin instr 3; p4 velocity, p5 octave, p6 degree --plays notes called by instr 1 ivel = p4 ioct = p5 imod = p6 ioff = i(gkoff) inote = 12*ioct + gitonic - 60 idegree = gimode[imod +ioff] ifr = cpsmidinn(inote)*girat[idegree] inote += idegree kifr = ifr kimp = ivel *.000002 ;fprints "ins", "(%f, %f, %f, %f)\n",itim,iquot,imod,impy impy = 50;gicount; impy = int(impy/40)*35 ipre = i(gkpreset) ;print ifr, impy a1,a2 sfplay3 impy,inote, kimp,kifr,ipre, 1 aenv linsegr 0, .05, .5,.5,.1, 1, 0 ;envelope outs a1*aenv, a2*aenv endin instr 99 ; send midi input & audio output to files kstatus, kchan, kdata1, kdata2 midiin midiout kstatus, kchan, kdata1, kdata2 allL, allR monitor ;write the output of csound to an audio file ;to a wav file: 16 bits with header fout "4.wav", 14, allL, allR endin </CsInstruments> <CsScore> ;f1 0 32 7 0 7 0 ; will hold the joystick data f2 0 0 -23 "keymap.txt" i 1 0 1 i 2 0 3600 ;i 3.060 0 -60 50 5 0 ; When this line is included it plays i 99 1 3600 ;Recording Instrument </CsScore> </CsoundSynthesizer> On Sat, May 16, 2015 at 8:13 AM, Forrest Curo <treegestalt@gmail.com> wrote:
|
Date | 2015-05-16 19:41 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
Attachments | None None |
But we've already established this is nothing to do with negative p3 not working. The issue here is branching that us messed up. Maybe you need to redesign your instrument. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland
|
Date | 2015-05-16 21:36 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Not faulty branching because it isn't going through that branch -- & when I take out the kill-lines from that branch entirely, the note still dies -- but only if it's generated by instrument 2. shows up when the if-branch is triggered via 'active' but not when I base the test on kplaying[knote], and in either case the note dies with p3 = -60 & lives with 60. printf "Here I am at %d \n", kkount, icount There doesn't need to be anything in instrument 2 to kill it; but it seems to self-destruct when that's where it comes from. On Sat, May 16, 2015 at 11:41 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2015-05-16 22:34 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
Attachments | None None |
negative p3 is not the problem here, you are looking at the wrong place. It is best to clean up the code and try to think clearly what you want to achieve. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland
|
Date | 2015-05-16 22:46 |
From | Victor Lazzarini |
Subject | Re: minus p3 in event events? |
Attachments | None None |
turnoff2 could be killing the instances of instr 3 Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland
|
Date | 2015-05-16 23:23 |
From | Forrest Curo |
Subject | Re: minus p3 in event events? |
Attachments | None None |
Okay, you're clearly right because this instrument 2 works: instr 2 kkount init 1 kt times if(kt > 2* kkount) then kkount += 1 knote = kkount + 19 kquot = int(knote/7) kmod = knote % 7 printf "Here I am at %d \n", kkount, kkount kextra active 3 if (kextra != 0) then kkount += 1 printf "And here I am at %d \n", kkount, kkount event "i", -3, 0, -60, 50, kquot, kmod kkount -= 1 endif event "i", 3, 0, -60, 50,kquot, kmod endif endin and goes through the "And here I am at" branch every time after the first... On Sat, May 16, 2015 at 2:46 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|