USB-MIDI-Driver
USB-MIDI-Driver copied to clipboard
MIDI Input Broken on Android 4
I've reproduced this issue many times on Android 4.4.2 with Samsung Galaxy Note 2. I've only occasionally reproduced on Android 5, and never on Android 6, and haven't the ability to test Android 3.
The problem is that in MIDIInputDevice, waiterThread is almost always started before midiEventListener reference is set, and therefore incoming MIDI data is never passed to the event listener.
Locally, I have fixed the issue by starting waiterThread in setMidiEventListener. I am very new to this library, as well as to GitHub, so I thought it better to report it here, rather than commit the change.
I experienced the exact same problem on an Android tablet running 4.4. However, while your fix allowed me to receive events, it caused crashes when disconnecting the device.
Instead I implemented a different solution. the midiEventListener is initialized to null. inside the waiterThread, after the sleeping I check if the listener is null, if so I 'continue' the loop, else I allow processing to continue. This solved the race condition you identified, and also resolved my crashing problem.
I had got the same issue and resolved by this solution:
- Add a function name start2Work to MidiInputDevice
public void start2Work() {
if (!waiterThread.isAlive()) {
waiterThread.start();
}
}
- Remove this line
java waiterThread.start()
of MidiInputDevice constructor. - Find this line contains
deviceAttachedListener.onMidiInputDeviceAttached(midiInputDevice);
in MidiDeviceConnectionWacther and add this line blow it:midiInputDevice.start2Work();
Still doesn't work for me, even with FlyingFishBird solution... any idea ? :/
Ok now i get midi input but on large sysex receptions sometimes the sysex gets mangled, any idea ?
This is most likely a problem with the USB MIDI interface.
Some interfaces (e.g. the Roland UM-ONE) have reported exactly this problem.
I’d recommend to try a different interface, e.g. the ESI MIDIMate II works perfectly.
Von: AlGrenadine [mailto:[email protected]] Gesendet: Freitag, 25. November 2016 10:59 An: kshoji/USB-MIDI-Driver Betreff: Re: [kshoji/USB-MIDI-Driver] MIDI Input Broken on Android 4 (#58)
Ok now i get midi input but on large sysex receptions sometimes the sysex gets mangled, any idea ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kshoji/USB-MIDI-Driver/issues/58#issuecomment-262920800 , or mute the thread https://github.com/notifications/unsubscribe-auth/AF5BLI0uc_5EHrcDuw84BxY8q6vSz00_ks5rBrFZgaJpZM4JDeW0 .Das Bild wurde vom Absender entfernt.
Yes i use a Roland UM One, but then why does it work if i use Marshmallow's midi feature ? With android 6, the sysex is not mangled, so it's not the interface the culprit...
The UM-One is overall a good interface.
I actually use one by myself for testing.
And yes, it works with the Android Marshmallow MIDI api (if you set the interface to class-compliant using the small dip switch on the interface).
But it has some weird technical internals, different to other interfaces.
That it works with the Android 6 does not proof that it also works with raw usb bulk transfer.
However, what you can try is to check (by debuggning) if there are running multiple MidiInputDevices (in other words multiple threads listening to the same in port).
That could theoretically result in such a problem, and the fact that there are 2 IN threads running could be a result of the UM-One.
Try do boot your device, then start the app the first time, then plug in the interface and test sysex…
If that worked, unplug it and reconnect it again, then test sysex again…
Can you force the error to happen that way?
Btw. I’m not the dev of the MIDI driver, I’ve just derived my old pre marshmallow midi driver from it a couple of years ago.
I just remember approximately the same discussion with some other user a while ago, and there it turned out that the UM-One was the problem.
Von: AlGrenadine [mailto:[email protected]] Gesendet: Freitag, 25. November 2016 11:51 An: kshoji/USB-MIDI-Driver Cc: planethcom; Comment Betreff: Re: [kshoji/USB-MIDI-Driver] MIDI Input Broken on Android 4 (#58)
Yes i use a Roland UM One, but then why does it work if i use Marshmallow's midi feature ? With android 6, the sysex is not mangled, so it's not the interface the culprit...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kshoji/USB-MIDI-Driver/issues/58#issuecomment-262930906 , or mute the thread https://github.com/notifications/unsubscribe-auth/AF5BLHXXMdxrjJZdQGQyxj3EwjDJZtXlks5rBr2IgaJpZM4JDeW0 .Das Bild wurde vom Absender entfernt.
Yes i can reproduce the problem everytime, not only with um one but also with an usb midi class compliant device. I'll check the MidiInputDevices, that's a good idea, thanks
That would explain why it’s only affecting sysex messages.
Regular midi messages are all small enough to fit into one usb transmission packet (max packet size on android is usually 64bytes as far as I remember).
A sysex message might be transmitted in multiple packets.. and if another thread grabs some of the packets in between, the result would be mangled.
Hope that helps getting it solved
Von: AlGrenadine [mailto:[email protected]] Gesendet: Freitag, 25. November 2016 13:13 An: kshoji/USB-MIDI-Driver Cc: planethcom; Comment Betreff: Re: [kshoji/USB-MIDI-Driver] MIDI Input Broken on Android 4 (#58)
Yes i can reproduce the problem everytime, not only with um one but also with an usb midi class compliant device. I'll check the MidiInputDevices, that's a good idea, thanks
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kshoji/USB-MIDI-Driver/issues/58#issuecomment-262944326 , or mute the thread https://github.com/notifications/unsubscribe-auth/AF5BLKOuJwnUYzx-PDhOvPPbxJQbOxQHks5rBtCwgaJpZM4JDeW0 .Das Bild wurde vom Absender entfernt.
Sadly, i only have 1 MidiInputDevice thread running... It acts like some bytes get lost occasionnally, the term 'mangles' wasn't the good one
Here are the USB descriptors of the midi interface : Information for device AXE-FX II (VID=0x2466 PID=0x8003):
*** ERROR: Descriptor has errors! ***
Connection Information:
Connection status: Device connected Device actual bus speed: HighSpeed Device is hub: No Device address: 0x0005 Current configuration value: 0x01 Number of open pipes: 2
Device Descriptor:
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0xEF bDeviceClass (Miscellaneous device)
0x02 bDeviceSubClass
0x01 bDeviceProtocol
0x40 bMaxPacketSize0 (64 Bytes)
0x2466 idVendor
0x8003 idProduct
0x0000 bcdDevice
0x01 iManufacturer "Fractal Audio Systems"
0x02 iProduct "AXE-FX II"
0x00 iSerialNumber
0x02 bNumConfigurations
Device Qualifier Descriptor:
0x0A bLength
0x06 bDescriptorType
0x0200 bcdUSB
0xEF bDeviceClass (Miscellaneous device)
0x02 bDeviceSubClass
0x01 bDeviceProtocol
0x40 bMaxPacketSize0 (64 Bytes)
0x01 bNumConfigurations
0x00 bReserved
Configuration Descriptor:
0x09 bLength 0x02 bDescriptorType 0x012F wTotalLength (303 Bytes) 0x05 bNumInterfaces 0x01 bConfigurationValue 0x00 iConfiguration 0xC0 bmAttributes (Self-powered Device) 0x01 bMaxPower (2 mA)
Interface Association Descriptor:
0x08 bLength
0x0B bDescriptorType
0x00 bFirstInterface
0x03 bInterfaceCount
0x01 bFunctionClass (Audio Device Class)
0x00 bFunctionSubClass
0x20 bFunctionProtocol
0x08 iFunction "AXE-FX II Audio Intfc"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x20 bInterfaceProtocol
0x03 iInterface "AXE-FX II"
AC Interface Header Descriptor:
0x09 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0200 bcdADC 0x08 bCategory (IO_BOX) 0x004B wTotalLength (75 Bytes) 0x00 bmControls
AC Clock Source Descriptor:
0x08 bLength 0x24 bDescriptorType 0x0A bDescriptorSubtype 0x28 bClockID 0x01 bmAttributes 0x01 bmControls 0x00 bAssocTerminal 0x04 iClockSource "DevClk"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x28 bCSourceID 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x14 bTerminalID 0x0301 wTerminalType (Speaker) 0x00 bAssocTerminal 0x02 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bTerminalID 0x0601 wTerminalType (Analog connector) 0x00 bAssocTerminal 0x28 bCSourceID 0x04 bNrChannels (4 Channels) 0x0000000F bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x06 iTerminal "AXE-FX II Audio In"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x16 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x01 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x06 iTerminal "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x02 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x02 bEndpointAddress (OUT Endpoint) 0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data) 0x002A wMaxPacketSize (42 Bytes) 0x01 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x16 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x04 bNrChannels (4 Channels) 0x0000000F bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x86 bEndpointAddress (IN Endpoint) 0x25 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Implicit) 0x0054 wMaxPacketSize (84 Bytes) 0x01 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x03 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x00 bInterfaceProtocol
0x08 iInterface "AXE-FX II Audio Intfc"
AC Interface Header Descriptor:
0x09 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0100 bcdADC 0x0009 wTotalLength (9 Bytes) 0x01 bInCollection 0x04 baInterfaceNr(1)
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x04 bInterfaceNumber
0x00 bAlternateSetting
0x02 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x03 bInterfaceSubClass (MIDI Streaming Interface)
0x00 bInterfaceProtocol
0x07 iInterface "AXE-FX II MIDI"
MS Interface Header Descriptor:
0x07 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0100 bcdMSC 0x0041 wTotalLength (65 Bytes)
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bJackType 0x01 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bJackType 0x02 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x01 bJackType 0x03 bJackID 0x01 bNrInputPins 0x02 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x02 bJackType 0x04 bJackID 0x01 bNrInputPins 0x01 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x04 bEndpointAddress (OUT Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0200 wMaxPacketSize (512 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x01 baAssocJackID(1)
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x81 bEndpointAddress (IN Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0200 wMaxPacketSize (512 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x03 baAssocJackID(1)
Configuration Descriptor:
0x09 bLength 0x02 bDescriptorType 0x012F wTotalLength (303 Bytes) 0x05 bNumInterfaces 0x01 bConfigurationValue 0x00 iConfiguration 0xC0 bmAttributes (Self-powered Device) 0x01 bMaxPower (2 mA)
Interface Association Descriptor:
0x08 bLength
0x0B bDescriptorType
0x00 bFirstInterface
0x03 bInterfaceCount
0x01 bFunctionClass (Audio Device Class)
0x00 bFunctionSubClass
0x20 bFunctionProtocol
0x08 iFunction "AXE-FX II Audio Intfc"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x20 bInterfaceProtocol
0x03 iInterface "AXE-FX II"
AC Interface Header Descriptor:
0x09 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0200 bcdADC 0x08 bCategory (IO_BOX) 0x004B wTotalLength (75 Bytes) 0x00 bmControls
AC Clock Source Descriptor:
0x08 bLength 0x24 bDescriptorType 0x0A bDescriptorSubtype 0x28 bClockID 0x01 bmAttributes 0x01 bmControls 0x00 bAssocTerminal 0x04 iClockSource "DevClk"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x28 bCSourceID 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x14 bTerminalID 0x0301 wTerminalType (Speaker) 0x00 bAssocTerminal 0x02 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bTerminalID 0x0601 wTerminalType (Analog connector) 0x00 bAssocTerminal 0x28 bCSourceID 0x04 bNrChannels (4 Channels) 0x0000000F bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x06 iTerminal "AXE-FX II Audio In"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x16 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x01 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x06 iTerminal "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x02 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x02 bEndpointAddress (OUT Endpoint) 0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data) 0x002A wMaxPacketSize (42 Bytes) 0x01 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x16 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x04 bNrChannels (4 Channels) 0x0000000F bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x86 bEndpointAddress (IN Endpoint) 0x25 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Implicit) 0x0054 wMaxPacketSize (84 Bytes) 0x01 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x03 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x00 bInterfaceProtocol
0x08 iInterface "AXE-FX II Audio Intfc"
AC Interface Header Descriptor:
0x09 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0100 bcdADC 0x0009 wTotalLength (9 Bytes) 0x01 bInCollection 0x04 baInterfaceNr(1)
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x04 bInterfaceNumber
0x00 bAlternateSetting
0x02 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x03 bInterfaceSubClass (MIDI Streaming Interface)
0x00 bInterfaceProtocol
0x07 iInterface "AXE-FX II MIDI"
MS Interface Header Descriptor:
0x07 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0100 bcdMSC 0x0041 wTotalLength (65 Bytes)
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bJackType 0x01 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bJackType 0x02 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x01 bJackType 0x03 bJackID 0x01 bNrInputPins 0x02 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x02 bJackType 0x04 bJackID 0x01 bNrInputPins 0x01 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x04 bEndpointAddress (OUT Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0200 wMaxPacketSize (512 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x01 baAssocJackID(1)
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x81 bEndpointAddress (IN Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0200 wMaxPacketSize (512 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x03 baAssocJackID(1)
*** ERROR: Invalid descriptor type (Exp:0x07 Got:0x02) Configuration Descriptor:
0x09 bLength 0x02 bDescriptorType 0x011D wTotalLength (285 Bytes) 0x05 bNumInterfaces *** ERROR: Invalid bNumInterfaces 5, found 4 interfaces within the whole configuration descriptor 0x01 bConfigurationValue 0x00 iConfiguration 0xC0 bmAttributes (Self-powered Device) 0x01 bMaxPower (2 mA)
Interface Association Descriptor:
0x08 bLength
0x0B bDescriptorType
0x00 bFirstInterface
0x03 bInterfaceCount
0x01 bFunctionClass (Audio Device Class)
0x00 bFunctionSubClass
0x20 bFunctionProtocol
0x00 iFunction
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x20 bInterfaceProtocol
0x03 iInterface "AXE-FX II"
AC Interface Header Descriptor:
0x09 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0200 bcdADC 0x08 bCategory (IO_BOX) 0x004B wTotalLength (75 Bytes) 0x00 bmControls
AC Clock Source Descriptor:
0x08 bLength 0x24 bDescriptorType 0x0A bDescriptorSubtype 0x28 bClockID 0x01 bmAttributes 0x01 bmControls 0x00 bAssocTerminal 0x04 iClockSource "DevClk"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x28 bCSourceID 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x14 bTerminalID 0x0301 wTerminalType (Speaker) 0x00 bAssocTerminal 0x02 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x05 iTerminal "AXE-FX II Audio Out"
AC Input Terminal Descriptor:
0x11 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bTerminalID 0x0601 wTerminalType (Analog connector) 0x00 bAssocTerminal 0x28 bCSourceID 0x03 bNrChannels (3 Channels) 0x00000007 bmChannelConfig 0x00 iChannelNames 0x00 bmControls 0x06 iTerminal "AXE-FX II Audio In"
AC Output Terminal Descriptor:
0x0C bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x16 bTerminalID 0x0101 wTerminalType (USB Streaming) 0x00 bAssocTerminal 0x01 bSourceID 0x28 bCSourceID 0x0000 bmControls 0x06 iTerminal "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x05 iInterface "AXE-FX II Audio Out"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x02 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x02 bNrChannels (2 Channels) 0x00000003 bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x02 bEndpointAddress (OUT Endpoint) 0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data) 0x0130 wMaxPacketSize (304 Bytes) 0x01 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x20 bInterfaceProtocol
0x06 iInterface "AXE-FX II Audio In"
AS Interface Descriptor:
0x10 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x16 bTerminalLink 0x00 bmControls 0x01 bFormatType (FORMAT_TYPE_1) 0x00000001 bmFormats 0x03 bNrChannels (3 Channels) 0x00000007 bmChannelConfig 0x00 iChannelNames
AS Format Type 1 Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bFormatType (FORMAT_TYPE_1) 0x03 bSubslotSize 0x18 bBitResolution (24 Bits/sample)
Endpoint Descriptor:
0x07 bLength 0x05 bDescriptorType 0x86 bEndpointAddress (IN Endpoint) 0x25 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Implicit) 0x0130 wMaxPacketSize (304 Bytes) 0x03 bInterval
AS Isochronous Data Endpoint Descriptor:
0x08 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x00 bmAttributes 0x00 bmControls 0x00 bLockDelayUnits (Undefined) 0x0000 wLockDelay
Interface Descriptor:
0x09 bLength
0x04 bDescriptorType
0x03 bInterfaceNumber
0x00 bAlternateSetting
0x02 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x03 bInterfaceSubClass (MIDI Streaming Interface)
0x00 bInterfaceProtocol
0x00 iInterface
MS Interface Header Descriptor:
0x07 bLength 0x24 bDescriptorType 0x01 bDescriptorSubtype 0x0100 bcdMSC 0x0041 wTotalLength (65 Bytes)
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x01 bJackType 0x01 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI IN Jack Descriptor:
0x06 bLength 0x24 bDescriptorType 0x02 bDescriptorSubtype 0x02 bJackType 0x02 bJackID 0x09 iJack "AXE-FX II MIDI In"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x01 bJackType 0x03 bJackID 0x01 bNrInputPins 0x02 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
MS MIDI OUT Jack Descriptor:
0x09 bLength 0x24 bDescriptorType 0x03 bDescriptorSubtype 0x02 bJackType 0x04 bJackID 0x01 bNrInputPins 0x01 baSourceID(1) 0x01 baSourcePin(1) 0x0A iJack "AXE-FX II MIDI Out"
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x04 bEndpointAddress (OUT Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0040 wMaxPacketSize (64 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x01 baAssocJackID(1)
Endpoint Descriptor (Audio/MIDI):
0x09 bLength 0x05 bDescriptorType 0x81 bEndpointAddress (IN Endpoint) 0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data) 0x0040 wMaxPacketSize (64 Bytes) 0x00 bInterval 0x00 bRefresh 0x00 bSynchAddress
MS Bulk Data Endpoint Descriptor:
0x05 bLength 0x25 bDescriptorType 0x01 bDescriptorSubtype 0x01 bNumEmbMIDIJack 0x03 baAssocJackID(1)
Microsoft OS Descriptor:
0x02 bLength 0x0D bDescriptorType Hex dump: 0x02 0x0D
String Descriptor Table
Index LANGID String 0x00 0x0000 0x0409 0x01 0x0409 "Fractal Audio Systems" 0x02 0x0409 "AXE-FX II" 0x08 0x0409 "AXE-FX II Audio Intfc" 0x03 0x0409 "AXE-FX II" 0x04 0x0409 "DevClk" 0x05 0x0409 "AXE-FX II Audio Out" 0x06 0x0409 "AXE-FX II Audio In" 0x07 0x0409 "AXE-FX II MIDI" 0x09 0x0409 "AXE-FX II MIDI In" 0x0A 0x0409 "AXE-FX II MIDI Out"
I've debugged the MidiInputDevice and when my sysex gets bad, it misses 4 bytes. The usb bulk transfer already misses 4 bytes, so should it be an usb buffer overrun ? If yes, how can i prevent this ?
It seems bulkTransfer is buggy : http://stackoverflow.com/questions/9108548/android-usb-host-bulktransfer-is-losing-data I'm gonna try using UsbRequest
Testing with UsbRequest is definitely a good idea.
For real-time midi, UsbRequest is way too laggy, but for sysex, it wouldn’t make a big difference as timing is no concern.
Von: AlGrenadine [mailto:[email protected]] Gesendet: Freitag, 25. November 2016 14:40 An: kshoji/USB-MIDI-Driver Cc: planethcom; Comment Betreff: Re: [kshoji/USB-MIDI-Driver] MIDI Input Broken on Android 4 (#58)
It seems bulkTransfer is buggy : http://stackoverflow.com/questions/9108548/android-usb-host-bulktransfer-is-losing-data I'm gonna try using UsbRequest
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kshoji/USB-MIDI-Driver/issues/58#issuecomment-262959079 , or mute the thread https://github.com/notifications/unsubscribe-auth/AF5BLLuaMIVXFL6Gj9jkyDCcksUpkkrDks5rBuVEgaJpZM4JDeW0 .Das Bild wurde vom Absender entfernt.
Exactly the same problem with UsbRequest...
Was to be expected since UsbRequest does nothing else than bulkTransfer internally. What you can try: Completely disable any midi out functionality, so that the midioutputdevice and its thread gets not started at all. As far as I remember, the um one does in and out over the same endpoint, and that could be the problem. Definitely worth a try. On Nov 25, 2016 3:06 PM, AlGrenadine [email protected] wrote:Exactly the same problem with UsbRequest...
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
But my USB midi device has the same problem and its endpoints are different as you can see in the above USB descriptors...
Just found the original issue I was referring to. Maybe that's helpful. https://github.com/kshoji/USB-MIDI-Driver/issues/40
On Nov 25, 2016 3:20 PM, AlGrenadine [email protected] wrote:But my USB midi device has the same problem and its endpoints are different as you can see in the above USB descriptors...
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
Yes i saw this fix in the code, it already filters MidiInputDevice creation on the same endpoints. But my problem is not the same, my midi input has only 1 endpoint...
Ok, understood. So it looks like the only thing you can do is to debug it bit by bit and search for the missing 4 bytes. If it's in bulk transfer, then it simply won't work with these older android versions. On Nov 25, 2016 3:31 PM, AlGrenadine [email protected] wrote:Yes i saw this fix in the code, it already filters MidiInputDevice creation on the same endpoints. But my problem is not the same, my midi input has only 1 endpoint...
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
It's now working with um one. The problem persists on usb device, where speed is crucial. So for what I understand it seems the data handling in InputMidiDevice is too slow and some data gets lost between 2 bulk reads, because the usb internal buffer may be overrun...
That makes sense, yes. Just wondering, how did you get it to work with the um one? What you can do to avoid the buffer underruns is to put the incoming sysex data into a queue and process it in another thread. That way the midiinputdevice thread is less time intensive and probably fast enough to get the bulkdata in time. On Nov 25, 2016 4:01 PM, AlGrenadine [email protected] wrote:It's now working with um one. The problem persists on usb device, where speed is crucial. So for what I understand it seems the data handling in InputMidiDevice is too slow and some data gets lost between 2 bulk reads, because the usb internal buffer may be overrun...
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
Yes that's what i plan to do but i'm very new to Android and Java dev... Any directions on how to achieve this?
I'd simply create an ArrayDeque (it's the fastest java queue type) and then put the data into it instead of processing it. Then in another thread that you create, process it the same way as it is now in midiindevice. That way you give your engine all the time it needs to process. If it's not real-time you can just instantiate new buffer arrays to fill the data into, no pooling mandatory. To get the very best performance you can pre-instantiate the buffer arrays and pool them for reuse (also in another ArrayDeque). On Nov 25, 2016 5:46 PM, AlGrenadine [email protected] wrote:Yes that's what i plan to do but i'm very new to Android and Java dev... Any directions on how to achieve this?
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
The ArrayDeque and second Thread handling the raw usb data was the solution :) I had to handle raw usb input in C++ by the way in order to maintain good thruput
Talked too fast, still have some bytes missing...
Which solution did you implement? I'd recommend to go for the second I mentioned, the one with the pre-initialized buffer pool. That's much faster than instantiating byte arrays at runtime. You can still have a fallback in case of a pool underrun, where you just resize the pool if required. On Nov 28, 2016 2:27 PM, AlGrenadine [email protected] wrote:Talked too fast, still have some bytes missing...
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
I used the ArrayDeque, i'm now trying with a https://developer.android.com/reference/java/util/concurrent/BlockingQueue.html
Blocking queue is slower. What I mean is to use 2 ArrayDeques, one as queue, and one as byte array pool, so that you can reuse the arrays once they are processed. Also the pool should be pre-initialized during startup. Allocating continuous heap memory at runtime takes a lot of time in java since it triggers the garbage collector. On Nov 28, 2016 2:37 PM, AlGrenadine [email protected] wrote:I used the ArrayDeque, i'm now trying with a https://developer.android.com/reference/java/util/concurrent/BlockingQueue.html
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
Oh ok that may be my problem, is still allocate new arrays . Trying to implement what you said, thanks ;)