void TscoreMeasure::fill() { QList<TscoreNote*> notesToShift; int remainDur = m_staff->shiftFromMeasure(id() + 1, m_free, notesToShift); qDebug() << debug() << "fill, remain" << remainDur << "to shift:" << notesToShift.count(); for (int i = 0; i < notesToShift.size(); ++i) { m_notes.append(notesToShift[i]); connect(notesToShift[i], &TscoreNote::noteGoingToChange, this, &TscoreMeasure::noteChangedSlot); } if (remainDur) { // next measure has a part of a new note qDebug() << debug() << remainDur << "remained in the next measure"; auto firstInNext = m_staff->measures()[id() + 1]->firstNote()->note(); Tnote newNote(*firstInNext, Trhythm(remainDur, firstInNext->isRest())); auto inserted = m_staff->insertNote(newNote, lastNoteId() + 1, lastNote()->isReadOnly()); // copyRhythmParams(inserted, firstInNext->rtm); fixStemDirection(inserted); insertNote(inserted->index() - firstNoteId(), inserted); m_staff->updateNotesPos(); if (!inserted->note()->isRest()) // add a tie inserted->tieWithNext(); } else { updateRhythmicGroups(); resolveBeaming(0); checkBarLine(); } content(this); }
void NotePool::insertLegatoNote(uint8_t note, uint8_t sendto, SynthDescriptor desc) { assert(desc.note); try { desc.note = desc.note->cloneLegato(); insertNote(note, sendto, desc, true); } catch (std::bad_alloc &ba) { std::cerr << "failed to insert legato note: " << ba.what() << std::endl; } };
void PageItem_NoteFrame::updateNotes(QList<TextNote*> nList, bool clear) { if (nList == l_notes && !clear) return; UndoManager::instance()->setUndoEnabled(false); m_Doc->setNotesChanged(true); //itemText.blockSignals(true); if (clear) { itemText.selectAll(); deleteSelectedTextFromFrame(); l_notes = nList; for (int a=0; a < l_notes.count(); ++a) insertNote(l_notes.at(a)); } else { //just insert new notes into frame notes list int count = nList.count(); if (count > 0) { for (int i=0; i< count; ++i) { TextNote* note = nList.at(i); if (!l_notes.contains(note)) { l_notes.append(note); insertNote(note); } } } } UndoManager::instance()->setUndoEnabled(true); //itemText.blockSignals(false); invalid = true; }
void TscoreMeasure::insertNote(int id, TscoreNote* sn) { // qDebug() << debug() << sn->note()->rtm.xmlType() << "inserting id" << id << "count" << m_notes.count() << "free" << m_free; int noteDur = sn->note()->duration(); int resolveAfter = 0; // un-resolvable duration of new note QList<TscoreNote*> notesToOut; Tnote newNote; // new note that has to be created when rhythm duration is split if (sn->note()->rhythm() != Trhythm::e_none && m_free - noteDur < 0) { // move notes to the next measure if not enough space int toRelease = releaseAtEnd(noteDur - m_free, notesToOut, newNote, id); if (toRelease > 0) { // There is still not enough space if (m_free > 0) { // measure has some free space for the new note but not for entire if (Trhythm(m_free).rhythm() == Trhythm::e_none) { Trhythm subRhythm(noteDur - m_free, sn->note()->isRest()); subRhythm.setTie(sn->note()->rtm.tie()); subRhythm.setStemDown(sn->note()->rtm.stemDown()); if (subRhythm.rhythm() == Trhythm::e_none) qDebug() << debug() << "can not shrink note to duration" << noteDur - m_free; sn->setRhythm(subRhythm); splitThenInsert(m_free, id, *sn->note(), sn->isReadOnly()); insertNote(lastNoteId() + 1, sn); if (!sn->note()->isRest()) lastNote()->tieWithNext(); return; } Trhythm oldRhythm(sn->note()->rtm); sn->setRhythm(Trhythm(m_free, sn->note()->isRest())); copyRhythmParams(sn, oldRhythm); // sn->note()->rtm.setTie(oldRhythm.tie()); // sn->note()->rtm.setStemDown(oldRhythm.stemDown()); if (newNote.rhythm() != Trhythm::e_none) // TODO: remove when tested qDebug() << "NEW NOTE is already created!!!"; Trhythm newRtm(noteDur - m_free, sn->note()->isRest()); if (newRtm.rhythm() == Trhythm::e_none) // two notes have to be added resolveAfter = noteDur - m_free; // do it after else newNote = Tnote(*sn->note(), newRtm); noteDur = m_free; } else { // measure has not at all space qDebug() << debug() << "move entire note" << sn->note()->toText(); notesToOut << sn; m_staff->shiftToMeasure(m_staff->measures().indexOf(this) + 1, notesToOut); return; } } } m_free -= noteDur; m_notes.insert(id, sn); qDebug() << debug() << "measure got a note" << sn->note()->rtm.xmlType() << "FREE" << m_free << "out" << notesToOut.count(); connect(sn, &TscoreNote::noteGoingToChange, this, &TscoreMeasure::noteChangedSlot); updateRhythmicGroups(); resolveBeaming(sn->rhythmGroup()); checkBarLine(); shiftReleased(notesToOut, newNote); if (resolveAfter) { auto lastN = lastNote(); splitThenInsert(resolveAfter, lastN->index() + 1, *lastN->note(), lastN->isReadOnly()); } content(this); }
void NotePool::insertLegatoNote(uint8_t note, uint8_t sendto, SynthDescriptor desc) { assert(desc.note); desc.note = desc.note->cloneLegato(); insertNote(note, sendto, desc, true); };
void NoteModel::editNote(const QDomElement& note, const QModelIndex &index) { delNote(index); insertNote(note, index); }