/// Determines if the chord diagram's voicing is the same /// @param fretNumber1 Fret number for the 1st string in the chord diagram (for standard guitar tuning, this is the high E string) /// @param fretNumber2 Fret number for the 2nd string in the chord diagram /// @param fretNumber3 Fret number for the 3rd string in the chord diagram /// @param fretNumber4 Fret number for the 4th string in the chord diagram /// @param fretNumber5 Fret number for the 5th string in the chord diagram /// @param fretNumber6 Fret number for the 6th string in the chord diagram /// @param fretNumber7 Fret number for the 7th string in the chord diagram /// @return True if all of the chord diagram fret numbers match, false if not bool ChordDiagram::IsSameVoicing(wxByte fretNumber1, wxByte fretNumber2, wxByte fretNumber3, wxByte fretNumber4, wxByte fretNumber5, wxByte fretNumber6, wxByte fretNumber7) const { //------Last Checked------// // - Jan 15, 2005 ChordDiagram temp; temp.AddFretNumbers(fretNumber1, fretNumber2, fretNumber3, fretNumber4, fretNumber5, fretNumber6, fretNumber7); return (IsSameVoicing(temp)); }
/// Determines if the chord diagram's voicing is the same /// @param fretNumbers Fret numbers for each string in the chord diagram (from high to low) /// @return True if all of the chord diagram fret numbers match, false if not bool ChordDiagram::IsSameVoicing(const std::vector<uint8_t>& fretNumbers) const { ChordDiagram temp; temp.AddFretNumbers(fretNumbers); return IsSameVoicing(temp); }
/// Tests the Fret Number Functions /// @return True if all tests were executed, false if not bool ChordDiagramTestSuite::TestCaseFretNumber() { //------Last Checked------// // - Jan 16, 2005 // TEST CASE: IsValidFretNumber { wxByte i = ChordDiagram::MIN_FRET_NUMBER; for (; i <= (ChordDiagram::MAX_FRET_NUMBER + 1); i++) TEST(wxString::Format(wxT("IsValidFretNumber - %d"), i), (ChordDiagram::IsValidFretNumber(i) == (i <= ChordDiagram::MAX_FRET_NUMBER)) ); TEST(wxT("IsValidFretNumber - string muted"), ChordDiagram::IsValidFretNumber(ChordDiagram::stringMuted)); TEST(wxT("IsValidFretNumber - not used"), ChordDiagram::IsValidFretNumber(ChordDiagram::notUsed)); } // TEST CASE: SetFretNumber { ChordName chordName; chordName.SetFormula(ChordName::minor); ChordDiagram chordDiagram(chordName, 3, 3, 4, 5, 5, 3, ChordDiagram::stringMuted); TEST(wxT("SetFretNumber - invalid string"), !chordDiagram.SetFretNumber(6, 2)); TEST(wxT("SetFretNumber - invalid fret number"), !chordDiagram.SetFretNumber(0, 192)); wxUint32 i = 0; wxUint32 stringCount = chordDiagram.GetStringCount(); for (; i < stringCount; i++) TEST(wxString::Format(wxT("SetFretNumber - string %d"), i), (chordDiagram.SetFretNumber(i, 2)) && (chordDiagram.GetFretNumber(i) == 2) ); TEST(wxT("GetFretNumber - invalid string"), chordDiagram.GetFretNumber(6) == 0); } // TEST CASE: AddFretNumbers { ChordDiagram chordDiagram; TEST(wxT("AddFretNumbers - invalid fret number1"), !chordDiagram.AddFretNumbers(192, 4, 5, 5, 3, 3, 3)); TEST(wxT("AddFretNumbers - invalid fret number2"), !chordDiagram.AddFretNumbers(3, 192, 5, 5, 3, 3, 3)); TEST(wxT("AddFretNumbers - invalid fret number3"), !chordDiagram.AddFretNumbers(3, 4, 192, 5, 3, 3, 3)); TEST(wxT("AddFretNumbers - invalid fret number4"), !chordDiagram.AddFretNumbers(3, 4, 5, 192, 3, 3, 3)); TEST(wxT("AddFretNumbers - invalid fret number5"), !chordDiagram.AddFretNumbers(3, 4, 5, 5, 192, 3, 3)); TEST(wxT("AddFretNumbers - invalid fret number6"), !chordDiagram.AddFretNumbers(3, 4, 5, 5, 3, 192, 3)); TEST(wxT("AddFretNumbers - invalid fret number7"), !chordDiagram.AddFretNumbers(3, 4, 5, 5, 3, 3, 192)); TEST(wxT("AddFretNumbers - 3 string chordDiagram"), chordDiagram.AddFretNumbers(3, 4, 5, ChordDiagram::notUsed, ChordDiagram::notUsed, ChordDiagram::notUsed, ChordDiagram::notUsed) && chordDiagram.IsSameVoicing(3, 4, 5) ); TEST(wxT("AddFretNumbers - 4 string chordDiagram"), chordDiagram.AddFretNumbers(3, 4, 5, 5, ChordDiagram::notUsed, ChordDiagram::notUsed, ChordDiagram::notUsed) && chordDiagram.IsSameVoicing(3, 4, 5, 5) ); TEST(wxT("AddFretNumbers - 5 string chordDiagram"), chordDiagram.AddFretNumbers(3, 4, 5, 5, 3, ChordDiagram::notUsed, ChordDiagram::notUsed) && chordDiagram.IsSameVoicing(3, 4, 5, 5, 3) ); TEST(wxT("AddFretNumbers - 6 string chordDiagram"), chordDiagram.AddFretNumbers(3, 4, 5, 5, 3, 3, ChordDiagram::notUsed) && chordDiagram.IsSameVoicing(3, 4, 5, 5, 3, 3) ); TEST(wxT("AddFretNumbers - 7 string chordDiagram"), chordDiagram.AddFretNumbers(3, 4, 5, 5, 3, 3, 3) && chordDiagram.IsSameVoicing(3, 4, 5, 5, 3, 3, 3) ); } return (true); }