A program to automatically tune a guitar. Written by Justin Reidhead and Steven Swenson

Dependencies:   FFT FrequencyFinder Motor NewTextLCD PinDetect mbed strings

Files at this revision

API Documentation at this revision

Comitter:
melangeaddict
Date:
Sun Apr 15 00:37:37 2012 +0000
Parent:
1:4a82a5178506
Child:
3:c672e782f19b
Commit message:
Uncommented mbed parts

Changed in this revision

FrequencyFinder/.lib Show annotated file Show diff for this revision Revisions of this file
FrequencyFinder/FrequencyFinder.cpp Show annotated file Show diff for this revision Revisions of this file
FrequencyFinder/FrequencyFinder.h Show annotated file Show diff for this revision Revisions of this file
Motor/.lib Show annotated file Show diff for this revision Revisions of this file
Motor/Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor/Motor.h Show annotated file Show diff for this revision Revisions of this file
NewTextLCD.lib Show annotated file Show diff for this revision Revisions of this file
PinDetect.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
strings/.lib Show annotated file Show diff for this revision Revisions of this file
strings/strings.cpp Show annotated file Show diff for this revision Revisions of this file
strings/strings.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrequencyFinder/.lib	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,1 @@
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrequencyFinder/FrequencyFinder.cpp	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,97 @@
+#include "FrequencyFinder.h"
+
+using namespace std;
+
+FrequencyFinder::FrequencyFinder(PinName input) : _signal_in(input), _dc_offset(p18){
+    index=0;
+    peak=0;
+    frequency_final=0;
+}
+
+FrequencyFinder::~FrequencyFinder() {
+    ticker.detach();
+}
+
+float FrequencyFinder::find_frequency() {
+    initialize_array();
+    ticker.attach_us(this, &FrequencyFinder::get_data,500);
+
+    wait(1);
+    ticker.detach();
+
+    vRealFFT(signal_array-1,size);
+
+    take_abs();
+
+    int peak = find_peak();
+
+    float frequency_final=((float)peak)/4.1;
+
+    return frequency_final;
+}
+
+void FrequencyFinder::get_data() {
+    if (index<size) {
+        signal_array[index]=_signal_in.read();//-0.5);
+        index++;
+    }
+}
+
+void FrequencyFinder::take_abs() {
+//takes the absolute value of the signal
+    for (int j=0; j<size; j++) {
+        signal_array[j]=abs(signal_array[j]);
+        if (j<100)
+            signal_array[j]=0;
+        else if (j<400)
+            signal_array[j]=signal_array[j]*2;
+        else if (j<600)
+            signal_array[j]=signal_array[j]*3;
+        else if (j<800)
+            signal_array[j]=signal_array[j]*4;
+        else
+            signal_array[j]=signal_array[j]*5;
+    }
+}
+
+int FrequencyFinder::find_peak() {
+    int i=0;
+
+    for (int j=0; j<size; j++) {
+        if ((signal_array[i]-signal_array[i-1])>100 ) {
+            while (
+                (signal_array[i]<=signal_array[i+1]) &&
+                (signal_array[i]<=signal_array[i+2]) &&
+                (signal_array[i]<=signal_array[i+3]) &&
+                (signal_array[i]<=signal_array[i+4])) {
+                i++;
+            }
+            return FrequencyFinder::find_max(i);
+        }
+        i++;
+    }
+    return FrequencyFinder::find_max(i);
+}
+
+int FrequencyFinder::find_max(int position) {
+    int index1=position-20;
+    int index2=position+20;
+    float max=signal_array[index1];
+    int max_index=0;
+
+    for (int a=index1; a<index2; a++) {
+        if (signal_array[a]>max) {
+            max=signal_array[a];
+            max_index=a;
+        }
+    }
+
+    return max_index;
+}
+
+void FrequencyFinder::initialize_array() {
+    index=0;
+    for (int w=0; w<size; w++) {
+        signal_array[w]=0;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrequencyFinder/FrequencyFinder.h	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,33 @@
+#pragma once
+#include "mbed.h"
+#include "FFT.h"
+
+#include "NewTextLCD.h"
+
+using namespace std;
+
+const int size=4096;
+
+class FrequencyFinder{
+public:
+
+FrequencyFinder(PinName input);
+~FrequencyFinder();
+
+float find_frequency();
+void get_data();
+void take_abs();
+int find_peak();
+int find_max(int);
+void initialize_array();
+
+private:
+    float signal_array[size];
+    int index;
+    int peak;
+    int frequency_final;
+    
+    Ticker ticker;
+    AnalogIn _signal_in;
+    AnalogOut _dc_offset;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor/.lib	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,1 @@
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor/Motor.cpp	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,19 @@
+#include "Motor.h"
+
+Motor::Motor(PinName enable,PinName direction,PinName step) : _enable(enable), _direction(direction), _step(step) {
+
+}
+
+Motor::~Motor() {
+}
+
+void Motor::motor_turn(int direction, int steps) {
+    _enable=0;
+    float freq=1000;//frequency of PWM signal to drive stepper motor
+    _step.period(1/freq);
+    _step.write(.5);
+    _direction=direction;
+    wait(steps*(1/freq));
+    _step.write(0);
+    _enable=1;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor/Motor.h	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,20 @@
+#pragma once
+#include "mbed.h"
+#include "string.h"
+
+using namespace std;
+
+class Motor {
+
+public:
+
+    Motor(PinName enable,PinName direction,PinName step);
+    ~Motor();
+
+    void motor_turn(int, int);
+
+private:
+    DigitalOut _enable;
+    DigitalOut _direction;
+    PwmOut _step;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NewTextLCD.lib	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/erik_kedo/libraries/NewTextLCD/lornxk
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinDetect.lib	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/libraries/PinDetect/lkyxpw
\ No newline at end of file
--- a/main.cpp	Sun Apr 15 00:20:48 2012 +0000
+++ b/main.cpp	Sun Apr 15 00:37:37 2012 +0000
@@ -1,320 +1,296 @@
-//#include "mbed.h"
-//#include "Motor.h"
-//#include "FrequencyFinder.h"
-//#include "NewTextLCD.h"
-//#include "PinDetect.h"
-#include "strings.h"
-#include <iostream>
-#include <stdio.h>
-#include <vector>
-
-using namespace std;
-//***************************************************
-//***************Globals*****************************
-//PinDetect string_but(p11);
-//PinDetect pitch_but(p12);
-//PinDetect start_but(p13);
-//PinDetect mode_but(p14);
-
-//DigitalOut led1(LED1);
-//DigitalOut led2(LED2);
-
-//TextLCD lcd(p21,p22,p23,p24,p25,p26);
-//Motor motor(p26,p22,p21);//enable, direction, step
-//FrequencyFinder guitar(p20);//input
-
-int selected_string;
-//int selected_pitch;
-bool current_mode;
-bool start_tuning;
-bool up, down;
-
-vector<strings> strings_array;
-
-//***************************************************
-//*****************constants*************************
-const bool tuning_mode=false;
-const bool winding_mode=true;
-
-//***************************************************
-//******************prototypes***********************
-void device_init();
-
-void string_sel();
-void pitch_sel();
-void start();
-void stop();
-void mode();
-void do_nothing();
-void wind_up();
-void wind_down();
-
-void button_init();
-void setup_buttons();
-void output_menu();
-void motor_calibration();
-bool check_threshold(float);
-//*************************************************
-//*********************main************************
-int main() {
-    //    lcd.cls();
-    //    lcd.printf("Perfect\n      Pitch");
-    
-    //    wait(.5);
-    
-    device_init();
-    
-    int state=0,next_state=0;
-    float old_freq=0,new_freq=0;
-    float desired_freq;
-    strings *temp=&strings_array[0];
-    while (1) {
-        
-        state=next_state;
-        
-        switch(state){
-            //------------------------------------
-        case 0://Stay here till the user selects the string and pitch
-            if(start_tuning==true){
-                next_state=1;
-            }
-            else{
-                next_state=0;
-            }
-            
-            break;
-            //----------------------------------------
-        case 1://motor calibration state
-            motor_calibration();
-            next_state=2;
-            break;
-            //-----------------------------------------
-        case 2://begin the actual tuning
-            temp=&strings_array[selected_string];
-            desired_freq=temp->get_freq();
-            
-            next_state=3;
-            break;
-            //-----------------------------------------
-        case 3:
-            //new_freq=frequency.find_frequency();
-            if(check_threshold(new_freq)){
-                if((desired_freq-.5)<new_freq && (desired_freq+.5)>new_freq){//We are within .5Hz of the desired frequency
-                    //lcd.cls();
-                    //lcd.
-                    printf("String %d\ntuned",selected_string);
-                    //wait(.5);
-                    
-                    start_tuning=false;
-                    next_state=0;
-                }
-                else if((desired_freq-.5)>new_freq){
-                    //motor(up,# of steps);
-                    next_state=3;
-                }
-                else{
-                    //motor(down,# of steps);
-                    next_state=3;
-                }
-            }
-            else{
-                next_state=3;
-            }
-            
-            //TODO:Determine number of steps per frequency change
-            old_freq=new_freq;
-            break;
-            //-----------------------------------------
-        default:
-            break;
-        }
-        //wait_ms(5);
-        
-        if(start_tuning==false){//If the stop button is pressed, the state machine returns to user input
-            next_state=0;
-        }
-    }
-    
-    //   return 0;
-}
-
-//***************************************************
-//******************functions************************
-void output_menu() {
-    //    lcd.cls();
-    strings temp=strings_array[selected_string];
-    /*lcd.*/printf("Select String: %d\nSelect Pitch: %s",selected_string,temp.get_note().c_str());
-            fflush(stdout);
-        }
-
-//***************************************************
-void button_init(){
-    //    string_but.mode( PullDown );
-    //    string_but.setSampleFrequency();
-    
-    //    pitch_but.mode( PullDown );
-    //    pitch_but.setSampleFrequency();
-    
-    //    start_but.mode( PullDown );
-    //    start_but.setSampleFrequency();
-    
-    //    mode_but.mode( PullDown );
-    //    mode_but.setSampleFrequency();
-}
-
-//***************************************************
-void setup_buttons() {
-    if(current_mode==tuning_mode){
-        //    string_but.attach_asserted(&string_sel);
-        //    pitch_but.attach_asserted(&pitch_sel);
-        //    start_but.attach_asserted(&start);
-        //    mode_but.attach_asserted(&mode);
-    }
-    else{
-        //    string_but.attach_asserted(&wind_up);
-        //    pitch_but.attach_asserted(&wind_down);
-        //    start_but.attach_asserted(&do_nothing);
-        //    mode_but.attach_asserted(&mode);
-    }
-}
-//***************************************************
-void string_sel() {
-    selected_string++;
-    if (selected_string>6)
-        selected_string=1;
-    
-    output_menu();
-}
-//***************************************************
-void pitch_sel() {
-    strings *temp=&strings_array[selected_string];
-    temp->inc_index();
-    
-    output_menu();
-}
-//***************************************************
-void start() {
-    start_tuning=true;
-}
-//***************************************************
-void mode() {
-    if(current_mode==tuning_mode){
-        current_mode=winding_mode;
-        //lcd.cls();
-        /*lcd.*/printf("Winding Mode");
-                //wait(1);
-            }
-    else{
-        current_mode=tuning_mode;
-        //lcd.cls();
-        /*lcd.*/printf("Tuning Mode");
-                //wait(1);
-            }
-    setup_buttons();
-}
-//***************************************************
-void stop() {
-    start_tuning=false;
-}
-//***************************************************
-void do_nothing(){
-    return;
-}
-//***************************************************
-void wind_up(){
-    //motor.motor_turn(1,10);
-}
-//***************************************************
-void wind_down(){
-    //motor.motor_turn(0,10);
-}
-//***************************************************
-void device_init(){
-    strings string1(1);
-    strings string2(2);
-    strings string3(3);
-    strings string4(4);
-    strings string5(5);
-    strings string6(6);
-    strings_array.push_back(string1);
-    strings_array.push_back(string2);
-    strings_array.push_back(string3);
-    strings_array.push_back(string4);
-    strings_array.push_back(string5);
-    strings_array.push_back(string6);
-    
-    selected_string=1;
-    current_mode=tuning_mode;
-    start_tuning=false;
-    up=true;
-    down=false;
-    
-    button_init();
-    
-    output_menu();
-}
-//***************************************************
-void motor_calibration(){
-    //lcd.cls();
-    //lcd.
-    printf("Calibrate Motor");
-    
-    float freq=0, freq_up, freq_down;
-    // bool calibration_done=false;
-    bool done=false;
-    //lcd.cls();
-    /*lcd.*/
-    printf("Please pluck\nstring");
-    
-    //motor.motor_turn(up,25)//TODO: Adjust the number of steps here
-    //On second thought, we don't need to tune up and down for this, we can find the current frequency
-    //and then turn the peg for two frequencies!
-    while(!done){
-        //freq=frequency.find_frequency();
-        
-        if(freq>500){
-            printf("Please pluck\nstring again");
-            //wait(.5);
-            //lcd.cls();
-        }
-        else{
-            freq_up=freq;
-            done=true;
-        }
-    }
-    //motor.motor_turn(down,25)//TODO: Adjust the number of steps here
-    done=false;
-    while(!done){
-        //freq=frequency.find_frequency();
-        
-        if(freq>500){
-            printf("Please pluck\nstring again");
-            //wait(.5);
-            //lcd.cls();
-        }
-        else{
-            freq_down=freq;
-            done=true;
-        }
-    }
-    
-    if(freq_up<freq_down){
-        down=true;
-        up=false;
-    }
-    
-    //lcd.cls();
-    //lcd.
-    printf("Calibration Done");
-}
-//**********************************************
-bool check_threshold(float freq){
-    if(freq>500){
-        //lcd.cls();
-        //lcd.
-        printf("Pluck string \nagain");
-        return false;
-    }
-    else
-        return true;
-}
+#include "mbed.h"
+#include "Motor.h"
+#include "FrequencyFinder.h"
+#include "NewTextLCD.h"
+#include "PinDetect.h"
+#include "strings.h"
+#include <iostream>
+#include <stdio.h>
+#include <vector>
+
+using namespace std;
+//***************************************************
+//***************Globals*****************************
+PinDetect string_but(p11);
+PinDetect pitch_but(p12);
+PinDetect start_but(p13);
+PinDetect mode_but(p14);
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+
+TextLCD lcd(p23,p24,p25,p26,p27,p28);
+Motor motor(p20,p21,p22);//enable, direction, step
+FrequencyFinder guitar(p19);//input
+
+int selected_string;
+bool current_mode;
+bool start_tuning;
+bool up, down;
+
+vector<strings> strings_array;
+
+//***************************************************
+//*****************constants*************************
+const bool tuning_mode=false;
+const bool winding_mode=true;
+
+//***************************************************
+//******************prototypes***********************
+void device_init();
+
+void string_sel();
+void pitch_sel();
+void start();
+void stop();
+void mode();
+void do_nothing();
+void wind_up();
+void wind_down();
+
+void button_init();
+void setup_buttons();
+void output_menu();
+void motor_calibration();
+bool check_threshold(float);
+//*************************************************
+//*********************main************************
+int main() {
+    lcd.cls();
+    lcd.printf("Perfect\n      Pitch");
+
+    wait(.5);
+
+    device_init();
+
+    int state=0,next_state=0;
+    //float old_freq=0;
+    float new_freq=0;
+    float desired_freq=0;
+    strings *temp=&strings_array[0];
+    while (1) {
+
+        state=next_state;
+
+        switch (state) {
+                //------------------------------------
+            case 0://Stay here till the user selects the string and pitch
+                if (start_tuning==true) {
+                    next_state=1;
+                } else {
+                    next_state=0;
+                }
+
+                break;
+                //----------------------------------------
+            case 1://motor calibration state
+                motor_calibration();
+                next_state=2;
+                break;
+                //-----------------------------------------
+            case 2://begin the actual tuning
+                temp=&strings_array[selected_string];
+                desired_freq=temp->get_freq();
+
+                next_state=3;
+                break;
+                //-----------------------------------------
+            case 3:
+                new_freq=guitar.find_frequency();
+                if (check_threshold(new_freq)) {
+                    if ((desired_freq-.5)<new_freq && (desired_freq+.5)>new_freq) {//We are within .5Hz of the desired frequency
+                        lcd.cls();
+                        lcd.printf("String %d\ntuned",selected_string);
+                        wait(.5);
+
+                        start_tuning=false;
+                        next_state=0;
+                    } else if ((desired_freq-.5)>new_freq) {
+                        //motor(up,# of steps);
+                        next_state=3;
+                    } else {
+                        //motor(down,# of steps);
+                        next_state=3;
+                    }
+                } else {
+                    next_state=3;
+                }
+
+                //TODO:Determine number of steps per frequency change
+                //old_freq=new_freq;
+                break;
+                //-----------------------------------------
+            default:
+                break;
+        }
+        wait_ms(5);
+
+        if (start_tuning==false) {//If the stop button is pressed, the state machine returns to user input
+            next_state=0;
+        }
+    }
+
+    //   return 0;
+}
+
+//***************************************************
+//******************functions************************
+void output_menu() {
+    lcd.cls();
+    strings temp=strings_array[selected_string];
+    lcd.printf("Select String: %d\nSelect Pitch: %s",selected_string,temp.get_note().c_str());
+}
+
+//***************************************************
+void button_init() {
+    string_but.mode( PullDown );
+    string_but.setSampleFrequency();
+
+    pitch_but.mode( PullDown );
+    pitch_but.setSampleFrequency();
+
+    start_but.mode( PullDown );
+    start_but.setSampleFrequency();
+
+    mode_but.mode( PullDown );
+    mode_but.setSampleFrequency();
+}
+
+//***************************************************
+void setup_buttons() {
+    if (current_mode==tuning_mode) {
+        string_but.attach_asserted(&string_sel);
+        pitch_but.attach_asserted(&pitch_sel);
+        start_but.attach_asserted(&start);
+        mode_but.attach_asserted(&mode);
+    } else {
+        string_but.attach_asserted(&wind_up);
+        pitch_but.attach_asserted(&wind_down);
+        start_but.attach_asserted(&do_nothing);
+        mode_but.attach_asserted(&mode);
+    }
+}
+//***************************************************
+void string_sel() {
+    selected_string++;
+    if (selected_string>6)
+        selected_string=1;
+
+    output_menu();
+}
+//***************************************************
+void pitch_sel() {
+    strings *temp=&strings_array[selected_string];
+    temp->inc_index();
+
+    output_menu();
+}
+//***************************************************
+void start() {
+    start_tuning=true;
+}
+//***************************************************
+void mode() {
+    if (current_mode==tuning_mode) {
+        current_mode=winding_mode;
+        lcd.cls();
+        lcd.printf("Winding Mode");
+        wait(1);
+    } else {
+        current_mode=tuning_mode;
+        lcd.cls();
+        lcd.printf("Tuning Mode");
+        wait(1);
+    }
+    setup_buttons();
+}
+//***************************************************
+void stop() {
+    start_tuning=false;
+}
+//***************************************************
+void do_nothing() {
+    return;
+}
+//***************************************************
+void wind_up() {
+    motor.motor_turn(1,10);
+}
+//***************************************************
+void wind_down() {
+    motor.motor_turn(0,10);
+}
+//***************************************************
+void device_init() {
+    strings string1(1);
+    strings string2(2);
+    strings string3(3);
+    strings string4(4);
+    strings string5(5);
+    strings string6(6);
+    strings_array.push_back(string1);
+    strings_array.push_back(string2);
+    strings_array.push_back(string3);
+    strings_array.push_back(string4);
+    strings_array.push_back(string5);
+    strings_array.push_back(string6);
+
+    selected_string=1;
+    current_mode=tuning_mode;
+    start_tuning=false;
+    up=true;
+    down=false;
+
+    button_init();
+
+    output_menu();
+}
+//***************************************************
+void motor_calibration() {
+    lcd.cls();
+    lcd.printf("Calibrate Motor");
+
+    float freq=0, freq_up=0, freq_down=0;
+    bool done=false;
+    lcd.cls();
+    lcd.printf("Please pluck\nstring");
+
+    //motor.motor_turn(up,25)//TODO: Adjust the number of steps here
+    //On second thought, we don't need to tune up and down for this, we can find the current frequency
+    //and then turn the peg for the two frequencies!
+    while (!done) {
+        freq=guitar.find_frequency();
+
+        if (check_threshold(freq)) {
+            freq_up=freq;
+            done=true;
+        }
+    }
+    motor.motor_turn(down,25);//TODO: Adjust the number of steps here
+    done=false;
+    while (!done) {
+        freq=guitar.find_frequency();
+
+        if (check_threshold(freq)) {
+            freq_down=freq;
+            done=true;
+        }
+    }
+
+    if (freq_up<freq_down) {
+        down=true;
+        up=false;
+    }
+
+    lcd.cls();
+    lcd.printf("Calibration Done");
+}
+//**********************************************
+bool check_threshold(float freq) {
+    if (freq>500) {
+        lcd.cls();
+        lcd.printf("Pluck string \nagain");
+        return false;
+    } else
+        return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/strings/.lib	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,1 @@
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/strings/strings.cpp	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,156 @@
+#include "strings.h"
+
+
+strings::strings(int string_num)
+{
+    index=4;
+    switch(string_num){
+    case 6:
+        frequencies[0]=65.4;
+        frequencies[1]=69.3;
+        frequencies[2]=73.4;
+        frequencies[3]=77.7;
+        frequencies[4]=82.4;
+        frequencies[5]=87.3;
+        frequencies[6]=92.5;
+        frequencies[7]=98;
+        frequencies[8]=103.8;
+        notes[0]="C";
+        notes[1]="C#";
+        notes[2]="D";
+        notes[3]="D#";
+        notes[4]="E";
+        notes[5]="F";
+        notes[6]="F#";
+        notes[7]="G";
+        notes[8]="G#";
+        break;
+
+    case 5:
+        frequencies[0]=87.3;
+        frequencies[1]=92.5;
+        frequencies[2]=98;
+        frequencies[3]=103.8;
+        frequencies[4]=110;
+        frequencies[5]=116.5;
+        frequencies[6]=123.4;
+        frequencies[7]=130.8;
+        frequencies[8]=138.6;
+        notes[0]="F";
+        notes[1]="F#";
+        notes[2]="G";
+        notes[3]="G#";
+        notes[4]="A";
+        notes[5]="A#";
+        notes[6]="B";
+        notes[7]="C";
+        notes[8]="C#";
+        break;
+
+    case 4:
+        frequencies[0]=116.5;
+        frequencies[1]=123.4;
+        frequencies[2]=130.8;
+        frequencies[3]=138.6;
+        frequencies[4]=146.8;
+        frequencies[5]=155.56;
+        frequencies[6]=164.8;
+        frequencies[7]=174.6;
+        frequencies[8]=184.9;
+        notes[0]="A#";
+        notes[1]="B";
+        notes[2]="C";
+        notes[3]="C#";
+        notes[4]="D";
+        notes[5]="D#";
+        notes[6]="E";
+        notes[7]="F";
+        notes[8]="F#";
+        break;
+
+    case 3:
+        frequencies[0]=155.6;
+        frequencies[1]=164.8;
+        frequencies[2]=174.6;
+        frequencies[3]=184.9;
+        frequencies[4]=195.9;
+        frequencies[5]=207.6;
+        frequencies[6]=220;
+        frequencies[7]=233.1;
+        frequencies[8]=246.9;
+        notes[0]="D#";
+        notes[1]="E";
+        notes[2]="F";
+        notes[3]="F#";
+        notes[4]="G";
+        notes[5]="G#";
+        notes[6]="A";
+        notes[7]="A#";
+        notes[8]="B";
+        break;
+
+    case 2:
+        frequencies[0]=195.9;
+        frequencies[1]=207.6;
+        frequencies[2]=220;
+        frequencies[3]=233.1;
+        frequencies[4]=246.9;
+        frequencies[5]=261.6;
+        frequencies[6]=277.1;
+        frequencies[7]=293.6;
+        frequencies[8]=311.1;
+        notes[0]="G";
+        notes[1]="G#";
+        notes[2]="A";
+        notes[3]="A#";
+        notes[4]="B";
+        notes[5]="C";
+        notes[6]="C#";
+        notes[7]="D";
+        notes[8]="D#";
+        break;
+
+    case 1:
+        frequencies[0]=261.6;
+        frequencies[1]=277.1;
+        frequencies[2]=293.6;
+        frequencies[3]=311.1;
+        frequencies[4]=329.6;
+        frequencies[5]=349.2;
+        frequencies[6]=369.9;
+        frequencies[7]=391.9;
+        frequencies[8]=415.3;
+        notes[0]="C";
+        notes[1]="C#";
+        notes[2]="D";
+        notes[3]="D#";
+        notes[4]="E";
+        notes[5]="F";
+        notes[6]="F#";
+        notes[7]="G";
+        notes[8]="G#";
+        break;
+
+    default:
+            break;
+    }
+}
+
+
+strings::~strings(void)
+{
+}
+
+void strings::inc_index(){
+    index++;
+    if(index>9)
+        index=0;
+}
+
+std::string strings::get_note(){
+    return notes[index];
+}
+
+float strings::get_freq(){
+    return frequencies[index];
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/strings/strings.h	Sun Apr 15 00:37:37 2012 +0000
@@ -0,0 +1,18 @@
+#pragma once
+#include <string>
+
+class strings
+{
+public:
+    strings(int string_num);
+    ~strings(void);
+
+    void inc_index();
+    std::string get_note();
+    float get_freq();
+
+private:
+    float frequencies[9];
+    std::string notes [9];
+    int index;
+};