Restored from previous forum. Originally posted by NicTheQuick.
I programmed a MIDIRequester to chose an in- or output device:
Code: Select all
Procedure MIDIRequester(*OutDevice, *InDevice)
#MOD_WAVETABLE = 6
#MOD_SWSYNTH = 7
#MIDIRequ_InSet = 2
#MIDIRequ_OutSet = 1
#Width = 400
If OpenWindow(0, 0, 0, #Width, 270, "MIDI-Requester", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Column = (#Width - 20) / 2
#Offset = (#Width / 2) + 5
TextGadget(0, 5, 5, #Column, 18, "Output-Device:", #PB_Text_Center | #PB_Text_Border)
ListViewGadget(2, 5, 23, #Column, 100)
MaxOutDev = midiOutGetNumDevs_()
InfoOut.MIDIOUTCAPS
If MaxOutDev
For a = -1 To MaxOutDev - 1
midiOutGetDevCaps_(a, InfoOut, SizeOf(MIDIOUTCAPS))
AddGadgetItem(2, -1, PeekS(@InfoOut\szPname[0], 32))
Next
Else
AddGadgetItem(2, -1, "(no output device)")
DisableGadget(3, 1)
EndIf
TextGadget(1, #Offset, 5, #Column, 18, "Input-Device:", #PB_Text_Center | #PB_Text_Border)
ListViewGadget(3, #Offset, 23, #Column, 100)
MaxInDev = midiInGetNumDevs_()
InfoIn.MIDIINCAPS
If MaxInDev
For a = 0 To MaxInDev - 1
midiInGetDevCaps_(a, InfoIn, SizeOf(MIDIINCAPS))
AddGadgetItem(3, -1, PeekS(@InfoIn\szPname[0], 32))
Next
Else
AddGadgetItem(3, -1, "(no input device)")
DisableGadget(3, 1)
EndIf
ButtonGadget(4, 5, 240, #Column, 24, "&OK")
ButtonGadget(5, #Offset, 240, #Column, 24, "&Cancel")
FrameGadget(6, 5, 130, #Width - 10, 100, "Info of Output-Device", 0)
TextGadget(7, 10, 145, #Width - 20, 18, "Version:")
TextGadget(8, 10, 165, #Width - 20, 18, "Technology:")
TextGadget(9, 10, 185, #Width - 20, 18, "Max. Voices:")
TextGadget(10, 10, 205, #Width - 20, 18, "Polyphonie:")
OutDev = 0
InDev = 0
Quit = #False
OK = #False
Repeat
If GetGadgetState(2) > -1 Or GetGadgetState(3) > -1
DisableGadget(4, 0)
Else
DisableGadget(4, 1)
EndIf
If InDev <> GetGadgetState(3)
InDev = GetGadgetState(3)
EndIf
If GetGadgetState(2) <> OutDev
OutDev = GetGadgetState(2)
midiOutGetDevCaps_(OutDev - 1, InfoOut, SizeOf(MIDIOUTCAPS))
SetGadgetText(7, "Version: " + Str(InfoOut\vDriverVersion >> 8) + "." + Str(InfoOut\vDriverVersion & FF))
Select InfoOut\wTechnology
Case #MOD_MIDIPORT : TmpS.s = "Hardware Port"
Case #MOD_SYNTH : TmpS.s = "Synthesizer"
Case #MOD_SQSYNTH : TmpS.s = "Square Wave Synthesizer"
Case #MOD_FMSYNTH : TmpS.s = "FM Synthesizer"
Case #MOD_MAPPER : TmpS.s = "Microsoft MIDI Mapper"
Case #MOD_WAVETABLE : TmpS.s = "Hardware Wavetable Synthesizer"
Case #MOD_SWSYNTH : TmpS.s = "Software Synthesizer"
Default: TmpS.s = "(Error Code " + Str(InfoOut\wTechnology) + ")"
EndSelect
SetGadgetText(8, "Technology: " + TmpS)
If InfoOut\wVoices = 0 : TmpS.s = "inf" : Else : TmpS.s = Str(InfoOut\wVoices) : EndIf
SetGadgetText(9, "Max. Voices: " + TmpS)
If InfoOut\wNotes = 0 : TmpS.s = "inf" : Else : TmpS.s = Str(InfoOut\wNotes) : EndIf
SetGadgetText(10, "Polyphonie: " + TmpS)
EndIf
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_CloseWindow
Quit = #True
OK = #False
Case #PB_Event_Gadget
Select EventGadget()
Case 4
PokeL(*OutDevice, OutDev - 1)
PokeL(*InDevice, InDev)
Quit = #True
OK = 3
If (OutDev = -1 Or CountGadgetItems(2) = 0) And OK & #MIDIRequ_OutSet : OK ! #MIDIRequ_OutSet : EndIf
If (InDev = -1 Or CountGadgetItems(3) = 0) And OK & #MIDIRequ_InSet : OK ! #MIDIRequ_InSet : EndIf
Case 5
Quit = #True
OK = #False
EndSelect
EndSelect
Until Quit
CloseWindow(0)
ProcedureReturn OK
Else
End
EndIf
EndProcedure
MIDIResult = MIDIRequester(@OutDevice, @InDevice)
If MIDIResult & #MIDIRequ_OutSet : Debug "Output device: " + Str(OutDevice) : EndIf
If MIDIResult & #MIDIRequ_InSet : Debug "Input device: " + Str(InDevice) : EndIf
End
Intel Celeron PPGA 466 Mhz, 192 MB SD-RAM, 2 Soundcards, 5 Synthesizer, ...
(16 years old german boy)