[sdiy] USB Midi??
Thorsten Klose
Thorsten.Klose at gmx.de
Sun Mar 2 11:29:32 CET 2003
There is no need for writing an own driver, because Windows/Mac OSX/
Linux already comes with an integrated MIDI USB solution which
is based on the specification that can be found under www.usb.org
Here an example setup which works (as you can notice, I had to
tweak the descriptors for Windows, since the M$ driver isn't
compatible at all)
;; for incompatible WinME/WinXP Driver
#define MICRO_WORKAROUND 1
#define FAKE_MIDI
1
;;-----------------------------------------------------------------------------
;; Global
Variables
;;-----------------------------------------------------------------------------
;; Note: This segment must be located in on-part memory.
rseg DSCR ;; locate the descriptor table anywhere below 8K
DeviceDscr: db deviceDscrEnd-DeviceDscr ;; Descriptor length
db DSCR_DEVICE ;; Decriptor type
db 0x10, 0x01 ;; Specification Version (BCD)
db 00H ;; Device class
db 00H ;; Device sub-class
db 00H ;; Device sub-sub-class
db 64 ;; Maximum packet size
#if FAKE_MIDI == 1
dw 4705H ;; Vendor ID
dw 0210H ;; Product ID - set to default example ID
dw 0100H ;; Product version ID
#else
dw 1112H ;; Vendor ID
dw 2222H ;; Product ID
db 0x01, 0x00 ;; Product version ID
#endif
db 1 ;; Manufacturer string index
db 2 ;; Product string index
db 0 ;; Serial number string index
db 1 ;; Number of configurations
deviceDscrEnd:
ConfigDscr: db ConfigDscrEnd-ConfigDscr ;; Descriptor length
db DSCR_CONFIG ;; Descriptor type
db LOW(StringDscr-ConfigDscr) ;; Config + End Points length (LSB)
db HIGH(StringDscr-ConfigDscr) ;; Config + End Points length (MSB)
#if MICRO_WORKAROUND == 0
db 2 ;; Number of interfaces
#else
db 1 ;; Number of interfaces
#endif
db 1 ;; Interface number
db 3 ;; Configuration string
db 10000000b ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)
db 0x10 ;; Power requirement (div 2 ma)
ConfigDscrEnd:
#if MICRO_WORKAROUND == 0
AudioCtrlIntrfcDscr:
db AudioCtrlIntrfcDscrEnd-AudioCtrlIntrfcDscr ;; Descriptor length
db DSCR_INTRFC ;; Descriptor type
db 0 ;; Zero-based index of this interface
db 0 ;; Alternate setting
db 0 ;; Number of end points
#if FAKE_MIDI == 1
db 0ffH ;; Interface class
db 00H ;; Interface sub class
db 00H ;; Interface sub sub class
#else
db 01H ;; Interface class (AUDIO)
db 01H ;; Interface sub class (AUDIO_CONTROL)
db 00H ;; Interface sub sub class
#endif
db 3 ;; Interface descriptor string index
AudioCtrlIntrfcDscrEnd:
AudioControlClassIntrfcDscr:
db AudioControlClassIntrfcDscrEnd-AudioControlClassIntrfcDscr ;;
Descriptor length
db 0x24 ;; Descriptor type (CS_INTERFACE)
db 0x01 ;; HEADER subtype
db 0x00, 0x01 ;; Revision of class specification - 1.0
db LOW(ClassLength);; Total size of specific descriptors
db HIGH(ClassLength)
db 0x01 ;; number of streaming interfaces
db 0x01 ;; MIDI streaming interface 1 belongs to this AudioControl
interface
AudioControlClassIntrfcDscrEnd:
ClassLength EQU $-AudioControlClassIntrfcDscr
#endif
AudioStreamIntrfcDscr:
db AudioStreamIntrfcDscrEnd-AudioStreamIntrfcDscr ;; Descriptor length
db DSCR_INTRFC ;; Descriptor type
#if MICROSHIT == 0
db 1 ;; Zero-based index of this interface
#else
db 0 ;; Zero-based index of this interface
#endif
db 0 ;; Alternate setting
db 2 ;; Number of end points
db 01H ;; Interface class (AUDIO)
db 03H ;; Interface sub class (MIDISTREAMING)
db 00H ;; Interface sub sub class
db 2 ;; Interface descriptor string index
AudioStreamIntrfcDscrEnd:
MSCIntrfcDscr:
db MSCIntrfcDscrEnd-MSCIntrfcDscr ;; Descriptor length
db 0x24 ;; Descriptor type
db 1 ;; Zero-based index of this interface
db 0x00, 0x01 ;; revision of this class specification
db LOW(MSCClassSize);; Total size of class-specific descriptors
db HIGH(MSCClassSize)
MSCIntrfcDscrEnd:
MIDIInEmDscr:
db MIDIInEmDscrEnd-MIDIInEmDscr ;; Descriptor length
db 0x24 ;; Descriptor type (CS_INTERFACE)
db 0x02 ;; MIDI_IN_JACK subtype
db 0x01 ;; EMBEDDED
db 0x01 ;; ID of this jack
db 00H ;; unused
MIDIInEmDscrEnd:
MIDIInExDscr:
db MIDIInExDscrEnd-MIDIInExDscr ;; Descriptor length
db 0x24 ;; Descriptor type (CS_INTERFACE)
db 0x02 ;; MIDI_IN_JACK subtype
db 0x02 ;; EXTERNAL
db 0x02 ;; ID of this jack
db 00H ;; unused
MIDIInExDscrEnd:
MIDIOutEmDscr:
db MIDIOutEmDscrEnd-MIDIOutEmDscr ;; Descriptor length
db 0x24 ;; Descriptor type (CS_INTERFACE)
db 0x03 ;; MIDI_OUT_JACK subtype
db 0x01 ;; EMBEDDED
db 0x03 ;; ID of this jack
db 0x01 ;; number of input pins of this jack
db 0x02 ;; ID of the entity to which this pin is connected
db 0x01 ;; Output Pin number of the entity to which this input pin is
connected
db 00H ;; unused
MIDIOutEmDscrEnd:
MIDIOutExDscr:
db MIDIOutExDscrEnd-MIDIOutExDscr ;; Descriptor length
db 0x24 ;; Descriptor type (CS_INTERFACE)
db 0x03 ;; MIDI_OUT_JACK subtype
db 0x02 ;; EXTERNAL
db 0x04 ;; ID of this jack
db 0x01 ;; number of input pins of this jack
db 0x01 ;; ID of the entity to which this pin is connected
db 0x01 ;; Output Pin number of the entity to which this input pin is
connected
db 00H ;; unused
MIDIOutExDscrEnd:
StdBulkOutEPDscr:
db StdBulkOutEPDscrEnd-StdBulkOutEPDscr ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 0x02 ;; Out Endpoint 2
db 0x02 ;; Bulk, not shared
db 0x04, 0x00 ;; 4 bytes per packet
db 0x00 ;; ignore for bulk
db 0x00 ;; unused
db 0x00 ;; unused
StdBulkOutEPDscrEnd:
StdBulkInEPDscr:
db StdBulkInEPDscrEnd-StdBulkInEPDscr ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 0x82 ;; In Endpoint 2
db 0x02 ;; Bulk, not shared
db 0x04, 0x00 ;; 4 bytes per packet
db 0x00 ;; ignore for bulk
db 0x00 ;; unused
db 0x00 ;; unused
StdBulkInEPDscrEnd:
MSBulkOutEPDscr:
db MSBulkOutEPDscrEnd-MSBulkOutEPDscr ;; Descriptor length
db 0x25 ;; Descriptor type (CS_ENDPOINT)
db 0x01 ;; MS_GENERAL
db 0x01 ;; number of embedded MIDI IN Jacks
db 0x01 ;; ID of embedded MIDI In Jack
MSBulkOutEPDscrEnd:
MSBulkInEPDscr:
db MSBulkInEPDscrEnd-MSBulkInEPDscr ;; Descriptor length
db 0x25 ;; Descriptor type (CS_ENDPOINT)
db 0x01 ;; MS_GENERAL
db 0x01 ;; number of embedded MIDI Out Jacks
db 0x03 ;; ID of embedded MIDI Out Jack
MSBulkInEPDscrEnd:
MSCClassSize EQU $-MSCIntrfcDscr
StringDscr:
StringDscr0:
db StringDscr0End-StringDscr0 ;; String descriptor length
db DSCR_STRING
db 09H,04H
StringDscr0End:
StringDscr1:
db StringDscr1End-StringDscr1 ;; String descriptor length
db DSCR_STRING
db 'A',00
StringDscr1End:
StringDscr2:
db StringDscr2End-StringDscr2 ;; Descriptor length
db DSCR_STRING
db 'B',00
StringDscr2End:
StringDscr3:
db StringDscr3End-StringDscr3 ;; Descriptor length
db DSCR_STRING
db 'C',00
StringDscr3End:
UserDscr:
dw 0000H
end
More information about the Synth-diy
mailing list