Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!rex!wuarchive!uunet!rosie!sstreep From: sstreep@next.com (Sam Streeper) Newsgroups: comp.sys.atari.st.tech Subject: Re: MIDI input problems (C or assembler programming) Message-ID: <250@rosie.NeXT.COM> Date: 6 Feb 91 19:26:36 GMT References: <3901@ryn.mro4.dec.com> Sender: news@NeXT.COM Organization: Next Computer, Inc. Lines: 40 Nntp-Posting-Host: elvis.next.com In article <3901@ryn.mro4.dec.com> miskinis@aisg.enet.dec.com (John Miskinis) writes: > > I hit the books, bought Mark Williams C, and wrote an interrupt >routine that duplicates that the standard MIDI input code, but I write the >bytes to MY buffer, and time-stamp each byte when it comes in. You really must write your midi interrupt handler in assembler. Fortunately this handler is pretty simple. The standard Atari interrupt handler is actually pretty good, but you can optimize it slightly. For an example of the source to the standard handler, see the Abacus Internals book. The default buffer is much too small (128 bytes, I think). With a good handler, a decent size buffer, and a good cable (most are crappy), you shouldn't lose any data. > This method allows application freedom, as MIDI input will happen in >the background. BUT I STILL LOSE DATA WHEN I MOVE THE MOUSE... This is true and it sucks big time! The problem here is that the keyboard/mouse ACIA and the midi ACIA interrupt at the same level to the MFP 68901. Also, the mouse packet parsing code is just too slow. If you blast the midi port at full speed and move the mouse, its possible that 2 midi characters will come in while you're parsing a mouse packet, and BOOM! you lost the first one, since the hardware only buffers one character. The midi handler cannot preempt the (slow) mouse handler, and this is a hardware architecture problem. The solution of course is to rewrite the mouse/keyboard handler, which is pretty difficult, especially if you want to maintain compatibility with the way the OS expects to find things. If you're writing a standalone sequencer, this really isn't a problem, but for joe average it's difficult. If you roll your own sequencer without the mouse handler, just _don't_move_ the_mouse_ (!) during critical times! (1/2 8^)) I hope this helps... Every profession sequencer writer has had to deal with this. -sam (sam_s@NeXT.com)