| I have not used the midiin opode, but if I had, I would expect it to
be called in a loop until kstatus is zero. That would enable any
number of pending messages to be pulled from the buffer. This would be
in keeping with the MIDI protocol, whereas having only one MIDI
message per kperiod would not be sufficient to handle the protocol,
which supports multiple simultaneous messages.
When I examine the source code for midiin, that is indeed what it
appears to be doing.
So, I suggest you set up a loop in your instrument and read MIDI
events using midiin until midiin returns a status of 0, something like
this:
kstatus init 0
top_of_loop:
kstatus, kchan, kdata1, kdata2 midiin
if (kstatus == 144) then
printks "kstatus= %d, kchan = %d, note# = %d, velocity = %d\\n", 0,
kstatus, kchan, kdata1, kdata2
midiout kstatus, kchan, kdata1, kdata2
endif
if kstatus != 0 kgoto top_of_loop
No guarantee that this works, but let us know if it does!
Hope this helps,
Mike
On Sun, Jun 6, 2010 at 10:22 PM, Jim Aikin wrote:
>
> I'm using QuteCsound 0.5 and Csound 5.11 under Windows 7. I'm attempting to
> use Csound for real-time MIDI event processing, but what I'm finding in my
> preliminary tests is that the midiin opcode is not buffering and releasing
> the messages in the way that I would expect or hope that it would.
>
> I'm getting stuck notes. Lots of them.
>
> What I would expect or hope would be that on each k-cycle, midiin would
> divest itself of one complete MIDI message. But I'm getting extra note-ons
> when I play chords. Perhaps someone can suggest a workaround (other than,
> "Use Max for this").
>
> For starters, here's the .csd I'm using:
>
>
>
>
>
>
> sr = 88200
> ksmps = 1
> nchnls = 1
>
> instr 101
> kstatus init 0
>
> kstatus, kchan, kdata1, kdata2 midiin
>
> if (kstatus == 144) then
> printks "kstatus= %d, kchan = %d, note# = %d, velocity = %d\\n", 0,
> kstatus, kchan, kdata1, kdata2
> midiout kstatus, kchan, kdata1, kdata2
> endif
>
> endin
>
>
>
> i 101 0 60
> e
>
>
>
> As long as I play single, separated notes on the keyboard, this works fine.
> But chords cause midiin to freak out. Here's the output when I run this.
> First I'm playing C-E-G as individual notes, and then I play C-E-G as a
> chord, starting all three notes at more or less the same time:
>
> SECTION 1:
> new alloc for instr 101:
> rtevent: T 1.556 TT 1.556 M: 0.0
> new alloc for instr 101:
> kstatus= 144, kchan = 1, note# = 60, velocity = 52
> rtevent: T 1.860 TT 1.860 M: 0.0
> kstatus= 144, kchan = 1, note# = 60, velocity = 0
> rtevent: T 2.229 TT 2.229 M: 0.0
> kstatus= 144, kchan = 1, note# = 64, velocity = 62
> rtevent: T 2.564 TT 2.564 M: 0.0
> kstatus= 144, kchan = 1, note# = 64, velocity = 0
> rtevent: T 2.924 TT 2.924 M: 0.0
> kstatus= 144, kchan = 1, note# = 67, velocity = 62
> rtevent: T 3.241 TT 3.241 M: 0.0
> kstatus= 144, kchan = 1, note# = 67, velocity = 0
> rtevent: T 4.574 TT 4.574 M: 0.0
> rtevent: T 4.574 TT 4.574 M: 0.0
> new alloc for instr 101:
> rtevent: T 4.574 TT 4.574 M: 0.0
> new alloc for instr 101:
> kstatus= 144, kchan = 1, note# = 60, velocity = 56
> kstatus= 144, kchan = 1, note# = 64, velocity = 56
> kstatus= 144, kchan = 1, note# = 67, velocity = 54
> kstatus= 144, kchan = 1, note# = 64, velocity = 56
> kstatus= 144, kchan = 1, note# = 67, velocity = 54
> kstatus= 144, kchan = 1, note# = 67, velocity = 54
> rtevent: T 5.016 TT 5.016 M: 0.0
> kstatus= 144, kchan = 1, note# = 64, velocity = 0
> kstatus= 144, kchan = 1, note# = 60, velocity = 0
> kstatus= 144, kchan = 1, note# = 67, velocity = 0
> inactive allocs returned to freespace
> end of score. overall amps: 0.0
>
> As you can see, when I play the three-note chord, note 64 is triggered twice
> and note 67 three times. Yet when I lift my fingers (the Yamaha keyboard is
> presumably transmitting note-offs as note-ons with velocity of 0), the notes
> are only stopped once.
>
> This could be a problem with how midiin interprets running status (though I
> don't know that the Yamaha is using running status -- that's just a guess),
> or it could just be a side effect of how midiin deals with stuff that's in
> its buffer.
>
> Is there any way for me to work around this problem? Thanks for any
> suggestions!
>
> --Jim Aikin
>
> P.S.: I'm testing this by getting an input from an M-Audio Firewire 410's
> MIDI driver and outputting to MIDI Yoke 1. Cubase is then using MIDI Yoke 1
> as its MIDI input. This should not be a source of problems, I'm just
> documenting it here to be thorough.
> --
> View this message in context: http://old.nabble.com/MIDI-buffer-reading-tp28800403p28800403.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"
>
>
--
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot 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"
|