TOP Contributors

  1. MIKROE (2659 codes)
  2. Alcides Ramos (356 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136953 times)
  2. FAT32 Library (70069 times)
  3. Network Ethernet Library (56015 times)
  4. USB Device Library (46338 times)
  5. Network WiFi Library (41957 times)
  6. FT800 Library (41266 times)
  7. GSM click (29051 times)
  8. mikroSDK (26480 times)
  9. PID Library (26447 times)
  10. microSD click (25411 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

USB-MIDI Demo

Rating:

0

Author: MIKROE

Last Updated: 2024-04-04

Package Version: 2.0.0.6

mikroSDK Library: 2.0.0.0

Category: USB

Downloaded: 38 times

Not followed.

License: MIT license  

The application demonstrates USB MIDI functionality.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "USB-MIDI Demo" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "USB-MIDI Demo" changes.

Do you want to report abuse regarding "USB-MIDI Demo".

  • Information
  • Comments (0)

mikroSDK Library Blog

USB MIDI

Code developed on UNI-DS v8 and it can be used on other MIKROE development boards as well. Code was developed with purpose of easier understanding functions for USB Musical Instrument Digital Interface (MIDI).



Code description

Depending on the numbers in the note_sequence array, different melodies will play. By default there is a "Happy Birthday" melody playing.


Hardware Support

image

This code was developed on UNI-DS v8 board. For this hardware to work according to program, it is necessary to:

  • Pull USB/UART switches that turn on PSW and ID lines (in the BOARD SETUP part, on picture -> bigger red square on the right);
  • Connect USB-C to USB connector (in the USB part, on picture -> smaller red square on the right);

Functions Description

All functions used in main project are located in MikroSDK.USB.Tiny and MikroSDK.USB.HW.

Functions in main file:

  • bool tusb_init(void)
    • initializes device/host stack;
  • uint32_t tud_midi_available(void)
    • gets the number of bytes available for reading;
  • bool tud_midi_packet_read(uint8_t packet[4])
    • reads event packet;
  • uint32_t tud_midi_stream_write(uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
    • writes byte stream;

Software Support

We provide demo code for testing all MIDI functions contained in libraries MikroSDK.USB.Tiny and MikroSDK.USB.HW, available in mikroSDK 2.0.

In order to make this example work, proper clock setup is needed. To create a setup with the adequate clock scheme, follow these steps:

  1. Click on Setups and select New.
  2. Choose GCC ARM or RISC-V GNU compiler.
  3. Choose the board you are using.
  4. Choose the MCU that has USB functionality and click Advanced to enter clock configuration window.
  5. In the Config scheme field choose the option with _USB in the end.
  6. If there is no such option, then either USB for this MCU is not supported in current version of SDK, or this MCU doesn't have USB functionality.
  7. Complete the setup.
  8. Program the MCU with created setup.
  9. Download MIDI-OX application if using windows OS.
  10. Open MIDI-OX application and you will be able to hear the melody that you programmed.
  11. If you have an error No MIDI devices when you're opening MIDI-OX, reset the MCU.
  12. If you see the MIDI notes on the screen, but don't hear the melody, go to Options -> MIDI Devices and choose Microsoft GS Wavetable Synth in the MIDI Outputs field.

ALSO FROM THIS AUTHOR

SPI Isolator click

0

The click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]

Servo click

0

Servo click is a 16-channel PWM servo driver with the voltage sensing circuitry. It can be used to simultaneously control 16 servo motors, each with its own programmable PWM signal.

[Learn More]

USB to I2C 2 click

0

USB to I2C 2 Click is a compact add-on board that contains a general-purpose USB to I2C serial interface. This board features the FT201X, a full-speed USB to I2C protocol converter from FTDI. The FT201X converts USB2.0 full-speed to an I2C serial interface capable of operating up to 3.4MBit/s, with low power consumption (typical 8mA). The entire USB protocol is handled on the chip itself, where no USB-specific firmware programming is required. It also has a fully-integrated 2048 byte Multi-Time-Programmable (MTP) memory for storing device descriptors and CBUS I/O user-desirable configuration. This Click board™ includes the complete FT-X series feature set and enables USB to be added into a system design quickly and easily over an I2C interface.

[Learn More]