Pages: [1]   Go Down
Author Topic: Potentiometer Send MIDI CC  (Read 2384 times)
0 Members and 1 Guest are viewing this topic.
Lisbon
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Everyone

I was wondering from the midi example that is available on Arduino Software
if its possible to send MIDI like that but with a potentiometer controlling both
Note and Velocity with different potentiometer's with serial.write

If there are examples available or someone that did something close to this
i would really appreciate your tips and solutions.

Thanks you very much
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 34506
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
to send MIDI like that but with a potentiometer controlling both
Note and Velocity with different potentiometer's with serial.write
Yes it is almost trivial,
read the two pots into a variable and shift it 3 places to the right to scale it
Code:
vPot = analogRead(vPotPin) >> 3;
nPot = analogRead(nPotPin) >> 3;
// then do other stuff and final use these variables to send just after the note on
Logged

Collegno, Turin
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino lovers
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi i'm also trying to build up a controller with 8 pots using an arduino 2009 and a IC 4051 for multiplexing, i'm following this tutorial from littlescale

http://little-scale.blogspot.it/2008/07/eight-pots-to-midi-cc-data.html


don't know why (maybe the pots) for me this circuit don't go. After that I've tested another circuit and code here it is

http://arduino.cc/forum/index.php/topic,122378.0.html

With that code and circuit I can hook up 6 pots (or analog sensor) and read their value, no latency, great response etc...

the problem is the mapping, when you select your parameter e.g. in ableton, until they are two it works than everything start flickering and its hard to get the solution....

Logged

Collegno, Turin
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino lovers
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

this the code I've modify

Quote
#include <MIDI.h>
#define MIDI_ENABLE 12

// Variables:
int cc = 0;
int AnalogValue = 0; // define variables for the controller data
int lastAnalogValue = 0; // define the "lastValue" variables

void setup() {
 
   
  //  launch MIDI
  MIDI.begin(4)
}

void loop() {
  AnalogValue = analogRead(0);
  //  convert to a range from 0 to 127:
  cc = AnalogValue/8;
  // check if analog input has changed
  if (lastAnalogValue != cc) {
    MIDI.sendControlChange(16,cc,1);
    // update lastAnalogValue variable
    lastAnalogValue = cc;
 
AnalogValue = analogRead(1);
  //  convert to a range from 0 to 127:
  cc = AnalogValue/8;
  // check if analog input has changed
  if (lastAnalogValue != cc) {
    MIDI.sendControlChange(17,cc,1);
    // update lastAnalogValue variable
    lastAnalogValue = cc;
  }   //  endif

AnalogValue = analogRead(2);
  //  convert to a range from 0 to 127:
  cc = AnalogValue/8;
  // check if analog input has changed
  if (lastAnalogValue != cc) {
    MIDI.sendControlChange(18,cc,1);
    // update lastAnalogValue variable
    lastAnalogValue = cc;
  }   //  endif
 
}

I'm not a programmer, i'm not an electronic guru, i'm just a poor musician with a few of nerd skills smiley
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 34506
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

On that first link, the code:-
Code:
if (filter[i] != data_send){ //if filter and data_send not equal then in theory this will only send midi data when a value is changes an not constantly.
Should be changed to:-
Code:
if (abs(filter[i] - data_send) > 1){ //if filter and data_send not equal then in theory this will only send midi data when a value is changes an not constantly.
This will allow a little bit of noise without constantly resending the MIDI

On that code you just posted you need a different variable for each analogue channel for both the value and the last value. As it is you are using the last value from the previous channel reading which is not going to work. While the code is rubbish change it to

Code:
AnalogValue0 = analogRead(0);
  //  convert to a range from 0 to 127:
  cc = AnalogValue0/8;
  // check if analog input has changed
  if (abs(lastAnalogValue0 - cc)>1 {
    MIDI.sendControlChange(16,cc,1);
    // update lastAnalogValue zero variable
    lastAnalogValue0 = cc;

AnalogValue1 = analogRead(1);
  //  convert to a range from 0 to 127:
  cc = AnalogValue1/8;
  // check if analog input has changed
  if (abs(lastAnalogValue1 - cc)>1 {
    MIDI.sendControlChange(16,cc,1);
    // update lastAnalogValue one variable
    lastAnalogValue1 = cc;

// and so on
Logged

Pages: [1]   Go Up
Jump to: