2# The MIDIUSB Library - MIDI Programming for the Arduino -

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 14. 07. 2024
  • đŸŽč Download the Arduino Sketch: go.musiconerd.com/files-download
    đŸŽč Nerd Musician Pro: go.musiconerd.com/nerd-musici...
    đŸŽč DIY MIDI Controller Workshop: go.musiconerd.com/diy-midi-co...
    đŸŽč Curso Fazendo MĂșsica com Arduino em PortuguĂȘs: go.musiconerd.com/fazendo-mus...
    đŸŽč Which Arduino to choose: ‱ The 5 BEST ARDUINOS fo...
    In this video, I'll show you how to use the MIDIUSB library. One can use the MIDIUSB lib to make MIDI class-compliant devices using any Arduino with the ATmega32U4 microcontroller, such as the Arduino Leonardo, Micro, and Pro Micro.
    This library is my favorite for building DIY MIDI Controllers with the Arduino because it's MIDI class-compliant (plug and play), so no need for other software such as Hairless MIDI.
    MIDIUSB Library documentation: github.com/arduino-libraries/...
    MIDI note numbers: computermusicresource.com/mid...
    Besides, I'll teach you two key programming concepts: "Arrays" and the "random()" function.
    Learn more about these concepts here: www.arduino.cc/reference/en/
    0:00 - Intro
    0:56 - The MIDIUSB Library
    8:30 - Random()
    10:11 - Arrays
    14:42 - Making Music with Arduino
    Translated titles:
    2# ProgramaciĂłn MIDI para Arduino-Biblioteca MIDIUSB
    2 # MIDI-Programmierung fĂŒr die Arduino-MIDIUSB-Bibliothek
    2# Programmation MIDI pour l'Arduino-BibliothĂšque MIDIUSB
    2# Programação MIDI para o Arduino-Biblioteca MIDIUSB
    Arduino à€•à„‡ à€Čà€żà€ 2 # MIDI à€Șà„à€°à„‹à€—à„à€°à€Ÿà€źà€żà€‚à€—-MIDIUSB à€Čà€Ÿà€‡à€Źà„à€°à„‡
    2# Arduino甹MIDIăƒ—ăƒ­ă‚°ăƒ©ăƒŸăƒłă‚°-MIDIUSBăƒ©ă‚€ăƒ–ăƒ©ăƒȘ
  • Hudba

Komentáƙe • 56

  • @shulkerdragon8653
    @shulkerdragon8653 Pƙed 6 měsĂ­ci

    Wonderfully explained!

  • @juliocosta5818
    @juliocosta5818 Pƙed 11 dny

    And that, my friends, is how jazz was discovered :)

  • @genghisbunny
    @genghisbunny Pƙed rokem

    Excited for this one!

  • @ismael4389
    @ismael4389 Pƙed 10 měsĂ­ci

    Valeu Nerd! isso me ajudou a compreender como funciona a biblioteca, pretendo colocar-o em um ĂłrgĂŁo antigo que restaurei

  • @KandMe1
    @KandMe1 Pƙed rokem

    I got in mind to create a node for a midi hub that keeps a copy of the simple script for the 16 channels plus editable globals of setups of the midi devices. This idea is a resolve so I do not have to pay for espensive subscriptions on my iPad for apps that do this. No knowledge on how to do that but that is what I have in mind. It seems a good resolve especially if I can extend the script over time so it becomes an app that facilitates other functions associated with my array midi devices.

  • @ClNoBody
    @ClNoBody Pƙed 4 měsĂ­ci

    Good stuff and helpful as I'm getting a Leonardo today to start prototyping.
    I disagree about using the noteOn function to turn off the note, especially when you have a noteOff function. Then you also have a comment when you shouldn't need one.

  • @AnteroJunior
    @AnteroJunior Pƙed 10 měsĂ­ci

    Mano, tĂŽ usando uma esp32, uma placa Touch e somente 10ms de delay no loop, mas parece mais quando conecto com o FL Studio mobile. O que vocĂȘs tem usado? Com USB tem menos delay?

  • @nicedim
    @nicedim Pƙed 8 měsĂ­ci

    A great idea and implementation.
    I did the control on the Arduino Pro Micro. If this connect after Ableton Live (11) running, then everything works. If the device is connected before starting Ableton Live (11), then no commands work until the device is reconnected. Then everything is fine again. That is, Ableton does not see an already connected device. Can this be fixed?

  • @mannytuzman3461
    @mannytuzman3461 Pƙed rokem

    Wow sounds great. Do you think the library I can have midi out AND midi in on the Arduino ? So then if I connect it to a midi cable usb on the arduino side and a split midi in/out cable to an instrument then I can send a command to the arduino interactivelly ?

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      It can. I do teach how to do this inside my course. With this Arduino it's tricky because you have to use the MIDIUSB lib for the USB and the MIDI libr for the midi din, so two libs at the same time.

  • @dokmuoh33
    @dokmuoh33 Pƙed 13 dny

    it is not straightforward that the code works with my teensy 4.0, i get an error, why? board is selected, usb port is selected, usb type midi is selected. code uploads but nothing appears in the serial monitor. also, the imported functions are generating some conflict apparently.

  • @mamamia980
    @mamamia980 Pƙed rokem

    Will you be talking about multiplexing in this video?
    I would really like to make a midi controller with 64 buttons.

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      In this video no, only about the MIDIUSB lib. Multiplexers I cover in my course: www.musiconerd.com/making-music-with-arduino/

  • @vocenalive
    @vocenalive Pƙed 2 měsĂ­ci

    friend we got an arduino with dvs timecode feature in serato

  • @user-ql5pq8oz1j
    @user-ql5pq8oz1j Pƙed rokem

    Hi, is it running on arduino uno pls ?

  • @SarasD14
    @SarasD14 Pƙed rokem

    Hi.! Where do i find all the functions for the MidiUSB library? Total Noob here, but i am watching your videos everyday and learing a lot.! Your videos deserve a hell lot more of views!

    • @Hoptronics
      @Hoptronics Pƙed rokem +1

      Documentation for the library. Also you can look at the code to see what is available.

    • @rootsnoir9164
      @rootsnoir9164 Pƙed 2 měsĂ­ci

      Did you ever find a list, I've looked everywhere and can't find anything.

    • @SarasD14
      @SarasD14 Pƙed 2 měsĂ­ci

      @@rootsnoir9164 I used chatgpt and figured out đŸ€ŁđŸ€Ł

  • @manuelgonzales6483
    @manuelgonzales6483 Pƙed rokem

    First đŸ„‡đŸ†đŸ˜

  • @Willpowerstudios
    @Willpowerstudios Pƙed rokem

    Hi, have you done midi + osc for wireless controllers ?

    • @NerdMusician
      @NerdMusician  Pƙed rokem +1

      I Onloy have used OSC with my phone with the TouchOSC app. I know one can use OSC with the Arduino too, though! I'll have to give it a try.

    • @Willpowerstudios
      @Willpowerstudios Pƙed rokem

      @@NerdMusician Yes, it's something I'm looking forward to trying too! It could open many doors... although it may create delay, it may be worth trying... midi+osc... I would like to create my own osc interface... I don't know how yet but will try it out! I love your work man, it's awesome !! You're a big inspiration !!

  • @PhilippeCavalier38490
    @PhilippeCavalier38490 Pƙed 4 měsĂ­ci

    hello so good video, but unfortuly
    i'm not avaible to understand correctly, arduino code. i need and want to make my personnal midi usb light console, like apc 40, running into sunlite suite software, who is DMX software.is this will cost me a lot of money to order you a complete running arduino code attached to a shematics i could design. hoping your answer. best regards philippe from france

  • @blueangel333333
    @blueangel333333 Pƙed rokem

    I can't find any model "usb midi class compliant' with 16 analog inputs or more .....
    Must i go on a impossible to find teensy or use a multiplexor ? seems terrifying

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      Yes. haha You already know the answer. Teensy is easy though. And I teach how to use multiplexers easily in my MMwA course: www.musiconerd.com/making-music-with-arduino/

  • @_just_looking_thank_you
    @_just_looking_thank_you Pƙed rokem +1

    If a call to the flush function is required after each call to noteOn, why not simply embed a call to flush at the end of the noteOn function’s code?

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      You want to call fliush as fast as you can after you get a read, so ideally every time hit a note. If you call at the end, imagine you have 100 buttons, you'll only hear that note you played after it finishes readin all the notes, besides it will play at the same time all the note you played during that loop.

    • @_just_looking_thank_you
      @_just_looking_thank_you Pƙed rokem

      @@NerdMusician I meant, if you moved the flush INTO the noteOn function, at the very end of its. That would be functionally equivalent to where you’ve placed it, would it not? But you wouldn’t have to remember to use it whenever you call noteOn, as it would be built in.
      It’s been a while since my coding years, and this wasn’t a language I used professionally, so I may be making incorrect assumptions.

    • @oienu
      @oienu Pƙed 10 měsĂ­ci

      @@_just_looking_thank_you Because USB work on packets, the data is first set in the buffer and when the Host request the data then is sended (remember, the host controller is also listening your keyboard, mouse, etc), that is why you can't send one-by-one because can increase the delay to wait the next request when you have to send multiple notes. By using flush() declare the data is ready to send and then force that.

  • @beachsidetech
    @beachsidetech Pƙed rokem

    Does anyone know if there is a way to change the USB MIDI device name? By default it’s always ‘Arduino Leonardo’. Would be good to change that.

    • @NerdMusician
      @NerdMusician  Pƙed rokem +2

      I'll prob cover this in a later video but this: github.com/mon/Arduino-USB-Rename

    • @beachsidetech
      @beachsidetech Pƙed rokem

      @@NerdMusician thanks for that link. I haven’t been able to get that code to work so far. Have the header and cpp files in the same directory as the ino file, and have added the include etc to the code, as it says to do in the readme. No errors when compiling, but no name change. Hmmm.

  • @crisoliveira2644
    @crisoliveira2644 Pƙed rokem

    Eu tenho um Arduino Uno e um shield USB host. Serve?

    • @NerdMusician
      @NerdMusician  Pƙed rokem +1

      Arduino Uno funciona, mas precisa de umas gambiaraas a mais, entĂŁo nĂŁo aconselho e nem ensino mais a usar o Uno, sĂł o Leonardo, Pro Micro e a famĂ­lia Teensy.
      A menos que seja o novo Uno R4!

    • @crisoliveira2644
      @crisoliveira2644 Pƙed rokem

      @@NerdMusician Valeu. Eu consegui fazer funcionar aqui, trocando o firmware do controlador da USB.

  • @bawexmelodysta7490
    @bawexmelodysta7490 Pƙed rokem

    how to download the sketch, and the schematic, please help me

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      Have you tried the link in the description?

  • @kamilowildchild4584
    @kamilowildchild4584 Pƙed rokem

    how can implement encoders??? and how can add some buttons ?

    • @_twich_8096
      @_twich_8096 Pƙed rokem

      is not so hard, this code i use interupt, you can delete interupt, but you may miss some pulses specialy if you rotate to fast
      // Rotary Encoder Inputs
      #define CLK 2
      #define DT 3
      #include "MIDIUSB.h"
      int counter = 0;
      int currentStateCLK;
      int lastStateCLK;
      void setup() {
      // Set encoder pins as inputs
      pinMode(CLK, INPUT);
      pinMode(DT, INPUT);
      // Setup Serial Monitor
      Serial.begin(9600);
      // Read the initial state of CLK
      lastStateCLK = digitalRead(CLK);
      // Call updateEncoder() when any high/low changed seen
      // on interrupt 0 (pin 2), or interrupt 1 (pin 3)
      attachInterrupt(0, updateEncoder, CHANGE);
      attachInterrupt(1, updateEncoder, CHANGE);
      }
      void loop() {
      //Do some useful stuff here
      midiEventPacket_t rx = MidiUSB.read();
      switch (rx.header) {
      case 0:
      break; //No pending events
      case 0xB:
      updateEncoder(
      rx.byte1 & 0xF, //channel
      rx.byte2, //cc
      rx.byte3 //value
      );
      break;
      }
      }
      void updateEncoder(byte channel, byte number, byte velocity) {
      // Read the current state of CLK
      currentStateCLK = digitalRead(CLK);
      // If last and current state of CLK are different, then pulse occurred
      // React to only 1 state change to avoid double count
      if (currentStateCLK != lastStateCLK && currentStateCLK == 1) {
      // If the DT state is different than the CLK state then
      // the encoder is rotating CCW so decrement
      if (digitalRead(DT) != currentStateCLK) {

      controlChange(1, 25, 127); // (channel, CC number, CC value)
      MidiUSB.flush();

      } else {
      controlChange(1, 25, 1); // (channel, CC number, CC value)
      MidiUSB.flush();

      }
      }
      // Remember last CLK state
      lastStateCLK = currentStateCLK;
      }
      void controlChange(byte channel, byte control, byte value) {
      midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
      MidiUSB.sendMIDI(event);
      }

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      czcams.com/video/9_dGC5XdQWc/video.html I teach buttons here. Encoders I teach inside the course: www.musiconerd.com/nerd-musician-pro/

  • @c1ph3rpunk
    @c1ph3rpunk Pƙed rokem

    How do you send chords?

    • @NerdMusician
      @NerdMusician  Pƙed rokem

      One note after the other without a delay. It sends so fast that you don't notice that it's not exactly at the same time.

  • @MejoradoLopezJonathan
    @MejoradoLopezJonathan Pƙed měsĂ­cem +1

    The code of the course, it doesn't work for the arduino UNO, needs an updated, because the pages is deleted, how can i make the compliant for arduino UNO

    • @eDrumsInANutshell
      @eDrumsInANutshell Pƙed měsĂ­cem

      Dude, you have the listen. He said, it's for Arduinos mit ATMega32U4 controller.... 😂

    • @MejoradoLopezJonathan
      @MejoradoLopezJonathan Pƙed měsĂ­cem

      @@eDrumsInANutshell in the course that i bought of NerdMusician, i don't speak of the video, but i dont found a place where can i put my comments in the course, and the video is related to the course and the comunication of the ATMEGA328 and the computer, for that i put my comment, learn to read

    • @eDrumsInANutshell
      @eDrumsInANutshell Pƙed měsĂ­cem

      @MejoradoLopezJonathan Learn to write! How could I know that you did a paid course?
      Hopefully, when I do a paid course, I have another possibility to contact him, then a tiny comment.

    • @MejoradoLopezJonathan
      @MejoradoLopezJonathan Pƙed měsĂ­cem

      @@eDrumsInANutshell You don't need to know, because my comment was for the author of the course, who is the owner of the CZcams channel, because he didn't answer the emails, my comment was for him, not for just anyone like YouđŸ€·

    • @eDrumsInANutshell
      @eDrumsInANutshell Pƙed měsĂ­cem

      @@MejoradoLopezJonathan Aha, might all be true. But still... Weired thoughts, dude.

  • @franprarod
    @franprarod Pƙed rokem

    This library dispenses the use of a middleware such as Hairless MIDISerial / ttymidi?

    • @NerdMusician
      @NerdMusician  Pƙed rokem +1

      Yes!

    • @franprarod
      @franprarod Pƙed rokem

      ​@@NerdMusician Thanks! Very nice as well. I have used this Pro Micro on another project, a gamepad, but since then its was unuseful. Previously, MIDI project only with Arduino Mega.