Hi all! I'm new in the forum and I'm a noob in Arduino but I'm here to learn the possible! ;))
I'm trying to create a MIDI simple controller with only two pots that have to control a program on my computer.. I want to launch hairless in background so that I can use the serial mode on Arduino.. But here are the problems: how can I make the pots communicate with serial in a MIDI code? I can only show one pot at time and I see the values on serial.. But how can traslate them in a MIDI language so that the program can read it?
I've an Arduino Due and I use archlinux
Let's have some examples of values read from the pots and the MIDI messages to be output.
The values input from the pots will vary between 0 and 1023 so you could use different ranges to generate different messages if that is what you have in mind.
Yes it's clear but I cannot understand how the grammar of these messages has to be... What kind of MIDI message has to be sent for a specific pot's value?
I wish you would make your mind up what your problem is.
how can I make the pots communicate with serial in a MIDI code?
I cannot understand how the grammar of these messages has to be..
I can't found out how to set up the code in Arduino IDE..
Before you can write the Arduino program you must know what MIDI messages you want to send. Actually sending the messages should be easy. Did you come across http://www.arduino.cc/en/Tutorial/Midi in your search ?
I want to send some data from the pots to my serial port and in the sketch create something to let this value to be seen as midi values (or something that the program can see). I can't figure out what kind of code I've to create..
I want to send some data from the pots to my serial port and in the sketch create something to let this value to be seen as midi values (or something that the program can see). I can't figure out what kind of code I've to create
I have underlined the things you don't seem to know. As you can see it is difficult to provide help when there are so many unknowns.
What is it exactly you want to do ? Suppose the user changes the position of one of the pots attached to the Arduino, what should happen ? Should the volume or pitch of the note change, for instance ? If not, what should happen ?
You're right.. I don't know exactly what kind of message I've to send to be seen from the program on PC.. I think it's not important which one is.. maybe volume change? By reading here little-scale: Simple Examples of Sending MIDI Data from Arduino to Computer I've seen I've to send a CONTROL CHANGE (defined by B in a midi message), but the data can be volume or somithing different... Am I wrong?
This probably should work.. In the next days I'will try
byte val = 0;
void setup() {
Serial.begin(57600); // open serial port
}
void loop() {
for(int i = 0; i < 3; i ++) {
val = analogRead(i) / 8; // read value of a potentiometer
// (which is analog input 0 - 1)
// depending on which for() loop we are at
// let's send a control change message
Serial.print(0xB0 + i, BYTE); // MIDI control change; channel number
// the channel number depends on which for() loop we ar at
Serial.print(1, BYTE); // MIDI controller #1
Serial.print(val, BYTE); // MIDI controller value from the potentiometer
delay(1); // delay for a brief moment
}
}
Improving my code.. but on SerialMonitor I can't see nothing...
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
// 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);
Serial.begin(9600);
}
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(0xB0,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif
}
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
// 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);
Serial.begin(9600);
}
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(0xB0,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
}
Serial.print("0xB0,");
Serial.print(cc);
Serial.print(",1,");
delay(20);
} // endif
A potentiometer is not a MIDI device, whatever its value.
If I understand correctly you want to read the value of the potentiometer then, depending on the value, send different MIDI commands to the PC serial interface to be read an interpreted by the Hairless MIDI to serial bridge ? Is that right ?
What speed is the Hairless interface running at and what serial port is it using ?