コード例 #1
0
ファイル: note.cpp プロジェクト: rondini/verovio
bool Note::IsClusterExtreme()
{
    ChordCluster* cluster = this->m_cluster;
    if (this == cluster->at(0)) return true;
    if (this == cluster->at(cluster->size() - 1)) return true;
    else return false;
}
コード例 #2
0
ファイル: chord.cpp プロジェクト: avorio/verovio
void Chord::ClearClusters()
{
    std::list<ChordCluster*>::iterator iter;
    for (iter = m_clusters.begin(); iter != m_clusters.end(); ++iter)
    {
        ChordCluster *cluster = dynamic_cast<ChordCluster*>(*iter);
        for (std::vector<Note*>::iterator clIter = cluster->begin(); clIter != cluster->end(); ++clIter)
        {
            Note *note = dynamic_cast<Note*>(*clIter);
            note->m_cluster = NULL;
            note->m_clusterPosition = 0;
        }
        delete *iter;
    }
    m_clusters.clear();
}
コード例 #3
0
ファイル: chord.cpp プロジェクト: avorio/verovio
void Chord::FilterList( ListOfObjects *childList )
{
    // Retain only note children of chords
    ListOfObjects::iterator iter = childList->begin();
    
    while ( iter != childList->end()) {
        LayerElement *currentElement = dynamic_cast<LayerElement*>(*iter);
        if ( !currentElement ) {
            // remove anything that is not an LayerElement
            iter = childList->erase( iter );
        }
        else if ( !currentElement->HasDurationInterface() )
        {
            iter = childList->erase( iter );
        }
        else /*if ( dynamic_cast<EditorialElement*>(currentElement))
        {
            Object* object = currentElement->GetFirstChild(&typeid(Note));
            if (dynamic_cast<Note*>(object))
            {
                iter++;
            }
        }
        else */{
            Note *n = dynamic_cast<Note*>(currentElement);
            
            if (n) {
                iter++;
            } else {
                // if it is not a note, drop it
                iter = childList->erase( iter );
            }
        }
    }
    
    childList->sort(compare_pitch);
    
    iter = childList->begin();
    
    this->ClearClusters();
    
    Note *curNote, *lastNote = dynamic_cast<Note*>(*iter);
    int curPitch, lastPitch = lastNote->GetDiatonicPitch();
    ChordCluster* curCluster = NULL;
    
    iter++;
    
    while ( iter != childList->end()) {
        curNote = dynamic_cast<Note*>(*iter);
        curPitch = curNote->GetDiatonicPitch();
        
        if (curPitch - lastPitch == 1) {
            if(!lastNote->m_cluster)
            {
                curCluster = new ChordCluster();
                m_clusters.push_back(curCluster);
                curCluster->push_back(lastNote);
                lastNote->m_cluster = curCluster;
                lastNote->m_clusterPosition = (int)curCluster->size();
            }
            curCluster->push_back(curNote);
            curNote->m_cluster = curCluster;
            curNote->m_clusterPosition = (int)curCluster->size();
        }
        
        lastNote = curNote;
        lastPitch = curPitch;
        
        iter++;
    }
}