List of frequencies and strings for a guitar
Revision 0:ed8fce1752f7, committed 2012-11-25
- Comitter:
- melangeaddict
- Date:
- Sun Nov 25 23:10:30 2012 +0000
- Commit message:
- [mbed] converted /tuner/strings
Changed in this revision
strings.cpp | Show annotated file Show diff for this revision Revisions of this file |
strings.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r ed8fce1752f7 strings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/strings.cpp Sun Nov 25 23:10:30 2012 +0000 @@ -0,0 +1,165 @@ +#include "strings.h" + +strings::strings() { + +} + +strings::strings(int string_num) { + set_values(string_num); +} + +strings::~strings(void) { + +} + +void strings::set_values(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; + } +} + +void strings::inc_index() { + index++; + if (index>=9) + index=0; +} + +void strings::reset_index(){ + index=4; +} + +char* strings::get_note() { + return notes[index]; +} + +float strings::get_freq() { + return frequencies[index]; +}
diff -r 000000000000 -r ed8fce1752f7 strings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/strings.h Sun Nov 25 23:10:30 2012 +0000 @@ -0,0 +1,24 @@ +#pragma once +#include "string" + +class strings +{ +public: + strings(int string_num); + strings(); + ~strings(void); + + void inc_index(); + void reset_index(); + char* get_note(); + float get_freq(); + + protected: + void set_values(int string_num); + +private: + float frequencies[9]; + char *notes [9]; + int index; + float threshold[6]; +};