Beispiel #1
0
bool Toolkit::Drag( std::string elementId, int x, int y )
{
    if ( !m_doc.GetDrawingPage() ) return false;
    Object *element = m_doc.GetDrawingPage()->FindChildByUuid(elementId);
    if ( dynamic_cast<Note*>(element) ) {
        Note *note = dynamic_cast<Note*>(element);
        Layer *layer = dynamic_cast<Layer*>(note->GetFirstParent(&typeid(Layer)));
        if ( !layer ) return false;
        int oct;
        data_PITCHNAME pname = (data_PITCHNAME)m_view.CalculatePitchCode( layer, m_view.ToLogicalY(y), note->GetDrawingX(), &oct  );
        note->SetPname(pname);
        note->SetOct(oct);
        return true;
    }
    return false;
}
Beispiel #2
0
void PaeInput::parseNote(NoteObject note) {
    
    LayerElement *element;
    
    if (note.rest) {
        Rest *rest =  new Rest();
        
        rest->SetDots( note.dots );
        rest->SetDur(note.duration);

        if (note.fermata) {
            rest->SetFermata(PLACE_above); // always above for now
        }
        
        element = rest;
    } else {
        Note *mnote = new Note();
        
        mnote->SetPname(note.pitch);
        mnote->SetOct(note.octave);
        mnote->SetAccid(note.accidental);
        
        mnote->SetDots( note.dots );
        mnote->SetDur(note.duration);
        
        if (note.fermata) {
            mnote->SetFermata(PLACE_above); // always above for now
        }
        
        if (note.trill == true)
            mnote->m_embellishment = EMB_TRILL;
        
        if (m_last_tied_note != NULL) {
            mnote->SetTie(TIE_t);
            m_last_tied_note = NULL;
        }
        
        if (note.tie) {
            if (mnote->GetTie()==TIE_t) mnote->SetTie(TIE_m);
            else mnote->SetTie(TIE_i);
            m_last_tied_note = mnote;
        }
        
        element = mnote;
    }
    
    // Does this note have a clef change? push it before everyting else
    if (note.clef)
        addLayerElement(note.clef);

    // Same thing for time changes
    // You can find this sometimes
    if (note.meter)
        addLayerElement(note.meter);
    
    // Handle key change. Evil if done in a beam
    if (note.key)
        addLayerElement(note.key);
    
    // Acciaccaturas are similar but do not get beamed (do they)
    // this case is simpler. NOTE a note can not be acciacctura AND appoggiatura
    // Acciaccatura rests do not exist
    if (note.acciaccatura && (element->Is() == NOTE) ) {
        Note *note = dynamic_cast<Note*>(element);
        assert( note );
        note->SetDur(DURATION_8);
        note->SetGrace(GRACE_acc);
        note->SetStemDir(STEMDIRECTION_up);
    }
    
    if ( (note.appoggiatura > 0) && (element->Is() == NOTE) ) {
        Note *note = dynamic_cast<Note*>(element);
        assert( note );
        note->SetGrace(GRACE_unacc);
        note->SetStemDir(STEMDIRECTION_up);
    }

    if (note.beam == BEAM_INITIAL) {
        pushContainer(new Beam());
    }
    
    // we have a tuplet, the tuplet_note is > 0
    // which means we are counting a tuplet
    if (note.tuplet_note > 0 && note.tuplet_notes == note.tuplet_note) { // first elem in tuplet
        Tuplet *newTuplet = new Tuplet();
        newTuplet->SetNum(note.tuplet_notes);
        newTuplet->SetNumbase(note.tuplet_notes);
        pushContainer(newTuplet);
    }
    
    
    // Add the note to the current container
    addLayerElement(element);
    
    // the last note counts always '1'
    // insert the tuplet elem
    // and reset the tuplet counter
    if (note.tuplet_note == 1)
        popContainer();
    
    if (note.beam == BEAM_TERMINAL)
        popContainer();
}