Midi Ondes Martenot Code Error

Hi All,

I’m still trying to replicate Mitsushi Abe’s midi ondes martenot,
but i’m fairly new to coding and i am having trouble with his code, i get the following error message;

Midi_ondes_potential:56: error: ‘serial’ does not name a type
serial.write (byte (data1)); Serial.write (byte (data2)); void SendMIDI (char cmd, char data1, char data2)
^
Midi_ondes_potential:56: error: ‘Serial’ does not name a type
serial.write (byte (data1)); Serial.write (byte (data2)); void SendMIDI (char cmd, char data1, char data2)
^
/Users/robertjedwards/Documents/Arduino/Midi_ondes_potential/Midi_ondes_potential.ino: In function ‘void SendMIDI(char, char, char)’:
Midi_ondes_potential:58: error: ‘serial’ was not declared in this scope
serial.write (byte
^
Midi_ondes_potential:62: error: expected primary-expression before ‘void’
void control () {
^
Midi_ondes_potential:83: error: ‘midiValue’ was not declared in this scope
MidiValue = sensorValue / 7.6; if (midiValue> 127) {midiValue = 127;} void volume () {
^
Midi_ondes_potential:83: error: a function-definition is not allowed here before ‘{’ token
MidiValue = sensorValue / 7.6; if (midiValue> 127) {midiValue = 127;} void volume () {
^
Midi_ondes_potential:198: error: expected ‘}’ at end of input
}
^
exit status 1
‘serial’ does not name a type

Any help would be greatly appreciated :slight_smile:
Below is Mitsushi’s example code;

#include <MIDI.h>

#define SWITCH 7 // connect the micro switch to D7
#define PITCHADJUST 8 // connect the push switch to D8
int PITCHADJUST_RANGE = 0;
int PITCH_RANGE = 24;

#define PITCHINPUT 1 // connect the center pin of 10-turn potentiometer to A1

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 Change

int 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 cutoffPin = 3; // connect the slide pot to A3
int cutoffValue;
int midicutoffValue = 0; // cutoff Value
int old_midicutoffValue;
int cu = 74; // MIDI cutoff change

int MidiCh = 1;
int Notecounter = 0; // Counter Used To Avoid Refrainig Note On
int val1 = 0;
int val2 = 0;
int Data3 = 0;

int MIDI_ROOT_NOTE = 60;
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 beam

float MIDIPITCHSCALE = 0.03785;

serial.write (byte (data1)); Serial.write (byte (data2)); void SendMIDI (char cmd, char data1, char data2)
{
serial.write (byte

void control () {

val1 = digitalRead (SWITCH);

if (val1 == HIGH)
{
Notecounter = Notecounter Tasu 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
}
}

MidiValue = sensorValue / 7.6; if (midiValue> 127) {midiValue = 127;} void volume () {

sensorValue = analogRead (sensorPin)

if (midiValue! = Old_midiValue)
{
SendMIDI (0xB0, cc, midiValue);
}

old_midiValue = midiValue;

} MidibendValue = bendValue / 8; if (midibendValue> 127) {midibendValue = 127; }

void bendrange () {
// connect the potentiometer to A2
// this pot notice
mandatory
bendValue = }

if (midibendValue! = Old_midibendValue)
{
SendMIDI (0xB0, br, midibendValue);
}

old_midibendValue = midibendValue;

}

void cutoff () {

cutoffValue = analogRead (cutoffPin);
midicutoffValue = cutoffValue / 8;
if (midicutoffValue> 127) {midicutoffValue = 127;

if (midicutoffValue! = Old_midicutoffValue)
{
SendMIDI (0xB0, cu, midicutoffValue);
}

old_midicutoffValue = midicutoffValue;

}

ProcessAnalogValue void (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 - data 3; // 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;}

converted >> = 7; upperBits = (byte) ( converted & 0x7F); // Convert this 14 bit range value to LSB and MSB bytes
lower Bits = (byte) (_ converted & 0x7F)

// Now output the message
SendMIDI (0xe0, lowerBits, upperBits);

}

Z Float (Byte Pin)
{
int tmp;
int data1 = 0;
int data2 = 0;
int Summary = 0; // Summary Of Input Data
int H;

Summary = Summary + (data1); } tmp = Summary / 10; return (float) tmp; } tmp ; // get average data from analogpin0
for (h = 0; h <10; h ++) {
data1 = analogRead

void setup () {

SendMIDI ( 0xB0, 0x64, 0); SendMIDI (0xB0, 0x06, PITCH_RANGE); //
Set MIDI baud rate:

SendMIDI (0xB0, 0x65, 0 ); // MIDI.begin Set pitchbend range pinMode (SWITCH, INPUT); pinMode (PITCHADJUST, INPUT);

}

loop void () {

Volume ();
Bendrange ();
Cutoff ();
Control ();
ProcessAnalogValue (PITCHINPUT);
Delay (1);

}

Try Serial instead of serial. (capital S)

int MIDI_ROOT_NOTE = 60;
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 beam

float MIDIPITCHSCALE = 0.03785;

serial.write (byte (data1)); Serial.write (byte (data2));  void SendMIDI (char cmd, char data1, char data2)
{
serial.write (byte



void control () {

That mess between the declaration of MIDIPITCHSCALE and the control() function - where did it come from? All executable code MUST be in a function.

Thanks for the speedy replies guys,

Paul this is Mitsushi Abe's code that seemed to of worked for him, i guess there must of been a formatting error when he copied it to his blog post? So i'm not really too sure, i'm a bit of a noob. :confused:

Hi, this is Mitsushi Abe. Do you have any problems about my Ondes Martenot MIDI Controller yet?

galliano:
Hi, this is Mitsushi Abe. Do you have any problems about my Ondes Martenot MIDI Controller yet?

I imagine after 3 years, it's no longer any issue -- one way or the other.