/** * iterate through notes in backward order (right to left), take note by note to release required duration * create a list from taken notes to send it to the next measure * split the latest note (the most right one in the measure) if necessary * half of the duration remains in current measure at the end tied with * a new note that has to be created and push to the beginning of the next measure */ int TscoreMeasure::releaseAtEnd(int dur, QList<TscoreNote*>& notesToOut, Tnote& newNote, int endNote) { int noteNr = m_notes.count() - 1; while (noteNr >= endNote && dur > 0) { auto lastN = lastNote(); int lastDur = lastN->note()->duration(); if (lastDur > dur) { // last note is longer than required space - split it then create and move the rest of its duration to the next measure if (Trhythm(lastDur - dur).rhythm() == Trhythm::e_none) { // subtracting can't be solved by single note split(lastN); // then split on two notes continue; // and call while loop again } Trhythm oldRhythm(lastN->note()->rtm); // preserve tie and stem direction lastN->setRhythm(Trhythm(lastDur - dur, lastN->note()->isRest())); copyRhythmParams(lastN, oldRhythm); // lastN->note()->rtm.setStemDown(oldRhythm.stemDown()); // if (oldRhythm.tie()) // lastN->note()->rtm.setTie(Trhythm::e_tieCont); newNote = Tnote(*lastN->note(), Trhythm(dur, lastN->note()->isRest())); // newNote.rtm.setStemDown(oldRhythm.stemDown()); lastDur = dur; } else { // last note is the same long or smaller than required space - so move it to the next measure notesToOut << m_notes.takeLast(); disconnect(notesToOut.last(), &TscoreNote::noteGoingToChange, this, &TscoreMeasure::noteChangedSlot); auto b = notesToOut.last()->beam(); if (b) { m_beams.removeOne(b); delete b; } } dur -= lastDur; m_free += lastDur; // note was taken out so there is more free space in the measure } return dur; }
void RhythmView::Beat(int j) { if (j>num) setRhythm(j,4); // This is a preventive case for (int i=0;i<num;i++) { lamps[i]->off(); } lamps[j-1]->on(); }
RhythmView::RhythmView (QWidget *parent, const char *name) : QWidget (parent,name) { lamps=NULL; setRhythm(4,4); }