コード例 #1
0
ファイル: chorddiagram.cpp プロジェクト: RaptDept/ptparser
// Voicing Functions
/// Determines if the chord diagram's voicing is the same as that of another
/// ChordDiagram object
/// @param chordDiagram ChordDiagram object to compare with
/// @return True if the chord diagrams have the same voicing, false if not
bool ChordDiagram::IsSameVoicing(const ChordDiagram& chordDiagram) const
{
    //------Last Checked------//
    // - Jan 15, 2005
    
    size_t thisStringCount = GetStringCount();
    size_t otherStringCount = chordDiagram.GetStringCount();
    
    // Chord diagrams have a different number of strings
    if (thisStringCount != otherStringCount)
        return (false);

    // Check each string for matching fret numbers
    size_t i = 0;
    for (; i < thisStringCount; i++)
    {
        if (m_fretNumberArray[i] != chordDiagram.m_fretNumberArray[i])
            return (false);
    }

    return (true);
}
コード例 #2
0
ファイル: chorddiagram.cpp プロジェクト: RaptDept/ptparser
/// Equality Operator
bool ChordDiagram::operator==(const ChordDiagram& chordDiagram) const
{
    //------Last Checked------//
    // - Jan 14, 2005
    
    size_t thisStringCount = GetStringCount();
    size_t otherStringCount = chordDiagram.GetStringCount();    
    if (thisStringCount != otherStringCount)
        return (false);
        
	size_t i = 0;
	for (; i < thisStringCount; i++)
	{
		if (m_fretNumberArray[i] != chordDiagram.m_fretNumberArray[i])
			return (false);
	}

    return (
        (m_chordName == chordDiagram.m_chordName) &&
        (m_topFret == chordDiagram.m_topFret)
    );
}
コード例 #3
0
ファイル: chorddiagram.cpp プロジェクト: RaptDept/ptparser
// Operations
/// Gets the spelling for the chord diagram (i.e. 0 2 2 1 0 0)
/// @return The spelling for the chord diagram
wxString ChordDiagram::GetSpelling() const
{
    //------Last Checked------//
    // - Jan 15, 2005
	wxString returnValue;

    size_t i = GetStringCount();
	for (; i > 0; i--)
	{
		wxString fretNumber;
		if (m_fretNumberArray[i - 1] == stringMuted)
			returnValue += _T("x");
		else
			fretNumber = wxString::Format(_T("%d"), m_fretNumberArray[i - 1]);
		returnValue += fretNumber;

        // Add a space between numbers
		if (i > 1)
			returnValue += _T(" ");
	}

    return (returnValue);
}
コード例 #4
0
ファイル: chorddiagram.cpp プロジェクト: RaptDept/ptparser
// Serialize Functions
/// Performs serialization for the class
/// @param stream Power Tab output stream to serialize to
/// @return True if the object was serialized, false if not
bool ChordDiagram::DoSerialize(PowerTabOutputStream& stream)
{
    //------Last Checked------//
    // - Jan 14, 2005
	m_chordName.Serialize(stream);
	wxCHECK(stream.CheckState(), false);
	
	stream << m_topFret;
	wxCHECK(stream.CheckState(), false);

	size_t count = GetStringCount();
	stream << (wxByte)count;
	wxCHECK(stream.CheckState(), false);
	
	size_t i = 0;
	for (; i < count; i++)
	{
    	stream << m_fretNumberArray[i];
        wxCHECK(stream.CheckState(), false);
    }
    	
    return (true);
}
コード例 #5
0
// Operations
/// Gets the spelling for the chord diagram (i.e. 0 2 2 1 0 0)
/// @return The spelling for the chord diagram
std::string ChordDiagram::GetSpelling() const
{
    std::stringstream text;

    for (size_t i = GetStringCount(); i > 0; i--)
    {
        if (m_fretNumberArray[i - 1] == stringMuted)
        {
            text << "x";
        }
        else
        {
            text << static_cast<int>(m_fretNumberArray[i-1]);
        }

        if (i > 1)
        {
            text << " ";
        }
    }

    return text.str();
}
コード例 #6
0
/// Determines if a string is valid
/// @param string String to validate
/// @return True if the string is valid, false if not
bool ChordDiagram::IsValidString(uint32_t string) const
{
    return string < GetStringCount();
}