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

M-Audio Keystation 49 MK3 recognized but no MIDI events received #73

Closed
Nephiel opened this issue Apr 25, 2021 · 11 comments
Closed

M-Audio Keystation 49 MK3 recognized but no MIDI events received #73

Nephiel opened this issue Apr 25, 2021 · 11 comments

Comments

@Nephiel
Copy link

Nephiel commented Apr 25, 2021

This MIDI keyboard model is class compliant and seems to be recognized, but no MIDI events are received at all.

Here is the USB_MIDI_dump with #define DEBUG_USB_HOST :

MIDI Init
Addr:01
VID:0763 PID:3110 #Conf:01

Conf:01 Int:00 Alt:00 EPs:00 IntCl:01 IntSubCl:01
No MIDI Device

Conf:01 Int:01 Alt:00 EPs:02 IntCl:01 IntSubCl:03
MIDI Device
-EPAddr:81 bmAttr:02 MaxPktSz:40
Endpoint descriptor:
 Length:	09
 Type:		05
 Address:	81
 Attributes:	02
 MaxPktSize:	0040
 Poll Intrv:	00
-EPAddr:02 bmAttr:02 MaxPktSz:40
Endpoint descriptor:
 Length:	09
 Type:		05
 Address:	02
 Attributes:	02
 MaxPktSize:	0040
 Poll Intrv:	00

NumEP:03
Conf:01
EPin :81
EPout:02
Init done.
VID:0763, PID:3110

Tried all of the keys, wheels, fader and buttons, but nothing appears on the dump after this point.

USBH_MIDI_desc output:

VID:0763, PID:3110
Start


01
--

Device descriptor: 
Descriptor Length:	12
Descriptor type:	01
USB version:		0110
Device class:		00
Device Subclass:	00
Device Protocol:	00
Max.packet size:	08
Vendor  ID:		0763
Product ID:		3110
Revision ID:		0105
Mfg.string index:	01
Prod.string index:	02
Serial number index:	00
Number of conf.:	01

Configuration descriptor:
Total length:		0085
Num.intf:		02
Conf.value:		01
Conf.string:		00
Attr.:			C0
Max.pwr:		32

Interface descriptor:
Intf.number:		00
Alt.:			00
Endpoints:		00
Intf. Class:		01
Intf. Subclass:		01
Intf. Protocol:		00
Intf.string:		00

<<<AUDIO_CONTROL>>>
Unknown descriptor:
Length:		09
Type:		24
Contents:	01000109000101

Interface descriptor:
Intf.number:		01
Alt.:			00
Endpoints:		02
Intf. Class:		01
Intf. Subclass:		03
Intf. Protocol:		00
Intf.string:		00

<<<MIDIStreaming>>>

MS Interface descriptor
07240100016100
DescriptorSubtype: 01
USB_DESCRIPTOR_CS_INTERFACE :	MS_HEADER
MIDIStreaming SubClass Specification Release number: 0100
wTotalLength:		0061

MS Interface descriptor
06240201010E
DescriptorSubtype: 02
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_IN_JACK(Embedded)
JackType:	01
JackID:		01

MS Interface descriptor
062402020200
DescriptorSubtype: 02
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_IN_JACK(External)
JackType:	02
JackID:		02

MS Interface descriptor
06240201030F
DescriptorSubtype: 02
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_IN_JACK(Embedded)
JackType:	01
JackID:		03

MS Interface descriptor
062402020400
DescriptorSubtype: 02
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_IN_JACK(External)
JackType:	02
JackID:		04

MS Interface descriptor
09240301090102010E
DescriptorSubtype: 03
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_OUT_JACK(Embedded)
JackType:	01
JackID:		09
NrInputPins:	01
02010E

MS Interface descriptor
092403020A01010100
DescriptorSubtype: 03
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_OUT_JACK(External)
JackType:	02
JackID:		0A
NrInputPins:	01
010100

MS Interface descriptor
092403010B0104010F
DescriptorSubtype: 03
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_OUT_JACK(Embedded)
JackType:	01
JackID:		0B
NrInputPins:	01
04010F

MS Interface descriptor
092403020C01030100
DescriptorSubtype: 03
USB_DESCRIPTOR_CS_INTERFACE :	MIDI_OUT_JACK(External)
JackType:	02
JackID:		0C
NrInputPins:	01
030100

Endpoint descriptor:
Endpoint address:	81
Attr.:			02(Bulk)
Max.pkt size:		0040
Polling interval:	00

MS Endpoint descriptor
06250102090B
USB_DESCRIPTOR_CS_ENDPOINT :	MS_GENERAL
bNumEmbMIDIJack: 02
090B

Endpoint descriptor:
Endpoint address:	02
Attr.:			02(Bulk)
Max.pkt size:		0040
Polling interval:	00

MS Endpoint descriptor
062501020103
USB_DESCRIPTOR_CS_ENDPOINT :	MS_GENERAL
bNumEmbMIDIJack: 02
0103


Addr:1(0.0.1)

And the output of lsusb -vvv:

Bus 001 Device 057: ID 0763:3110 M-Audio 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0763 M-Audio
  idProduct          0x3110 
  bcdDevice            1.05
  iManufacturer           1 M-Audio
  iProduct                2 Keystation 49 MK3
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0085
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0009
        bInCollection           1
        baInterfaceNr(0)        1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      3 MIDI Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      MIDIStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0061
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               1 Embedded
        bJackID                 1
        iJack                  14 Keystation 49 MK3(USB MIDI)
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               2 External
        bJackID                 2
        iJack                   0 
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               1 Embedded
        bJackID                 3
        iJack                  15 Keystation 49 MK3(Transport)
      MIDIStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (MIDI_IN_JACK)
        bJackType               2 External
        bJackID                 4
        iJack                   0 
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               1 Embedded
        bJackID                 9
        bNrInputPins            1
        baSourceID( 0)          2
        BaSourcePin( 0)         1
        iJack                  14 Keystation 49 MK3(USB MIDI)
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               2 External
        bJackID                10
        bNrInputPins            1
        baSourceID( 0)          1
        BaSourcePin( 0)         1
        iJack                   0 
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               1 Embedded
        bJackID                11
        bNrInputPins            1
        baSourceID( 0)          4
        BaSourcePin( 0)         1
        iJack                  15 Keystation 49 MK3(Transport)
      MIDIStreaming Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (MIDI_OUT_JACK)
        bJackType               2 External
        bJackID                12
        bNrInputPins            1
        baSourceID( 0)          3
        BaSourcePin( 0)         1
        iJack                   0 
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
        bRefresh                0
        bSynchAddress           0
        MIDIStreaming Endpoint Descriptor:
          bLength                 6
          bDescriptorType        37
          bDescriptorSubtype      1 (GENERAL)
          bNumEmbMIDIJack         2
          baAssocJackID( 0)       9
          baAssocJackID( 1)      11
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
        bRefresh                0
        bSynchAddress           0
        MIDIStreaming Endpoint Descriptor:
          bLength                 6
          bDescriptorType        37
          bDescriptorSubtype      1 (GENERAL)
          bNumEmbMIDIJack         2
          baAssocJackID( 0)       1
          baAssocJackID( 1)       3
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Let me know if I can help get this keyboard model supported.

@Nephiel Nephiel changed the title Keystation 49 MK3 recognized but no MIDI events received M-Audio Keystation 49 MK3 recognized but no MIDI events received Apr 25, 2021
@YuuichiAkagawa
Copy link
Owner

Do you have enough power ?
Can you try connecting via a Powered USB hub?

Please check inTransfer() return value.

USBH_MIDI/usbh_midi.cpp

Lines 377 to 379 in 808b5a1

uint8_t r = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
if( *bytes_rcvd < (MIDI_EVENT_PACKET_SIZE-4)){

↓ insert #ifdef - #endif

        uint8_t  r = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
#ifdef DEBUG_USB_HOST
        if( r )
                USBTRACE2("inTransfer():", r);
#endif
        if( *bytes_rcvd < (MIDI_EVENT_PACKET_SIZE-4)){

@Nephiel
Copy link
Author

Nephiel commented Apr 26, 2021

Here's the dump with check in place:

[...]
NumEP:03
Conf:01
EPin :81
EPout:02
Init done.
VID:0763, PID:3110
inTransfer():04
inTransfer():04
inTransfer():04
inTransfer():04
inTransfer():04
inTransfer():04

Steady stream of inTransfer():04 continues after that. Pressing keys has no effect.

Also tested power draw with a meter, Arduino Pro Micro + USB Host board + Keystation MK3 only draw about 60 mA.

@YuuichiAkagawa
Copy link
Owner

Hmmm
The Keystation 49 MK3 responds to NAK, so USB communication is possible. But I don't understand why it doesn't send MIDI events.

@doctea
Copy link

doctea commented Feb 14, 2022

Did a solution to this ever get found? I think I'm having the same problem with an Arturia Beatstep. Here's the output if I enable ENABLE_UHS_DEBUGGING and EXTRADEBUG:

`MIDI Init
USBH_MIDI version 000600
Addr:01
VID:1C75 PID:0206 #Conf:01

STEP1: MIDI Start
Interface descriptor:
Inf#: 00
Alt: 00
EPs: 00
IntCl: 01
IntSubcl: 01
Protocol: 00
-MIDI not found

Interface descriptor:
Inf#: 01
Alt: 00
EPs: 02
IntCl: 01
IntSubcl: 03
Protocol: 00
+MIDI found
>Extracting endpoint
Endpoint descriptor:
Length: 09
Type: 05
Address: 02
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 00
+valid EP found.

Extracting endpoint
Endpoint descriptor:
Length: 09
Type: 05
Address: 81
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 00
+valid EP found.
STEP1: MIDI,NumEP:03
Conf:01
EPin :81
EPout:02
VID:1C75, PID:0206
Init done.
inTransfer():04
SendData():00003746
inTransfer():04
inTransfer():04
inTransfer():04
inTransfer():04
inTransfer():04
[...etc...]
`

(ugh, the >'s break code formatting, but hopefully you get the gist!)

@YuuichiAkagawa
Copy link
Owner

YuuichiAkagawa commented Feb 17, 2022

Try commenting out the following line in Usb.cpp.
https://github.com/felis/USB_Host_Shield_2.0/blob/9184254b87b2c65378ba83d653457a48c01d5396/Usb.cpp#L241-L246

Like this.

                rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
                if(rcode == hrTOGERR) {
                        // yes, we flip it wrong here so that next time it is actually correct!
//                        pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1;
//                        regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
                        continue;
                }
                if(rcode) {

@doctea
Copy link

doctea commented Feb 17, 2022

Try commenting out the following line in Usb.cpp. https://github.com/felis/USB_Host_Shield_2.0/blob/9184254b87b2c65378ba83d653457a48c01d5396/Usb.cpp#L241-L246

Success! Sending and receiving MIDI note on/offs now seems to work! Thank you! :D

Are there any drawbacks to this modification -- will this have a negative impact on the of other devices? (I've tested it with an Akai APCmini, and that seems to work, but maybe there is a case where it causes a problem?)

I note that although noteon/noteoff messages seems to work fine in both directions, that using MIDI.sendClock() to send clock to the Beatstep doesn't seem to work -- is this perhaps handled in a different function that needs to be similarly modified? I have also tested with an Arturia Keystep, and that DOES receive the MIDI clock OK. [Edit: actually, upon further testing, I'm finding the Beatstep behaving strangely in other ways too - and am starting to think this is to do with the Beatstep configuration itself. I'll explore some more with this over the weekend and see what I can figure out]

@YuuichiAkagawa
Copy link
Owner

YuuichiAkagawa commented Feb 18, 2022

Sorry, I made a mistake in one place, please try again.
Only two lines need to be commented out.

This problem is on the USB_Host_Shield_2.0 side, not the MIDI driver.
felis/USB_Host_Shield_2.0#438

2 . Do not flip toggle value on Toggle Error

Some devices have problems with the initial toggle, and BeatStep is one of them.

will this have a negative impact on the of other devices?

Usually there is no problem.

@doctea
Copy link

doctea commented Feb 18, 2022

@doctea Sorry, I made a mistake in one place, please try again. Only two lines need to be commented out.

EDIT -- see below!

Thanks -- I've changed my copy of the library as you suggested here. It doesn't seem to make any difference that I can see, though. The Beatstep still doesn't respond to clock - was this meant to solve this problem? I've been through the settings in the Beatstep control app, hoping to find something like a 'MIDI clock mode' option, but had no such luck, so I don't know what else to try here..

This problem is on the USB_Host_Shield_2.0 side, not the MIDI driver. felis/USB_Host_Shield_2.0#438

Would it be better to solve this problem by applying that pull request to my copy of the USB_Host_Shield_2.0 library rather than commenting out the two lines you suggest?

Edit: so to answer my own confusion! I've applied the above pull request to the USB_Host_Shield_2.0 library (https://patch-diff.githubusercontent.com/raw/felis/USB_Host_Shield_2.0/pull/438.patch) and the Beatstep now seems to be receiving clock!

Steps to apply the patch for anyone who wants to replicate this:-

  1. cd libraries/USB_Host_Shield_2.0
  2. wget https://patch-diff.githubusercontent.com/raw/felis/USB_Host_Shield_2.0/pull/438.patch
  3. patch -p1 < 438.patch

The other part of the puzzle here was that the Beatstep needs to receive an external MIDI start message before it will be clocked externally!

@YuuichiAkagawa
Copy link
Owner

@doctea
I thought that the cause of not working in BeatStep might be the toggle problem and suggested commenting it out. During my research, I found a pull request for USB_Host_Shield_2.0 and introduced it to you.
If this pull request fix solves the problem, then it should be adopted.

@doctea
Copy link

doctea commented Feb 19, 2022

@doctea I thought that the cause of not working in BeatStep might be the toggle problem and suggested commenting it out. During my research, I found a pull request for USB_Host_Shield_2.0 and introduced it to you. If this pull request fix solves the problem, then it should be adopted.

Many thanks for your help, I understand now! Yes it seems to solve the problem and should be adopted :)

@YuuichiAkagawa
Copy link
Owner

@Nephiel
OK, I purchased Keystation for verification.
I have confirmed that it works in two cases: with an external power supply connected to the Aruduino and through a powered USB hub.

Also tested power draw with a meter, Arduino Pro Micro + USB Host board + Keystation MK3 only draw about 60 mA.

Unfortunately, that is current consumption under stable conditions. This keyboard draws a large current when it is powered on.
KeyStation49mk3-power

I will say it again. You must connect via a powered USB hub.

I've wasted my money, you know. 😭

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

3 participants