Pages: [1] 2   Go Down
Author Topic: Electronic Saxophone  (Read 1469 times)
0 Members and 1 Guest are viewing this topic.
Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
#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.
« Last Edit: December 11, 2012, 10:59:40 am by AWOL » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45935
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45935
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
   }

 
}
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 -

   http://rcarduino.blogspot.com/2012/08/adding-audio-to-arduino-projects.html

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


Manchester (England England)
Online Online
Brattain Member
*****
Karma: 504
Posts: 31327
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 504
Posts: 31327
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:-
https://ccrma.stanford.edu/software/stk/
Logged

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2921
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Cebu City
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Hi im new to arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: