Hello! Welcome to Embedic!
This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Embedded Events > Arduino-based MIDI controller

Arduino-based MIDI controller

Date: 21-07-2021 ClickCount: 76

This project is to take an old computer mouse and turn it into a MIDI controller. The controller will utilize all the functions of the old computer mouse. That is, mapping different MIDI commands to the X and Y axes for left click, right click, mouse wheel click, mouse wheel scroll and mouse movement.

The midi pitch is mapped to the X-axis position and the midi volume (called "velocity") is mapped to the Y-axis position. The position of the mouse wheel will determine the value of the continuous controller. In the default setting, it is CC1 - mod wheel value.

The operation of the device is based on two modes, which can be switched by clicking on the mouse wheel. In Glissando mode, the device can only play one MIDI note at a time. A left or right mouse click maps to the same note. Moving the mouse while clicking allows seamless movement between notes. In interval mode, left and right mouse button clicks map to different notes, so intervals can be played by first clicking one mouse button, then moving the X-axis position of the mouse, and then clicking the other mouse button.

Circuit diagram.

Circuit diagram

User interface.

Gives the controller an intuitive and fully built user interface so that the user does not have to rely on the computer display in order to use the device. This means that the controller can be used with any device capable of reading MIDI via USB. This is done by using an LED dual color 8 * 8 matrix and a 128 * 64 monochrome I2C display.

The LED matrix provides a representation of the X and Y axis positions of the mouse, with the light pattern on the X axis being based on one octave of the C major scale. The pattern is shown below and it will repeat from -5 to +4 octaves above middle C.

LED matrix

Unlike the X-axis, the Y-axis has no "loops", so the 127 possible volume values are mapped to the 8 positions of the matrix. This is shown in the figure below:

 Y-axis

In Glissando mode, the matrix lights up green to show the mouse position before a note is pressed, and red when a note is pressed. In interval mode, the matrix is red when the left mouse button is pressed, orange when the right mouse button is pressed, and green at the current mouse position.

matrix

In addition to the LED matrix, there is a 128 * 64 OLED monochrome display showing the current notes and volume, as well as the position and mode of operation of the mouse wheel. An annotated image of this display is shown below.

An annotated image of this display

Assembly.

With the components connected on the breadboard, install the following libraries on the Arduino IDE using the Library Manager:

  • MIDIUSB (for sending MIDI over USB)
  • Adafruit_LEDBackpack (for communicating with the LED matrix)
  • Adafruit_GFX (for OLED displays)
  • Adafruit_SSD1306 (for communicating with OLED displays)

Install the following library from GitHub to communicate with the PS/2 mouse adapter - ps2 mouse.

Download the code from the GitHub repository and upload it to Arduino.

Making music.

With the circuit connected and code uploaded, connect a ps/2 scrolling mouse and check if the UI is working properly. If so, the device can now be used as a MIDI controller. If you have never used a MIDI controller on a PC to make music before, it is recommended that you refer to the MIDI device documentation for instructions on MIDI sound generation on Windows.

If you have used MIDI before, you can use the device as you would any other MIDI controller. In the image below, it is shown how to use Pro Tools 12.

 use the device as you would any other MIDI controller

Note that the MIDI channel is fixed at channel 1 (to change this value, change the midchannel constant in the code). The mouse wheel is mapped to CC 1, which can also be changed in the code.

If you modify the code slightly, you can try to change the sensitivity of the mouse, or the X and Y positions or the MIDI parameters corresponding to the mouse wheel.

  • Difference between ATMEGA328P-PU and ATMEGA16A-PU
  • STM32WB Wireless Family of MCUs

Hot Products

  • ADSP-BF516BSWZ-4F4

    Manufacturer: Analog Devices

    IC DSP 16/32B 400MHZ LP 176LQFP

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • ADSP-BF518BSWZ-4F4

    Manufacturer: Analog Devices

    IC DSP 16/32B 400MHZ LP 176LQFP

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • PIC16C710-04/P

    Manufacturer: Microchip

    IC MCU 8BIT 896B OTP 18DIP

    Product Categories: 8bit MCU

    Lifecycle:

    RoHS:

  • TMS320C6747BZKB3

    Manufacturer: Texas Instruments

    IC DSP FLOATING POINT 256BGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty