12. MIDI INPMID$ With the command INPMID$ the internal Midi-buffer is read and at the same time cleared: dummy$=INPMID$ ! clear Midi-buffer You can find the buffer-address and the buffer-size with XBIOS 14 (Iorec): adr%=LPEEK(XBIOS(14,2)) size%=DPEEK(adr%+4) The default size of the Midi-buffer is only 128 bytes, but you can change the size of the buffer: ptr%=XBIOS(14,2) DIM buffer|(size%-1) ! new Midi-buffer LPOKE ptr%,VARPTR(buffer|(0)) ! start-address of new buffer DPOKE ptr%+4,size% ! size DPOKE ptr%+6,0 ! buffer-head DPOKE ptr%+8,0 ! buffer-tail DPOKE ptr%+10,0 ! low mark (not used) DPOKE ptr%+12,size%-1 ! high mark (not used) Because handshake is impossible with Midi, you need a large buffer (at least 16 K) if Midi-bytes are coming in fast. INP If you use INP(3) to read Midi-bytes, you should first check with INP?(3) if the Midi-buffer contains data. If you use INP(3) and no bytes are available, your ST will freeze. Until you reset the computer. Procedures (CHAPTER.12) Midi_buffer_new & Midi_buffer_restore (page 12-1) MIDI_BUF Change the size of the Midi-buffer (default 128 bytes): @midi_buffer_new(16384,old.buffer%) ! 16 K (...) @midi_buffer_restore(old.buffer%) ! restore default buffer Midi_monitor MIDI_MON A simple Midi-monitor to examine the Midi-bytes that are received by your Atari ST: @midi_monitor Midi_off MIDI_OFF Switch everything off on one Midi-channel: @midi_off(1) ! switch off on channel 1 Midi_off_all MIDI_ALL Switch everything off on all channels (1-16): @midi_off_all Midi_play MIDIPLAY Play music that has been recorded with Procedure Midi_record: @midi_record(last.byte%,song|(),song.time%()) ! improvise @midi_play(last.byte%,song|(),song.time%()) ! listen Midi_record MIDIRCRD Record music. Play it with Procedure Midi_play. The following Midi-command Procedures have self-evident names. Please note that you have to use 1-16 for the Midi-channels and 0-127 for other parameters (unless otherwise stated in a Procedure). \MIDI_COM\ Midi_channel_pressure CH_PRESS Midi_control CONTROL Midi_data DATA Midi_hold HOLD Midi_key_pressure KEY_PRES Midi_modulation MODULATN Midi_note_off NOTE_OFF Midi_note_on NOTE_ON Midi_notes_off NOTESOFF Midi_omni OMNI Midi_pitch_bend PITCHBND Midi_program PROGRAM Midi_volume VOLUME