Sending Midi Data; Reading Midi Data - Creative SB0350 Programming Manual

Hardware programming guide
Table of Contents

Advertisement

5-10
MIDI Port I/O Programming

Sending MIDI Data

Once in UART mode, MIDI data can be sent to an external MIDI device by writing to
the Data port.
Example code:
Busy:

Reading MIDI Data

When MIDI data is available from an external MIDI device, it can be read in from the
Data port. There are two modes used in detecting the availability of input data: polling
and interrupt.
When in polling mode, as before, input data is available when bit 7 of the Status port is
zero. Conversely, when bit 7 is a one, no MIDI data is available.
In interrupt mode, an interrupt occurs when a MIDI code is ready. An interrupt service
routine has to be set up to retrieve the MIDI code. Reading from the Data port will
clear the interrupt signal.
The sequence for reading MIDI data is identical in both polling and interrupt modes.
Below is a code fragment that can be used in either the polling routine or the interrupt
service routine:
Busy:
Under the MPU-401 UART mode, there is no timing information available. It is up to
the application to handle the timing for the MIDI data.
mov
dx,wMpuBaseAddx
inc
dx
in
al,dx
test
al,40h
jnz
Busy
mov
al,bMidiData
dec
dx
out
dx,al
mov
dx,wMpuBaseAddx
inc
dx
in
al,dx
test
al,80h
jnz
Busy
dec
dx
in
al,dx
;MPU-401 base I/O address
;Status port
;Read status port
;Ready for output?
;No
;Get MIDI data
;Data Port
;Output MIDI data
;MPU-401 base I/O address
;Status port
;Read status port
;MIDI data available?
;No
;Data port
;Read MIDI data, and clear interrupt

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents