A program to automatically tune a guitar. Written by Justin Reidhead and Steven Swenson
Dependencies: FFT FrequencyFinder Motor NewTextLCD PinDetect mbed strings
Diff: strings/strings.cpp
- Revision:
- 15:bb2bc286f44b
- Parent:
- 14:fd59e7acf2e5
diff -r fd59e7acf2e5 -r bb2bc286f44b strings/strings.cpp --- a/strings/strings.cpp Thu Apr 26 22:20:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -#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]; -}