Electronic Saxophone

Hi i'm working on a project that is called the "Electronic Saxophone" which can reproduce the sound of an actual saxophone. So far I was able to finish the button combinations code but was not satisfied of my work because my project doesn't sound like the actual saxophone even though I followed the exact frequency of each note of the Alto Saxophone. I found a project that was similar to ours but still doesn't sound even near the actual saxophone :frowning: Any ideas on how to improve my project? I'm new to Arduino, just learned this for about 3 weeks. Hope you guys can help, thanks! :smiley: :smiley:
P.S.: My groupmate is still working on the microphone module to detect wind passing through the mic so I didn't integrate the code for the microphone yet.

#define NOTE_AS2	116.540
#define NOTE_B2		123.470
#define NOTE_C3		130.810
#define NOTE_CS3	138.590
#define NOTE_D3		146.830
#define NOTE_DS3	155.560
#define NOTE_E3		164.810
#define NOTE_F3		174.610
#define NOTE_FS3	185.000
#define NOTE_G3		196.000
#define NOTE_GS3	207.650
#define NOTE_A3		220.000
#define NOTE_AS3	233.080
#define NOTE_B3		246.940
#define NOTE_C4		261.630
#define NOTE_CS4	277.180
#define NOTE_D4		293.660
#define NOTE_DS4	311.130
#define NOTE_E4		329.630
#define NOTE_F4	        349.230
#define NOTE_FS4	369.990
#define NOTE_G4		392.000
#define NOTE_GS4	415.300
#define NOTE_A4		440.000
#define NOTE_AS4	466.160
#define NOTE_B4		493.880
#define NOTE_C5		523.250
#define NOTE_CS5	554.370
#define NOTE_D5		587.330
#define NOTE_DS5	622.250
#define NOTE_E5		659.260
#define NOTE_F5		698.460

//Buttons 1-8
int swiPin [] = {23,24,25,26,27,28,29};
//Buttons 9-16
int swiPin2 [] = {4,5,6,7,9,10,11,12};
//Buttons 17-19
int swiPin3 [] = {22,30,31};

int speakerPin = 8;


//Grouping of combinations
int groupA,groupB,groupC;
void setup(){
  //Circuit is normally high
  for(int x = 0; x<7; x++){
    pinMode(swiPin[x], INPUT);
    pinMode(swiPin2[x], INPUT);
    digitalWrite(swiPin[x], 1);
    digitalWrite(swiPin2[x], 1);
  }
  for(int x = 0; x<2; x++){
    pinMode(swiPin3[x], INPUT);
    digitalWrite(swiPin3[x], 1);
  }
  Serial.begin(9600);
}

void check_fingering(){
   //Check keys pressed
   
   //Buttons 1-8
  groupA = ~1*(digitalRead(swiPin[0])) + 2*(digitalRead(swiPin[1])) + 4*(digitalRead(swiPin[2])) + 8*(digitalRead(swiPin[3])) + 16*(digitalRead(swiPin[4])) + 32*(digitalRead(swiPin[5])) + 64*(digitalRead(swiPin[6])) + 128*(digitalRead(swiPin[7]));
   //Buttons 9-16
  groupB = ~1*(digitalRead(swiPin2[0])) + 2*(digitalRead(swiPin2[1])) + 4*(digitalRead(swiPin2[2])) + 8*(digitalRead(swiPin2[3])) + 16*(digitalRead(swiPin2[4])) + 32*(digitalRead(swiPin2[5])) + 64*(digitalRead(swiPin2[6])) + 128*(digitalRead(swiPin2[7]));
   //Buttons 17-19
  groupC = ~1*(digitalRead(swiPin3[0])) + 2*(digitalRead(swiPin3[1])) + 4*(digitalRead(swiPin3[2]));

}

void loop(){
  check_fingering();

  //Note: B flat = A#2
  if ((groupA == 191)&&(groupB == 64)&&(groupC == 0)){
  Serial.println("B Flat");
  tone(speakerPin, NOTE_AS2 );
  }

  //Note: B = B2
  else if ((groupA == 191)&&(groupB == 32)&&(groupC == 0)){
  Serial.println("B");
  tone(speakerPin, NOTE_B2 );
  }

  //Note: C =C3
  else if ((groupA == 191)&&(groupB == 0)&&(groupC == 0)){
  Serial.println("C");
  tone(speakerPin, NOTE_C3 );
  }
  
  //I deleted the continuation of the code because it simply are all the note combinations and it would be such a long post
   else{
     noTone(speakerPin); //default note==c#5
   }

  
}

Moderator edit: Code tags. I'm getting bored with playing this game.

but was not satisfied of my work because my project doesn't sound like the actual saxophone even though I followed the exact frequency of each note of the Alto Saxophone.

Because a real saxophone produces harmonics. You won't do that on an Arduino.

PaulS:

but was not satisfied of my work because my project doesn't sound like the actual saxophone even though I followed the exact frequency of each note of the Alto Saxophone.

Because a real saxophone produces harmonics. You won't do that on an Arduino.

I understand that, but do you have any suggestions sir so that my project can be near to the sound of the actual saxophone?

I understand that, but do you have any suggestions sir so that my project can be near to the sound of the actual saxophone?

No. You can play one (pure) note at a time. There is no way, doing that, that you can make the Arduino sound like a device that can generate harmonics (multiple notes of varying volume and frequency).

Hi i'm working on a project that is called the "Electronic Saxophone" which can reproduce the sound of an actual saxophone. So far I was able to finish the button combinations code but was not satisfied of my work because my project doesn't sound like the actual saxophone even though I followed the exact frequency of each note of the Alto Saxophone. I found a project that was similar to ours but still doesn't sound even near the actual saxophone smiley-sad Any ideas on how to improve my project? I'm new to Arduino, just learned this for about 3 weeks. Hope you guys can help, thanks! smiley-grin smiley-grin
P.S.: My groupmate is still working on the microphone module to detect wind passing through the mic so I didn't integrate the code for the microphone yet.

#define NOTE_AS2 116.540
#define NOTE_B2 123.470
#define NOTE_C3 130.810
#define NOTE_CS3 138.590
#define NOTE_D3 146.830
#define NOTE_DS3 155.560
#define NOTE_E3 164.810
#define NOTE_F3 174.610
#define NOTE_FS3 185.000
#define NOTE_G3 196.000
#define NOTE_GS3 207.650
#define NOTE_A3 220.000
#define NOTE_AS3 233.080
#define NOTE_B3 246.940
#define NOTE_C4 261.630
#define NOTE_CS4 277.180
#define NOTE_D4 293.660
#define NOTE_DS4 311.130
#define NOTE_E4 329.630
#define NOTE_F4 349.230
#define NOTE_FS4 369.990
#define NOTE_G4 392.000
#define NOTE_GS4 415.300
#define NOTE_A4 440.000
#define NOTE_AS4 466.160
#define NOTE_B4 493.880
#define NOTE_C5 523.250
#define NOTE_CS5 554.370
#define NOTE_D5 587.330
#define NOTE_DS5 622.250
#define NOTE_E5 659.260
#define NOTE_F5 698.460

//Buttons 1-8
int swiPin [] = {23,24,25,26,27,28,29};
//Buttons 9-16
int swiPin2 [] = {4,5,6,7,9,10,11,12};
//Buttons 17-19
int swiPin3 [] = {22,30,31};

int speakerPin = 8;

//Grouping of combinations
int groupA,groupB,groupC;
void setup(){
//Circuit is normally high
for(int x = 0; x<7; x++){
pinMode(swiPin

, INPUT);

pinMode(swiPin2

, INPUT);

digitalWrite(swiPin

, 1);

digitalWrite(swiPin2

, 1);

}
for(int x = 0; x<2; x++){
pinMode(swiPin3

, INPUT);

digitalWrite(swiPin3

, 1);

}
Serial.begin(9600);
}

void check_fingering(){
//Check keys pressed

//Buttons 1-8
groupA = ~1*(digitalRead(swiPin[0])) + 2*(digitalRead(swiPin[1])) + 4*(digitalRead(swiPin[2])) + 8*(digitalRead(swiPin[3])) + 16*(digitalRead(swiPin[4])) + 32*(digitalRead(swiPin[5])) + 64*(digitalRead(swiPin[6])) + 128*(digitalRead(swiPin[7]));
//Buttons 9-16
groupB = ~1*(digitalRead(swiPin2[0])) + 2*(digitalRead(swiPin2[1])) + 4*(digitalRead(swiPin2[2])) + 8*(digitalRead(swiPin2[3])) + 16*(digitalRead(swiPin2[4])) + 32*(digitalRead(swiPin2[5])) + 64*(digitalRead(swiPin2[6])) + 128*(digitalRead(swiPin2[7]));
//Buttons 17-19
groupC = ~1*(digitalRead(swiPin3[0])) + 2*(digitalRead(swiPin3[1])) + 4*(digitalRead(swiPin3[2]));

}

void loop(){
check_fingering();

//Note: B flat = A#2
if ((groupA == 191)&&(groupB == 64)&&(groupC == 0)){
Serial.println("B Flat");
tone(speakerPin, NOTE_AS2 );
}

//Note: B = B2
else if ((groupA == 191)&&(groupB == 32)&&(groupC == 0)){
Serial.println("B");
tone(speakerPin, NOTE_B2 );
}

//Note: C =C3
else if ((groupA == 191)&&(groupB == 0)&&(groupC == 0)){
Serial.println("C");
tone(speakerPin, NOTE_C3 );
}

//I deleted the continuation of the code because it simply are all the note combinations and it would be such a long post
else{
noTone(speakerPin); //default note==c#5
}

}

Hi,
You are being very optimistic in expecting the tone function to reproduce the sound of a saxophone or any instrument at all.

I would suggest that you adjust your expectations/project goals to 'have a saxophone style interface to an interesting sounding electronic instrument'.

If you really want to try reproducing a saxophone sound, you have a lot of reading ahead of you, there is a good series fo about 50 articles buried somewhere on this site - http://www.soundonsound.com/

If you want to go for the more realistic option of saxophone style interface to interesting electronic instrument, I suggest you look up the Auduino project, its not mine but I have collected some interesting examples here -

It could really benefit from a more instrument like user interface so could be the perfect marriage of two projects
Duane B

To get the sound of a real instrument you need to get right:-

  1. the frequency
  2. the mix of harmonics
  3. the changing mix of harmonics over time.
  4. the change in all the above when the blow velocity changes.

There are two options, you can either play back a sample sound from a wave shield, one for each note. Or you can synthesise the waveform. The UNO is not fast enough to do this but it is possible to do this with a Due. There is a good book about modelling synths by Perry Cook, he has a web site with code on it to help you to do this. However it is not a thing for beginners, it is rather advanced.

Thank you guys for your suggestions! I will try to look on this and plan with my groupmates! Your advices give a lot of insight and we will start studying on them :slight_smile:

Links to help you:-
The book:-

The code:-
https://ccrma.stanford.edu/software/stk/

Hi I made a microphone circuit and I plan to make it detect only the wind blowing for my Saxophone project. So far I am having problems on how to do this because when I blow wind to the microphone it gathers data and when I also talk it also gathers data. How can I let my circuit only gather data wind blowing from the microphone?

That is nearly impossible to do without some kind of filter or isolation container.
How big is the microphone, is it able to go inside the Saxophone?

xxryan1234:
I understand that, but do you have any suggestions sir so that my project can be near to the sound of the actual saxophone?

Does it sound like MIDI tones?

Grumpy_Mike:
Links to help you:-
The book:-
http://www.amazon.co.uk/Real-Sound-Synthesis-Interactive-Applications/dp/1568811683/ref=sr_1_9?ie=UTF8&qid=1355222781&sr=8-9

The code:-
The Synthesis ToolKit in C++ (STK)

okay sir will look into this right away when I get home thank you, will update you guys if the project is a success :slight_smile:

S_Flex:

xxryan1234:
I understand that, but do you have any suggestions sir so that my project can be near to the sound of the actual saxophone?

Does it sound like MIDI tones?

Yes sir

HazardsMind:
That is nearly impossible to do without some kind of filter or isolation container.
How big is the microphone, is it able to go inside the Saxophone?

the microphone is inside the artificial saxophone that we made sir, I used a EM-80PX7 mic MIC Condenser. Is there any way I can stop getting data from the sound and only get data through wind from the microphone?

Can you place another microphone upstream in the sax, if you can it may be possible to use the upstream mic as a switch that turns on the sampling if it get a signal before the ed. you placed. This is not foolproof but may be any easy method that work well enough.

Why choose a microphone?
Surely you need something more like an anemometer?

A microphone is the wrong sensor to use. You want to use a pressure sensor. You want to blow into a Leakey chamber, then the pressure will represent how hard you blow.

Did not think about using an anemometer or a pressure sensor, I thought about the microphone because it was the first thing that came into my mind. Thank you for the suggestions Sir Grumpy_Mike and Sir AWOL. Thank you also wwbrown You guys have been a lot of help, I'll look into using your suggestions and try them out when we work tomorrow! :slight_smile:

Will try looking on pressure sensors and anemometer circuits, sorry not that familiar with these two. :slight_smile: