Making a simple MIDI Controller. One Man's Journey


i interested in making midi controllers communicate virtual instruments or daw.
i had spend fair amount of time figuring out works setup.
i offer little bit of knowledge have gathered far may save troubles.

i have arduino uno, latest revision, laptop running windows 7 professional , old version of ableton live. using laptop's standard sound card. not using hardware or specialized cables, usb cable connected arduino laptop.
(this time mention can use usb connection arduino pc 1 thing @ time. meaning can upload sketch, or send serial data.it doing 1 or other, not both @ same time.)

i set out create simple controller can expand upon learn how code.

before venture different ways trigger midi, there simple sketch below not require sort of input such buttons, knobs, or force sensing resistors. great way test setup.

i found needed 2 pieces of software arduino communicate audio software:

1. hairless midi    http://projectgus.github.io/hairless-midiserial/
2. loopbe1          http://www.nerds.de/en/loopbe1.html


do not run hairless midi until after upload sketch arduino , have started audio software!!!!!!!!

in case that's not clear:
1. upload sketch
2. start audio software of choice (i assume know how setup audio , midi ins/outs daw/vst of choice.)
3. open hairless

loopbe1 kinda runs in background don't have it.



here sketch http://www.instructables.com/id/arduino-sensors-and-midi/?allsteps
that can serve test confirm have proper setup/configuration arduino pc serial bridge:

step 3: generating midi arduino

(upload following code onto arduino, turns midi note 60 (middle c) on, waits 300ms, turns off , waits 200ms:

code: [select]
byte noteon = 144;//note on command

void setup() {
  serial.begin(9600);
}

void loop() {
  midimessage(noteon, 60, 100);//turn note on
  delay(300);//hold note 300ms
  midimessage(noteon, 60, 0);//turn note off (note on velocity 0)
  delay(200);//wait 200ms until triggering next note
}

//send midi message
void midimessage(byte command, byte data1, byte data2) {
  serial.write(command);
  serial.write(data1);
  serial.write(data2);
}



you may have mess around baud rate settings in hairless sketch things start communicating properly. however, sketch, prescribed setting should fine.you should see blinky lights on hairless gui indicating arduino indeed sending bytes laptop , midi in seeing them. should hear sounds coming laptop, pc, sound card,io device, etc.
don't forget close hairless midi before try upload changes arduino.
if hear middle c turning on , off, congratulations, communicating.

my next mission figure out how setup couple of buttons turn on midi notes have ability play melody or whatever on virtual instrument.

if finds thread helpful or can offer further guidance on subject, please post comment.

i try add post learn more , have more share.

thanks

here's quick ideas played last year "stomp box" style of foot control.  used fluxamasynth output synth (everything in 1 spot , compact) , used uno to hard work.

code: [select]


#include "fluxamasynth.h"

# define bass 36              // define midi note numbers several gm drum sounds
# define snare 38
# define hihatc 42
# define hihatp 44
# define hihato 46

fluxamasynth synth; // create synth object

// * basic settings */
int channel = 9;              // midi channel number
int tempo = 127;              // start tempo

const int pad0 = a0;  // analog input pin potentiometer attached to
const int pad1 = a1;  // analog input pin potentiometer attached to
const int pad2 = a2;  // analog input pin potentiometer attached to
const int ledpin = 13;       // led connected digital pin 13

int sensor0 = 0;         // value read sensor
int perc_0 = 45;         //center
int sensor1 = 0;         // value read sensor
int perc_1 = 49;         //lhs
int sensor2 = 0;         // value read sensor
int perc_2 = 38;          //rhs
int trapadc = 0;            //used trap reading
int trapsensor = 0;
int sensorhi = 0;
int sensorlo = 2000;
int trigger = 0;
int hihys = 500;
int lohys = 100;
int vel = 120;

void setup() {
  //use led monitor
  pinmode(ledpin, output);              // sets digital pin output
  // initialize serial communications midi 31,250 bps
  serial.begin(31250);         //  set midi baud rate:
  //set midi
 
  synth.midireset();                    // complete midi reset
  //synth.setreverb(channel,5,255,100);   // plate reverb maximum effect level
  synth.setchannelvolume(channel, 127); // max. channel volume
  synth.setmastervolume(255);         // max. master volume
  //synth.noteon(channel, hihatp, vel); // play note
 
  //serial.begin(9600);         // debug only

}

void loop() {
  // read analogs values:
  sensor0 = analogread(pad0);
  sensor1 = analogread(pad1);
  sensor2 = analogread(pad2);
  // determine alarm status
  if (sensor0 > hihys)
  {
    digitalwrite(ledpin, high);   // sets led on
  }
  else
  {
    digitalwrite(ledpin, low);    // sets led off
  }

  if (sensor0 > hihys){
    synth.noteon(channel, perc_0, vel); // play note
    synth.noteoff(channel, perc_0);   
    trapadc = a0;
    trapsensor = sensor0;
  }
  if (sensor1 > hihys){
    synth.noteon(channel, perc_1, vel); // play note
    synth.noteoff(channel, perc_1);   
    trapadc = a1;
    trapsensor = sensor1;
  }
  if (sensor2 > hihys){
    synth.noteon(channel, perc_2, vel); // play note
    synth.noteoff(channel, perc_2);   
    trapadc = a2;
    trapsensor = sensor2;
  }
  while (trapsensor > hihys ){
    delay(10);
    trapsensor = analogread(trapadc);

  }
  while (trapsensor < lohys){
    delay(10);
    trapsensor = analogread(trapadc);

  }
  // wait 10 milliseconds before next loop
  // analog-to-digital converter settle
  // after last reading:
}

void update(){
  //delay(1000);
  serial.print("sensor a0 = " );
  serial.print(sensor0,dec);
  serial.print(" sensor a1 = " );
  serial.print(sensor1,dec);
  serial.print(" sensor a2 = " );
  serial.print(sensor2,dec);
  serial.print(" sensor lo = " );
  serial.print(hihys,dec);
  serial.print(" sensor hi = " );
  serial.println(lohys,dec);
  serial.println();
}
/*
bass  keynum sound
a_ 33 metronome click
b_b 34 metronome bell
b_ 35 acoustic bass drum
c 36 bass drum 1
c# 37 side stick
d 38 acoustic snare
eb 39 hand clap
e 40 electric snare
f 41 low floor tom
f# 42 closed hi-hat
g 43 high floor tom
g# 44 pedal hi-hat
a 45 low tom
bb 46 open hi-hat
bn 47 low-mid tom
c 48 hi-mid tom
c# 49 crash cymbal 1
d 50 high tom
eb 51 ride cymbal 1
e 52 chinese cymbal
f 53 ride bell
f# 54 tambourine
g 55 splash cymbal
g# 56 cowbell
a 57 crash cymbal 2
bb 58 vibraslap
bn 59 ride cymbal 2
c 60 hi bongo
c# 61 low bongo
d 62 mute hi conga
d# 63 open hi conga
e 64 low conga
f 65 high timbale
f# 66 low timbale
g 67 high agogo
g# 68 low agogo
a 69 cabasa
bb 70 maracas
bn 71 short whistle
c 72 long whistle
c# 73 short guiro
d 74 long guiro
d# 75 claves
e 76 hi wood block
f 77 low wood block
f# 78 mute cuica
g 79 open cuica
g# 80 mute triangle
a 81 open triangle
82
83
84
*/


it uses 3 pressure sensitive sensors dropper resistor , reading voltage analogue channels set thresholds etc "notes" in percussion channel , not seem matter when off signal sent, beat plays same.

cheers, rob

i hope helps.


Arduino Forum > Using Arduino > Audio > Making a simple MIDI Controller. One Man's Journey


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code