Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIDI Input Broken on Android 4 #58

Open
JasonMcClinsey opened this issue Jul 1, 2016 · 34 comments
Open

MIDI Input Broken on Android 4 #58

JasonMcClinsey opened this issue Jul 1, 2016 · 34 comments

Comments

@JasonMcClinsey
Copy link

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.

@Blackaddr
Copy link

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.

@zhangyufei49
Copy link

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 linejava waiterThread.start() of MidiInputDevice constructor.
  • Find this line contains deviceAttachedListener.onMidiInputDeviceAttached(midiInputDevice);
    in MidiDeviceConnectionWacther and add this line blow it: midiInputDevice.start2Work();

@AlGrenadine
Copy link

Still doesn't work for me, even with FlyingFishBird solution... any idea ? :/

@AlGrenadine
Copy link

Ok now i get midi input but on large sysex receptions sometimes the sysex gets mangled, any idea ?

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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...

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

Sadly, i only have 1 MidiInputDevice thread running...
It acts like some bytes get lost occasionnally, the term 'mangles' wasn't the good one

@AlGrenadine
Copy link

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"

@AlGrenadine
Copy link

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 ?

@AlGrenadine
Copy link

It seems bulkTransfer is buggy : http://stackoverflow.com/questions/9108548/android-usb-host-bulktransfer-is-losing-data
I'm gonna try using UsbRequest

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

Exactly the same problem with UsbRequest...

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

But my USB midi device has the same problem and its endpoints are different as you can see in the above USB descriptors...

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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...

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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...

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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?

@planethcom
Copy link

planethcom commented Nov 25, 2016 via email

@AlGrenadine
Copy link

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

@AlGrenadine
Copy link

Talked too fast, still have some bytes missing...

@planethcom
Copy link

planethcom commented Nov 28, 2016 via email

@AlGrenadine
Copy link

I used the ArrayDeque, i'm now trying with a https://developer.android.com/reference/java/util/concurrent/BlockingQueue.html

@planethcom
Copy link

planethcom commented Nov 28, 2016 via email

@AlGrenadine
Copy link

Oh ok that may be my problem, is still allocate new arrays . Trying to implement what you said, thanks ;)

@AlGrenadine
Copy link

Still doesn't work, i can't see why, here is the code in MidiInputDevice :
http://pastebin.com/hAR8WHpQ
If you have an idea...

@planethcom
Copy link

planethcom commented Nov 28, 2016 via email

@AlGrenadine
Copy link

@robtoll
Copy link

robtoll commented Jul 2, 2017

If you're still having any problems with this, you might find my solution helpful.

#63

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants