Restored from previous forum. Originally posted by cor.
Question:
I have the following statement in Visual basic.
Dim MidiCaps As MIDIOUTCAPS
How do I convert this to Purebasic?
Registered PB version : 2.90 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
How to use Dim in Purebasic?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by cor.
Additional info:
Dim MidiCaps As MIDIOUTCAPS
MIDIOUTCAPS is pointing a structure which is already defined.
===========================================================
The following code I want to convert to PB
===========================================================
Const MAXPNAMELEN = 32
Private Type MIDIOUTCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
wTechnology As Integer
wVoices As Integer
wNotes As Integer
wChannelMask As Integer
dwSupport As Long
End Type
Private Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long
Private Declare Function midiOutGetNumDevs Lib "winmm" () As Integer
Private Sub Form_Paint()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [url]mailto:KPDTeam@Allapi.net">KPDTeam@Allapi.net
Dim MidiCaps As MIDIOUTCAPS, Cnt As Long
'Clear the form
Me.Cls
'Get the number of installed MIDI devices
Me.Print "Available midi devices:" + Str$(midiOutGetNumDevs)
For Cnt = 0 To midiOutGetNumDevs - 1
'Get the device name and capabilities
midiOutGetDevCaps Cnt, MidiCaps, Len(MidiCaps)
Me.Print "Device name" + Str$(Cnt + 1) + ": " + MidiCaps.szPname
Next Cnt
End Sub
=================
Registered PB version : 2.90 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
<a href="http://www.ready4music.com[/url]
Additional info:
Dim MidiCaps As MIDIOUTCAPS
MIDIOUTCAPS is pointing a structure which is already defined.
===========================================================
The following code I want to convert to PB
===========================================================
Const MAXPNAMELEN = 32
Private Type MIDIOUTCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
wTechnology As Integer
wVoices As Integer
wNotes As Integer
wChannelMask As Integer
dwSupport As Long
End Type
Private Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long
Private Declare Function midiOutGetNumDevs Lib "winmm" () As Integer
Private Sub Form_Paint()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [url]mailto:KPDTeam@Allapi.net">KPDTeam@Allapi.net
Dim MidiCaps As MIDIOUTCAPS, Cnt As Long
'Clear the form
Me.Cls
'Get the number of installed MIDI devices
Me.Print "Available midi devices:" + Str$(midiOutGetNumDevs)
For Cnt = 0 To midiOutGetNumDevs - 1
'Get the device name and capabilities
midiOutGetDevCaps Cnt, MidiCaps, Len(MidiCaps)
Me.Print "Device name" + Str$(Cnt + 1) + ": " + MidiCaps.szPname
Next Cnt
End Sub
=================
Registered PB version : 2.90 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
<a href="http://www.ready4music.com[/url]
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
I'm no expert Cor but I would interpret it as this:
Good luck 
Edited by - paul on 02 February 2002 18:53:47
I'm no expert Cor but I would interpret it as this:
Code: Select all
#MAXPNAMELEN = 32
Structure MIDIOUTCAPS2
wMid.w
wPid.w
vDriverVersion.l
szPname.b[#MAXPNAMELEN]
wTechnology.w
wVoices.w
wNotes.w
wChannelMask.w
dwSupport.l
EndStructure
MidiCaps.MIDIOUTCAPS2
devices=midiOutGetNumDevs_()
If devices>0
OpenConsole()
PrintN("Available Devices: "+Str(devices))
For cnt=0 To devices-1
midiOutGetDevCaps_(cnt,MidiCaps,SizeOf(MIDIOUTCAPS2) )
PrintN( PeekS(@MidiCaps\szPname[0]) )
Next
wait$=Input()
CloseConsole()
EndIf
Edited by - paul on 02 February 2002 18:53:47
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by cor.
Thanks Paul, It's working.
Below is a complete working version
Registered PB version : 2.90 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Thanks Paul, It's working.
Below is a complete working version
Code: Select all
InitGadget(1)
; Get the number of MIDI Out devices in this computer */
;
; PB: version 2.90 (Windows)
; Using API calls from the winmm.dll (Windows Multimedia DLL)
;==============================================================
;
; Below info from Mirosoft MSDN Library
;More info at:
;[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/midi_4ysl.asp[/url]
;
;MIDIOUTCAPS
;The MIDIOUTCAPS Structure describes the capabilities of a MIDI output device.
;typedef struct {
; WORD wMid;
; WORD wPid;
; MMVERSION vDriverVersion;
; CHAR szPname[MAXPNAMELEN];
; WORD wTechnology;
; WORD wVoices;
; WORD wNotes;
; WORD wChannelMask;
; DWORD dwSupport;
;} MIDIOUTCAPS;
;Members
;wMid
;Manufacturer identifier of the device driver For the MIDI output device. Manufacturer identifiers are defined in Manufacturer And Product Identifiers.
;wPid
;Product identifier of the MIDI output device. Product identifiers are defined in Manufacturer And Product Identifiers.
;vDriverVersion
;Version number of the device driver For the MIDI output device. The high-order byte is the major version number, And the low-order byte is the minor version number.
;szPname
;Product name in a null-terminated string.
;wTechnology
;Flags describing the type of the MIDI output device. It can be one of the following:
;MOD_MIDIPORT
;The device is a MIDI hardware port.
;MOD_SYNTH
;The device is a synthesizer.
;MOD_SQSYNTH
;The device is a square wave synthesizer.
;MOD_FMSYNTH
;The device is an FM synthesizer.
;MOD_MAPPER
;The device is the Microsoft MIDI mapper.
;MOD_WAVETABLE
;The device is a hardware wavetable synthesizer.
;MOD_SWSYNTH
;The device is a software synthesizer.
;wVoices
;Number of voices supported by an internal synthesizer device. If the device is a port, this member is not meaningful And is set To 0.
;wNotes
;Maximum number of simultaneous notes that can be played by an internal synthesizer device. If the device is a port, this member is not meaningful And is set To 0.
;wChannelMask
;Channels that an internal synthesizer device responds to, where the least significant bit refers To channel 0 And the most significant bit To channel 15. Port devices that transmit on all channels set this member To 0xFFFF.
;dwSupport
;Optional functionality supported by the device. It can be one Or more of the following:
;MIDICAPS_CACHE
;Supports patch caching.
;MIDICAPS_LRVOLUME
;Supports separate left And right volume control.
;MIDICAPS_STREAM
;Provides direct support For the midiStreamOut function.
;MIDICAPS_VOLUME
;Supports volume control.
;If a device supports volume changes, the MIDICAPS_VOLUME flag will be set For the dwSupport member. If a device supports separate volume changes on the left And right channels, both the MIDICAPS_VOLUME And the MIDICAPS_LRVOLUME flags will be set For this member.
;====================================================================
; Display name constant of MIDIOUTCAPS structure which is already defined
; max. chars to display
#MAXPNAMELEN=32
; Copy structure
MidiCaps.MIDIOUTCAPS
; get the number of midiout devices
iNumDevs.l = midiOutGetNumDevs_()
If OpenWindow(0, 100, 100, 250, 210, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Get Midi Out Devices")
CreateGadgetList(WindowID())
hCbo=ComboBoxGadget(1,33,56,160,455)
; Go through all of those devices, displaying their names
For i =0 To iNumDevs-1
; Get info about the Next device */
If (midiOutGetDevCaps_(i, MidiCaps, SizeOf(MIDIOUTCAPS))) =0
; Display its Device name */
AddGadgetItem(1,-1, PeekS(@MidiCaps\szPname[0]) );
EndIf
Next
; Display First MidiOut device
If iNumDevs < 1
AddGadgetItem(1,-1,"No MidiOut Device found")
EndIf
; Set to first item in ComboBox
SetGadgetState(1, 0)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com