Go Down

Topic: Electronic Saxophone (Read 2 times) previous topic - next topic

xxryan1234

Dec 10, 2012, 06:53 pm Last Edit: Dec 11, 2012, 04:59 pm by AWOL Reason: 1
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 :(  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! :D :D
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.

Code: [Select]
#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.

PaulS

Quote
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.

xxryan1234


Quote
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?

PaulS

Quote
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).

xxryan1234

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
   }


}

Go Up