Giter Site home page Giter Site logo

Add MIDI device class about libusb_stm32 HOT 8 OPEN

dmitrystu avatar dmitrystu commented on May 19, 2024
Add MIDI device class

from libusb_stm32.

Comments (8)

xcvista avatar xcvista commented on May 19, 2024 2

Another common class I would suggest is mass storage.

from libusb_stm32.

dmitrystu avatar dmitrystu commented on May 19, 2024

The MSC class definitions are partially done.

from libusb_stm32.

kisielk avatar kisielk commented on May 19, 2024

That should probably be tracked in a separate issue ;)

from libusb_stm32.

kisielk avatar kisielk commented on May 19, 2024

I already have a functional MIDI implementation using ST's Device Library for the F072, F373 and F746, so I should be able to port it over to this lib when I have some time..

from libusb_stm32.

WojtaCZ avatar WojtaCZ commented on May 19, 2024

I know this is a old one, but has anyone made any progress on the MIDI class?

from libusb_stm32.

dmitrystu avatar dmitrystu commented on May 19, 2024

No one but me. :)
But it's yet not completed nor tested. See this branch.

from libusb_stm32.

GrantMTG avatar GrantMTG commented on May 19, 2024

We need to add another struct to usb_midi.h (there might be other things I discover as I go through this as well):

// Class-Specific AC (Audio Control) Interface Descriptor
struct usb_midi_ac_interface_desc {
   uint8_t  bLength;              /**<\brief Size of this descriptor in bytes. */
   uint8_t  bDescriptorType;      /**<\brief CS_INTERFACE descriptor type.     */
   uint8_t  bDescriptorSubType;   /**<\brief MIDI_HEADER descriptor subtype.  */
   uint16_t bcdADC;               /**<\brief AC SubClass Specification Release Number. */
   uint16_t wTotalLength;         /**<\brief Total size of class specific descriptors. */
   uint8_t  bInCollection;        /**<\brief Number of streaming interfaces.   */
   uint8_t  bInterfaceNumber;     /**<\brief Index of the current interface.   */
} __attribute__ ((packed));

from libusb_stm32.

GrantMTG avatar GrantMTG commented on May 19, 2024

The only other things that I think are missing from usb_midi.h are,

(a) adding the definition for USB_MIDI_SUBCLASS_STREAM

#define USB_CLASS_MIDI              0x01U   /**<\brief MIDI Device class */
#define USB_MIDI_SUBCLASS_CONTROL   0x01U   /**<\brief Data Interface class */
#define USB_MIDI_SUBCLASS_STREAM    0x03U   /**<\brief MIDI Streaming */

(b) Preferred spelling of USB_MIDI_JACK_EXTERNAL

//#define USB_MIDI_JACK_EXTERNL       0x02U   /**<\brief Declares external Jack */ 
#define USB_MIDI_JACK_EXTERNAL      0x02U   /**<\brief Declares external Jack */ 

(c) Correction of baAssocJackID in usb_midi_class_ep_descriptor

struct usb_midi_class_ep_descriptor {
    uint8_t     bLength;                /**<\brief Size of the descriptor, in bytes.*/
    uint8_t     bDescriptorType;        /**<\brief CS_ENDPOINT descriptor.*/
    uint8_t     bDescriptorSubType;     /**<\brief USB_DTYPE_MIDI_EP_GENERAL subtype.*/
    uint8_t     bNumEmbMIDIJack;        /**<\brief Number of Embedded MIDI Jacks.*/
//    uint8_t     baAssocJackID[];        /**<\brief Embedded jacks ID's */ 
    uint8_t     baAssocJackID;          /**<\brief Embedded jacks ID's */ 
} __attribute__((packed));

(d) and finally, if it is not elsewhere (I didn't see it), the 9-byte version of the bulk endpoints. This one I am not 100% sure of yet since I have not run the USB Compliance Suite and both endpoint versions for USB MIDI.

struct usb_bulk_endpoint_desc {
    uint8_t  bLength;             /**<\brief Size of the descriptor, in bytes. */
    uint8_t  bDescriptorType;     /**<\brief Endpoint descriptor.*/
    uint8_t  bEndpointAddress;    /**<\brief Logical address of the endpoint within the device for
                                   * the current configuration, including direction mask. */
    uint8_t  bmAttributes;        /**<\brief Endpoint attributes, \ref USB_ENDPOINT_DEF.  */
    uint16_t wMaxPacketSize;      /**<\brief Size of the endpoint bank, in bytes. This indicates the
                                   * maximum packet size that the endpoint can receive at a time. */
    uint8_t  bInterval;           /**<\brief Ignored for bulk.   */
    uint8_t  bRefresh;            /**<\brief               */
    uint8_t  bSynchAddress;       /**<\brief               */
} __attribute__((packed));

See:
Example: https://github.com/kshoji/USB-MIDI-Link/blob/master/firmware/main.c
Discussion elsewhere: libopencm3/libopencm3#1130

from libusb_stm32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.