Go Down

Topic: Help on how to send MIDI commands to pc to achieve chords and arpeggi effect (Read 2057 times) previous topic - next topic


Hi, i recently acquired an arduino uno and after going through some of the tutorials i'm looking for a bigger challenge. Specifically i want to replicate the input system of a device called lightharp.
i've built a prototype based on what i see on this video. I've managed to replicate a "light string" and i've managed to send midi noteon and noteoff commands and play that notes with a DAW software on windows, specifically REAPER.
Now i'm up to replicating the "chord" and "arpeggi" modes from the video before building more light strings. Does anyone have any idea, example or pseudocode to guide me on that? I'm completely new to MIDI singals.


You could do it using millis(). If you don't know how to use it, read the blink without delay example.
If you're activating the sensor which corresponds to C, and you want to send a C major chord, you would send
note 60, 64, 67.
If you want to send a note every 100ms for example(this is the blink without delay example modified)

Code: [Select]
const int ledPin =  13;      // the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED

// Generally, you shuould use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
const long interval = 100;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);     

void loop()
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the
  // difference between the current time and last time you blinked
  // the LED is bigger than the interval at which you want to
  // blink the LED.
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;   
//send note 60 here

Then you could add a variable that increments by one each time a note is sent, and reset it to 0 when it sends the last note of the chord
Code: [Select]
  if(currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;   
//send note off of the last note on here
//send note on 60 here
   if(counter > 2){
counter = 0;

then you can say that when counter is 0, it sends note 60, if counter is 1, it sends note 64, and when is 2, note 67, reset, and it starts again. Always with a note off between each note so it sounds like the one in the video. Although I don't know why he calls it a chord, they're not sounding at the same time, so that doesn't make it a chord... If you want to send the chord, just send the 3 note on at the same time without noteoff between each one

Go Up