Hi Guys,
I've been trying to build my own midi Ondes Martenot based around Mitshushi Abe's design. I'm using an Arduino Uno with hairless midi as a serial bridge. Everything looks like it should be working to me, but I am a bit of a noob.
The problem is when I try to control an Ableton soft synth with it, the sound is heavily distorted. I used Midi Monitor to check what midi messages my Arduino was outputting and it seems to be sending channel volume (course) control messages.
Does anyone know why this might be happening? or how I can prevent this?
Any help will be greatly appreciated,
Thank you
See code below
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////
// Ondes Martenot MIDI Controller For Arduino UNO 9V V0.0
// Mitsushi "Galliano" Abe 2012.9.1
// Http : // gam . Boo . Jp / Blog / Archives / 2012 / 07 / midi . Html
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////
//Connect the pressure sensor (volume) to A0, the micro switch (note on) to D7
// Connect the center pin of 10-turn potentiometer (pitchbend ) To A1
// Connect the push switch (tuning adjust) to D8
// Connect the center pin of slide potentiometer (cut off,
//To A2
// Connect Mac >> USB - MIDI (IN) >> Arduino
// The software synthesizer must have + - 24 pitch ( not must) to A3 // Connect the center pin of potentiometer Bend range for 4 octave control
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
#define SWITCH 7 // connect the micro switch to D7
#define PITCHADJUST 8 // connect the push switch to D8
#define PITCHINPUT 1 // connect the center pin of 10-turn potentiometer to A1int PITCHADJUST_RANGE = 0;
int PITCH_RANGE = 24;
int MIDI_ROOT_NOTE = 60;
float MIDIPITCHSCALE = 0.03785;int sensorPin = 0; // Connect The Pressure Sensor To A0
int sensorValue;
int midiValue = 0; // Volume Value
int old_midiValue;
int cc = 7; // Main Volume For MIDI Control Changeint bendPin = 2; // connect the potentiometer to A2
int bendValue;
int midibendValue = 0; // bend Value
int old_midibendValue;
int br = 58; // MIDI bendrange change (depends on user's difinition)int midiCh = 1;
int notecounter = 0; // Counter Used To Avoid Refrainig Note On
int val1 = 0;
int val2 = 0;
int data3 = 0;byte lowerBits; // Pitchbend value LSB
byte upperBits; // Pitchbend value MSB
int iCounter = 0; // Counter used to reduce the sample rate
byte noteOnToggle = HIGH; // Used to hold the state of the beamvoid SendMIDI(char cmd, char data1, char data2)
{
Serial.write (byte (cmd));
Serial.write (byte (data1));
Serial.write (byte (data2));
}void Control() {
val1 = digitalRead (SWITCH);
if (val1 == HIGH)
{
//notecounter += 1;
notecounter = notecounter + 1;
}
if (notecounter == 1)
{
SendMIDI (0X90, MIDI_ROOT_NOTE, 127); // Send The Root Note
}
else
{
// NOTE OFF
SendMIDI (0X80, MIDI_ROOT_NOTE , 127); // Silence the note
notecounter = 0; // Reset the counter
}
}void Volume() {
sensorValue = analogRead (sensorPin);
midiValue = sensorValue / 7.6;
if (midiValue> 127)
{
midiValue = 127;
}if (midiValue != old_midiValue)
{
SendMIDI (0xB0, cc, midiValue);
}old_midiValue = midiValue;
}
void ProcessAnalogValue(byte i)
{
// Get A Value For The GP Sensor On Pin I
float _x = Z (i);val2 = digitalRead (PITCHADJUST);
if (val2 == HIGH)
{
data3 = analogRead (1);
PITCHADJUST_RANGE = 608 - data3; // 608 is the middle point of pitchbend plus 1
}// 0 - 16383 is the full 14 bit pitchbend range
int _converted = (int) ((_x - 297 + PITCHADJUST_RANGE) / MIDIPITCHSCALE);if (_converted> 16383)
{
_converted = 16383;
}if (_converted <0)
{
_converted = 0;
}// Convert this 14 bit range value to LSB and MSB bytes
_converted >>= 7;
upperBits = (byte) (_converted & 0x7F);
lowerBits = (byte) (_converted & 0x7F);// Now output the message
SendMIDI (0xe0, lowerBits, upperBits);}
float Z(byte pin)
{
int tmp;
int data1 = 0;
int data2 = 0;
int summary = 0; // Summary Of Input Data
int h;// get average data from analogpin0
for (h = 0; h <10; h ++) {
data1 = analogRead(pin);
summary = summary + (data1);
}tmp = summary/10;
return (float)tmp;
}void setup(){
MIDI.begin(1);
Serial.begin(115200); // Set MIDI baud rate:SendMIDI(0xB0, 0x65, 0);
SendMIDI(0xB0, 0x64, 0);
SendMIDI(0xB0, 0x06, PITCH_RANGE); // Set pitchbend rangepinMode(SWITCH, INPUT);
}
void loop () {
Volume();
Control();
ProcessAnalogValue(PITCHINPUT);
delay(1);}
Midi_ondes_potential__AMMENDING_WIP_.ino (4.77 KB)