Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Chord Note Finder
#include <string> #include <iostream> std::string intToNote(int number){ if (number > 12){ number += -12; } else if (number < 1){ number += 12; } std::string note; if (number == 1){ note = "A"; } else if (number == 2){ note = "A#"; } else if (number == 3){ note = "B"; } else if (number == 4){ note = "C"; } else if (number == 5){ note = "C#"; } else if (number == 6){ note = "D"; } else if (number == 7){ note = "D#"; } else if (number == 8){ note = "E"; } else if (number == 9){ note = "F"; } else if (number == 10){ note = "F#"; } else if (number == 11){ note = "G"; } else if (number == 12){ note = "G#"; } return note; } int main() { std::cout << "Please enter your desired chord: "; char rootChord; std::cin >> rootChord; //std::cout << "Your chord is " << rootChord; std::cout << std::endl; std::cout << "Please enter # for sharp, N for natural or b for flat: "; char semitone; std::cin >> semitone; std::cout << std::endl; std::cout << "Please enter M for major, m for minor and d for diminished: "; char type; std::cin >> type; std::cout << std::endl; int notea; int noteb; int notec; if (rootChord == 'A' || rootChord == 'a'){ //std::cout << "Your Chord is A"; notea = 1; } else if (rootChord == 'B' || rootChord == 'b'){ //std::cout << "Your Chord is B"; notea = 3; } else if (rootChord == 'C' || rootChord == 'c'){ //std::cout << "Your Chord is C"; notea = 4; } else if (rootChord == 'D' || rootChord == 'd'){ //std::cout << "Your Chord is D"; notea = 6; } else if (rootChord == 'E' || rootChord == 'e'){ //std::cout << "Your Chord is E"; notea = 8; } else if (rootChord == 'F' || rootChord == 'f'){ //std::cout << "Your Chord is F"; notea = 9; } else if (rootChord == 'G' || rootChord == 'g'){ //std::cout << "Your Chord is G"; notea = 11; } else{ std::cout << "Your Chord is not recognised, it will be set to C as default" << std::endl; notea = 4; } if (semitone == '#'){ notea += 1; } else if (semitone == 'N'){ notea += 0; } else if (semitone == 'b'){ notea += -1; } else{ std::cout << "You entered an invalid sharp, natural or flat, it will be set to natural as default" << std::endl; } if (type == 'M'){ noteb = notea + 4; notec = noteb + 3; } else if (type == 'm'){ noteb = notea + 3; notec = noteb + 4; } else if (type == 'd'){ noteb = notea + 3; notec = noteb + 3; } else{ std::cout << "You entered an invalid major, minor or diminished, it will be set to major as default" << std::endl; noteb = notea + 4; notec = noteb + 3; } std::cout << intToNote(notea) << std::endl << intToNote(noteb) << std::endl << intToNote(notec) << std::endl; if (notea > 12) notea += -12; else if (notea < 1) notea += 12; if (noteb > 12) noteb += -12; else if (noteb < 1) noteb += 12; if (notec > 12) notec += -12; else if (noteb < 1) notec += 12; for (int x = 0; x < 2; x++){ if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "|████|"; }else std::cout << "| |"; if (notea == 2 || noteb == 2 || notec == 2){ std::cout << "█|"; }else std::cout << " |"; if (notea == 3 || noteb == 3 || notec == 3){ std::cout << "████|"; }else std::cout << " |"; if (notea == 4 || noteb == 4 || notec == 4){ std::cout << "████|"; }else std::cout << " |"; if (notea == 5 || noteb == 5 || notec == 5){ std::cout << "█|"; }else std::cout << " |"; if (notea == 6 || noteb == 6 | notec == 6){ std::cout << "███|"; }else std::cout << " |"; if (notea == 7 || noteb == 7 || notec == 7){ std::cout << "█|"; }else std::cout << " |"; if (notea == 8 || noteb == 8 || notec == 8){ std::cout << "████|"; }else std::cout << " |"; if (notea == 9 || noteb == 9 || notec == 9){ std::cout << "████|"; }else std::cout << " |"; if (notea == 10 || noteb == 10 || notec == 10){ std::cout << "█|"; }else std::cout << " |"; if (notea == 11 || noteb == 11 || notec == 11){ std::cout << "███|"; }else std::cout << " |"; if (notea == 12 || noteb == 12 || notec == 12){ std::cout << "█|"; }else std::cout << " |"; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "████|" << std::endl; }else std::cout << " |" << std::endl; } if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "|████|"; }else std::cout << "| |"; if (notea == 2 || noteb == 2 || notec == 2){ std::cout << "█|"; }else std::cout << "_|"; if (notea == 3 || noteb == 3 || notec == 3){ std::cout << "████|"; }else std::cout << " |"; if (notea == 4 || noteb == 4 || notec == 4){ std::cout << "████|"; }else std::cout << " |"; if (notea == 5 || noteb == 5 || notec == 5){ std::cout << "█|"; }else std::cout << "_|"; if (notea == 6 || noteb == 6 | notec == 6){ std::cout << "███|"; }else std::cout << " |"; if (notea == 7 || noteb == 7 || notec == 7){ std::cout << "█|"; }else std::cout << "_|"; if (notea == 8 || noteb == 8 || notec == 8){ std::cout << "████|"; }else std::cout << " |"; if (notea == 9 || noteb == 9 || notec == 9){ std::cout << "████|"; }else std::cout << " |"; if (notea == 10 || noteb == 10 || notec == 10){ std::cout << "█|"; }else std::cout << "_|"; if (notea == 11 || noteb == 11 || notec == 11){ std::cout << "███|"; }else std::cout << " |"; if (notea == 12 || noteb == 12 || notec == 12){ std::cout << "█|"; }else std::cout << "_|"; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "████|" << std::endl; }else std::cout << " |" << std::endl; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "|██A██|"; }else std::cout << "| A |"; if (notea == 3 || noteb == 3 || notec == 3){ std::cout << "██B██|"; }else std::cout << " B |"; if (notea == 4 || noteb == 4 || notec == 4){ std::cout << "██C██|"; }else std::cout << " C |"; if (notea == 6 || noteb == 6 || notec == 6){ std::cout << "██D██|"; }else std::cout << " D |"; if (notea == 8 || noteb == 8 || notec == 8){ std::cout << "██E██|"; }else std::cout << " E |"; if (notea == 9 || noteb == 9 || notec == 9){ std::cout << "██F██|"; }else std::cout << " F |"; if (notea == 11 || noteb == 11 || notec == 11){ std::cout << "██G██|"; }else std::cout << " G |"; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "██A██|" << std::endl; }else std::cout << " A |" << std::endl; for (int x = 0; x < 2; x++){ if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "|█████|"; }else std::cout << "| |"; if (notea == 3 || noteb == 3 || notec == 3){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 4 || noteb == 4 || notec == 4){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 6 || noteb == 6 || notec == 6){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 8 || noteb == 8 || notec == 8){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 9 || noteb == 9 || notec == 9){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 11 || noteb == 11 || notec == 11){ std::cout << "█████|"; }else std::cout << " |"; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "█████|" << std::endl; }else std::cout << " |" << std::endl; } if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "|█████|"; }else std::cout << "|_____|"; if (notea == 3 || noteb == 3 || notec == 3){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 4 || noteb == 4 || notec == 4){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 6 || noteb == 6 || notec == 6){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 8 || noteb == 8 || notec == 8){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 9 || noteb == 9 || notec == 9){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 11 || noteb == 11 || notec == 11){ std::cout << "█████|"; }else std::cout << "_____|"; if (notea == 1 || noteb == 1 || notec == 1){ std::cout << "█████|" << std::endl; }else std::cout << "_____|" << std::endl; return 0; }
run
|
edit
|
history
|
help
0
Compile time creation of class member stl container (const std::array) filled with elements.
vc++ bug?
MSVC14 <experimental/generator> header
Removing __unaligned specifier partial solution
trying to find if reinterpret_cast preserves calling convention
Override keyword.cpp
default
Copy double[2][3] into vector<vector<double>>
pitch errors verification for Nowhk
make_integer_sequence