Cebu City
Offline
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« on: December 10, 2012, 12:53:05 pm » |
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!  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.
|
|
|
|
« Last Edit: December 11, 2012, 10:59:40 am by AWOL »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35476
Seattle, WA USA
|
 |
« Reply #1 on: December 10, 2012, 01:08:23 pm » |
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
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #2 on: December 10, 2012, 01:29:41 pm » |
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
Brattain Member
Karma: 311
Posts: 35476
Seattle, WA USA
|
 |
« Reply #3 on: December 10, 2012, 01:36:18 pm » |
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
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #4 on: December 10, 2012, 10:28:40 pm » |
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
Edison Member
Karma: 20
Posts: 1627
|
 |
« Reply #5 on: December 11, 2012, 04:18:02 am » |
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
Brattain Member
Karma: 274
Posts: 25480
Solder is electric glue
|
 |
« Reply #6 on: December 11, 2012, 04:54:17 am » |
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
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #7 on: December 11, 2012, 05:42:59 am » |
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 
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 274
Posts: 25480
Solder is electric glue
|
 |
« Reply #8 on: December 11, 2012, 05:48:34 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Cebu City
Offline
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #9 on: December 11, 2012, 05:48:44 am » |
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
Online
Edison Member
Karma: 28
Posts: 1556
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #10 on: December 11, 2012, 08:35:04 am » |
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
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
|
 |
« Reply #11 on: December 11, 2012, 08:42:13 am » |
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
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #12 on: December 11, 2012, 10:06:31 am » |
okay sir will look into this right away when I get home thank you, will update you guys if the project is a success 
|
|
|
|
|
Logged
|
|
|
|
|
Cebu City
Offline
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #13 on: December 11, 2012, 10:06:38 am » |
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
Newbie
Karma: 0
Posts: 34
Hi im new to arduino!
|
 |
« Reply #14 on: December 11, 2012, 10:12:46 am » |
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
|
|
|
|
|
|