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 Trhythm::split(TrhythmList& twoRhythms) const { if (rhythm() == e_none || rhythm() == e_sixteenth) return; // nothing to split if (hasDot()) { twoRhythms << Trhythm(rhythm(), isRest(), false) // no triplet for sure << Trhythm(static_cast<Erhythm>(rhythm() + 1), isRest()); // Also when there is a dot, for sure it is not lowest possible rhythm, so we may add 1 to rhythm value to obtain its half } else { Trhythm half(static_cast<Erhythm>(rhythm() + 1), isRest(), false, isTriplet()); twoRhythms << half << half; } if (!isRest() && twoRhythms.size() == 2) { twoRhythms.first().setStemDown(stemDown()); twoRhythms.last().setStemDown(stemDown()); } }
void Trhythm::debug(const char* text) const { if (m_r == e_none) qDebug() << text << "no rhythm"; else { qDebug() << text << xmlType() << "| rest" << isRest() << "| dot" << hasDot() << "| triplet" << isTriplet() << "| duration" << duration() << "| beam" << beam() << "| tie" << tie() << "| stem" << (stemDown() ? "down" : "up") << "|" << (m_prefs % 8) << m_prefs; } }
bool KML::isHandled(std::string const& elem) const { if( isLeaf(elem) || isFeature(elem) || isFeatureContainer(elem) || isContainer(elem) || isRest(elem) ) { return true; } return false; }
QString Trhythm::string() const { QString ret = QString::number(weight()); if (isRest()) ret.prepend(QStringLiteral("R")); if (hasDot()) ret.append(QStringLiteral(".")); else if (isTriplet()) ret.append(QStringLiteral("^3")); return ret; }
static char beamL1(int t, int v, int bn, TabTrack *trk) { // if column is a rest, then no beam if (isRest(t, trk)) { return 'n'; } // if no note in this voice, then no beam int dt; // dots (not used) int tp; // note type bool tr; // triplet (not used) if (!trk->getNoteTypeAndDots(t, v, tp, dt, tr)) { return 'n'; } // if note is 1/4 or longer, then no beam if (tp >= 120) { return 'n'; } int f = trk->bars()[bn].start; // first note of bar int l = trk->lastColumn(bn);// last note of bar int p = 0; // previous note int n = 0; // next nnote p = (t == f) ? -1 : (t - 1); n = (t == l) ? -1 : (t + 1); int ptp = 480; // previous note type, default to 1/1 int ntp = 480; // next note type, default to 1/1 if ((p == -1) || !trk->getNoteTypeAndDots(p, v, ptp, dt, tr)) { // no previous note (or not in this voice), // therefore pretend 1/1 (which has no stem) ptp = 480; } if ((n == -1) || !trk->getNoteTypeAndDots(n, v, ntp, dt, tr)) { // no previous note (or not in this voice), // therefore pretend 1/1 (which has no stem) ntp = 480; } if (mustBreakBeam(t, bn, trk)) { // note ends at n * divisor if ((p != -1) && (ptp <= 60) && !mustBreakBeam(p, bn, trk) && !isRest(p, trk)) { // previous note exists which has beam to this one return 'e'; } else { return 'n'; } } else { // note does not end at n * divisor bool left = false; // beam at left side ? bool right = false; // beam at right side ? if ((p != -1) && (ptp <= 60) && !mustBreakBeam(p, bn, trk) && !isRest(p, trk)) { // previous note exists which has beam to this one left = true; } if ((n != -1) && (ntp <= 60) && !isRest(n, trk)) { // next note exists to draw beam to right = true; } // test all possible combinations of left and right if (left && right) { return 'c'; } if (left && !right) { return 'e'; } if (!left && right) { return 's'; } if (!left && !right) { return 'n'; } } return 'n'; }
/** * In most cases it returns only single element list because subtracting can be resolved with only one rhythm value. */ void Trhythm::sub(const Trhythm& r, TrhythmList& remained) const { if (r.rhythm() == e_none) { remained << *this; qDebug() << "[Trhythm] subtracting null rhythm! IS IT REALLY NECESSARY?"; } else { if (r.isTriplet() != isTriplet()) { // TODO: It has to be solved by changing main note qDebug() << "[Trhythm] Subtracting triplets and no triplets unsupported"; return; } int baseDur = duration(); int subDur = r.duration(); if (subDur > baseDur) { qDebug() << "[Trhythm] Subtracting rhythm" << r.duration() << "is greater than" << duration(); return; } if (baseDur - subDur == 0) { // Return empty (null) rhythm when rhythms are the same remained << Trhythm(e_none); return; } Trhythm newR(baseDur - subDur, isRest()); if (newR.rhythm() != e_none) { // In most cases subtracting returns single rhythm remained << newR; return; } if (r.isTriplet() || isTriplet()) // There is no support for subtracting triplets into multiple notes return; if (baseDur == 4) // 16th triplet - nothing to subtract from return; // For the rest cases list will contain two Trhythm elements if (baseDur == 36 && subDur == 6) // quarter with dot (4.) minus 16th = 4 and 16th remained << Trhythm(e_quarter, isRest()) << Trhythm(e_eighth, isRest(), true); else if (baseDur == 48) { // subtracting form half note remained << Trhythm(e_quarter, isRest()); if (subDur == 6) // 2 - 16th = 4 and 8. remained << Trhythm(e_eighth, isRest(), true); else if (subDur == 18) // 2 - 8. = 4 and 16th remained << Trhythm(e_sixteenth, isRest()); } else if (baseDur == 72) { // subtracting from half with dot remained << Trhythm(e_whole, isRest()); // whole is always first if (baseDur == 6) // 2. - 16th = 2 and 8. remained << Trhythm(e_eighth, isRest(), true); else if (baseDur == 12) // 2. - 8 = 2 and 8 remained << Trhythm(e_eighth, isRest()); else if (baseDur == 18) // 2. - 8. = 2 and 16th remained << Trhythm(e_sixteenth, isRest()); } else if (baseDur == 96) { // subtracting from whole note remained << Trhythm(e_whole, isRest(), true); // whole wit dot is always first if (subDur == 6) // 1 - 16 = 2. and 8. remained << Trhythm(e_eighth, isRest(), true); else if (baseDur == 12) // 1 - 8 = 2. and 8 remained << Trhythm(e_eighth, isRest()); else if (baseDur == 18) // 1 - 8. = 2. and 16th remained << Trhythm(e_sixteenth, isRest()); else if (baseDur == 36) { // 1 - 4. = 2 and 16th remained[0].setDot(false); // revert a dot set above remained << Trhythm(e_sixteenth, isRest()); } } else if (baseDur == 144) { // subtracting from whole and dot if (subDur <= 48) { Trhythm half(e_half, isRest()); half.sub(r, remained); remained.prepend(Trhythm(e_whole, isRest())); } } } }
void KMLVector::findLayers(KMLNode* poNode, int bKeepEmptyContainers) { bool bEmpty = true; // Start with the trunk if( nullptr == poNode ) { nNumLayers_ = 0; poNode = poTrunk_; } if( isFeature(poNode->getName()) || isFeatureContainer(poNode->getName()) || ( isRest(poNode->getName()) && poNode->getName().compare("kml") != 0 ) ) { return; } else if( isContainer(poNode->getName()) ) { for( int z = 0; z < (int) poNode->countChildren(); z++ ) { if( isContainer(poNode->getChild(z)->getName()) ) { findLayers(poNode->getChild(z), bKeepEmptyContainers); } else if( isFeatureContainer(poNode->getChild(z)->getName()) ) { bEmpty = false; } } if( bKeepEmptyContainers && poNode->getName() == "Folder" ) { if (!bEmpty) poNode->eliminateEmpty(this); } else if(bEmpty) { return; } Nodetype nodeType = poNode->getType(); if( bKeepEmptyContainers || isFeature(Nodetype2String(nodeType)) || nodeType == Mixed || nodeType == MultiGeometry || nodeType == MultiPoint || nodeType == MultiLineString || nodeType == MultiPolygon) { poNode->setLayerNumber(nNumLayers_++); papoLayers_ = static_cast<KMLNode**>( CPLRealloc(papoLayers_, nNumLayers_ * sizeof(KMLNode*)) ); papoLayers_[nNumLayers_ - 1] = poNode; } else { CPLDebug( "KML", "We have a strange type here for node %s: %s", poNode->getName().c_str(), Nodetype2String(poNode->getType()).c_str() ); } } else { CPLDebug( "KML", "There is something wrong! Define KML_DEBUG to see details"); if( CPLGetConfigOption("KML_DEBUG", nullptr) != nullptr ) print(); } }