Listing the MIDI output devices

by Richard Russell, May 2006

The code below will list to the screen all the available MIDI output devices:

        DIM  moc{ \
        \    wMid{l&,h&}, \ int16
        \    wPid{l&,h&}, \ int16
        \    vDriverVersion%, \ int32
        \    szPname&(31), \ string
        \    wTechnology{l&,h&}, \ int16
        \    wVoices{l&,h&}, \ int16
        \    wNotes{l&,h&}, \ int16
        \    wChannelMask{l&,h&}, \ int16
        \    dwSupport% \ int32
        \    }
 
        SYS "midiOutGetNumDevs" TO iNumDevs%
 
        FOR i% = 0 TO iNumDevs%-1
          SYS "midiOutGetDevCaps", i%, moc{}, DIM(moc{}) TO res%
          IF res%=0 THEN
            PRINT "Device ID #";i%;": "moc.szPname&()
          ENDIF
        NEXT i%

When more than one output device is available you could adapt the code to present a list to the user from which he can make a selection.