Finding MIDI devices...

Share your advanced PureBasic knowledge/code with the community.
akee
Enthusiast
Enthusiast
Posts: 498
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Finding MIDI devices...

Post by akee »

Code updated For 5.20+
I guess it is about time I contributed to this forum so here it is...

Nothing special but if you would want to find out what MIDI devices you have, here's one solution... :)

Code: Select all

#MAXPNAMELEN = 32

;
; *** For your reference... :)
; 6 Nov 2004 - akee (hey! visit me ... www.akee.com)
;
;Structure MIDIINCAPS
;  wMid.w
;  wPid.w
;  vDriverVersion.l
;  szPname.b[#MAXPNAMELEN]
;EndStructure 
;
;Structure MIDIOUTCAPS
;  wMid.w
;  wPid.w
;  vDriverVersion.l
;  szPname.b[#MAXPNAMELEN]
;  wTechnology.w
;  wVoices.w
;  wNotes.w
;  wChannelMask.w
;  dwSupport.l
;EndStructure



OpenConsole()

iNumDev.l = midiInGetNumDevs_()
PrintN(Str(iNumDev) + " MIDI in devices.")
PrintN("")
For around.l = 0 To iNumDev - 1
  midiInGetDevCaps_(around, mic.MIDIINCAPS, SizeOf(MIDIINCAPS))
  PrintN("- " + Str(around) + " " + PeekS(@mic\szPname[0], #MAXPNAMELEN))
Next

PrintN("")
PrintN("")

iNumDev.l = midiOutGetNumDevs_()
PrintN(Str(iNumDev) + " MIDI out devices.")
PrintN("")
For around.l = 0 To iNumDev - 1
  midiOutGetDevCaps_(around, moc.MIDIOUTCAPS, SizeOf(MIDIOUTCAPS))
  PrintN("- " + Str(around) + " " + PeekS(@moc\szPname[0], #MAXPNAMELEN))
Next

Input()
CloseConsole()

End
User avatar
griz
Enthusiast
Enthusiast
Posts: 167
Joined: Sun Jun 29, 2003 7:32 pm
Location: Canada

Post by griz »

Thanks Akee! I love nice simple little API examples.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Re: Finding MIDI devices...

Post by Ralf »

nice small example! :D

any small example available to select available midi output device and play .mid file using this output?
Post Reply