[Csnd] trying to catch midi events
Date | 2013-02-17 20:23 |
From | zappfinger |
Subject | [Csnd] trying to catch midi events |
Following code does not always do what I expect. This is part of a .csd file that plays a midi file, and I am trying to catch all note-on and note-off events as they are played. They are then sent via OSC to a python program that animates the notes in a keyboard (tkinter). Somehow not all notes are detected, specially when the same note is played in sequence. Strange thing is, the printks does not miss any notes (on or off).. kst, kch, kd1, kd2 midiin ktrigger changed kst, kch, kd1, kd2 ;trigger if midi data changes if ktrigger=1&&kst!=0 then ;if status byte is non-zero... printks "status:%d%tchannel:%d%tdata1:%d%tdata2:%d%n",0,kst,kch,kd1,kd2 if (kst == 144) && (kd2!=0) then ; note on? OSCsend (kst|kd1|kd2), "localhost",9000, "/non", "i", kd1 endif if (kst == 128) || ((kst==144) && (kd2==0)) then ; note off? OSCsend (kst|kd1|kd2), "localhost",9000, "/nof", "i", kd1 endif endif Richard -- View this message in context: http://csound.1045644.n5.nabble.com/trying-to-catch-midi-events-tp5720156.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-02-17 21:38 |
From | Tarmo Johannes |
Subject | Re: [Csnd] trying to catch midi events |
Hello,
My guess is that the problem is in the first parameter of OSCsend: > OSCsend (kst|kd1|kd2), ...
The message is sent only if the value is positive AND has changed (I don't know, why it is implemented like that). It seems likely taht if you play many same notes in a row, the value stays the same? You could replace it with any changing value, even like
ktime timek OSCsend ktime, "localhost",9000, "/non", "i", kd1
Not 100% sure, if it helps, nut please give a try!
greetings, tarmo
|
Date | 2013-02-17 22:17 |
From | zappfinger |
Subject | [Csnd] Re: trying to catch midi events |
Tarmo, Your suggestion was spot on! Thanks! Richard -- View this message in context: http://csound.1045644.n5.nabble.com/trying-to-catch-midi-events-tp5720156p5720158.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-02-19 21:21 |
From | zappfinger |
Subject | [Csnd] Re: trying to catch midi events |
This is more complicated than I thought. When I play chords, the note on and offs can be very close, so I do miss events then, although they are not missed by fluidsynth - I can hear them. If I raise kr things get better obviously, but still notes are missed. Is this a limitation of OSC? Is it possible to catch midi events with the API better? Richard -- View this message in context: http://csound.1045644.n5.nabble.com/trying-to-catch-midi-events-tp5720156p5720216.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-02-19 21:36 |
From | Justin Smith |
Subject | Re: [Csnd] Re: trying to catch midi events |
you need to loop back and repeat midiin until kstatus is 0, because it is possible for two messages to come in one k cycle and if you don't read them they are just gone so wrap the midiin / oscsend in
readmidi: ... ... if (kstatus != 0) kgoto readmidi also, do not check if status is changed, you only need to verify it is non 0 (you are dropping data you should be processing if two consecutive messages had the same bits)
On Tue, Feb 19, 2013 at 1:21 PM, zappfinger <zappfinger@gmail.com> wrote: This is more complicated than I thought. |
Date | 2013-02-19 21:37 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Re: trying to catch midi events |
If you send us a CSD and a midi file for testing, we can try to suggest solutions. On 19 Feb 2013, at 21:21, zappfinger wrote: > This is more complicated than I thought. > When I play chords, the note on and offs can be very close, so I do miss > events then, although they are not missed by fluidsynth - I can hear them. > If I raise kr things get better obviously, but still notes are missed. > > Is this a limitation of OSC? Is it possible to catch midi events with the > API better? > > > Richard > > > > -- > View this message in context: http://csound.1045644.n5.nabble.com/trying-to-catch-midi-events-tp5720156p5720216.html > Sent from the Csound - General mailing list archive at Nabble.com. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |