Tuplet::Tuplet(Score* s) : DurationElement(s) { setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE); _direction = score()->style(StyleIdx::tupletDirection).value<Direction>(); _numberType = NumberType(score()->style(StyleIdx::tupletNumberType).toInt()); _bracketType = BracketType(score()->style(StyleIdx::tupletBracketType).toInt()); _ratio = Fraction(1, 1); _number = 0; _hasBracket = false; _isUp = true; }
void InstrumentTemplate::read(const QDomElement& de) { bool customDrumset = false; staves = 1; for (int i = 0; i < MAX_STAVES; ++i) { clefIdx[i] = CLEF_INVALID; staffLines[i] = -1; smallStaff[i] = false; bracket[i] = NO_BRACKET; bracketSpan[i] = 0; barlineSpan[i] = 0; } minPitchA = 0; maxPitchA = 127; minPitchP = 0; maxPitchP = 127; transpose.diatonic = 0; transpose.chromatic = 0; useDrumset = false; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "name" || tag == "longName") { // "name" is obsolete int pos = e.attribute("pos", "0").toInt(); QString longName = Xml::htmlToString(e); longNames.append(StaffName(longName, pos)); } else if (tag == "short-name" || tag == "shortName") { // "short-name" is obsolete int pos = e.attribute("pos", "0").toInt(); QString shortName = Xml::htmlToString(e); shortNames.append(StaffName(shortName, pos)); } else if (tag == "description") trackName = val; else if (tag == "extended") extended = true; else if (tag == "staves") { staves = val.toInt(); bracketSpan[0] = staves; barlineSpan[0] = staves; } else if (tag == "clef") { int idx = readStaffIdx(e); bool ok; int i = val.toInt(&ok); if (!ok) { ClefType ct = Clef::clefType(val); clefIdx[idx] = ct; } else clefIdx[idx] = ClefType(i); } else if (tag == "stafflines") { int idx = readStaffIdx(e); staffLines[idx] = val.toInt(); } else if (tag == "smallStaff") { int idx = readStaffIdx(e); smallStaff[idx] = val.toInt(); } else if (tag == "bracket") { int idx = readStaffIdx(e); bracket[idx] = BracketType(val.toInt()); } else if (tag == "bracketSpan") { int idx = readStaffIdx(e); bracketSpan[idx] = val.toInt(); } else if (tag == "barlineSpan") { int idx = readStaffIdx(e); barlineSpan[idx] = val.toInt(); } else if (tag == "Tablature") { tablature = new Tablature; tablature->read(e); } else if (tag == "aPitchRange") setPitchRange(val, &minPitchA, &maxPitchA); else if (tag == "pPitchRange") setPitchRange(val, &minPitchP, &maxPitchP); else if (tag == "transposition") { // obsolete transpose.chromatic = val.toInt(); transpose.diatonic = chromatic2diatonic(val.toInt()); } else if (tag == "transposeChromatic") transpose.chromatic = val.toInt(); else if (tag == "transposeDiatonic") transpose.diatonic = val.toInt(); else if (tag == "drumset") useDrumset = val.toInt(); else if (tag == "Drum") { // if we see on of this tags, a custom drumset will // be created if (drumset == 0) drumset = new Drumset(*smDrumset); if (!customDrumset) { drumset->clear(); customDrumset = true; } drumset->load(e); } else if (tag == "MidiAction") { NamedEventList a; a.read(e); midiActions.append(a); } else if (tag == "channel") { Channel a; a.read(e); channel.append(a); } else if (tag == "Articulation") { MidiArticulation a; a.read(e); int n = articulation.size(); int i; for(i = 0; i < n; ++i) { if (articulation[i].name == a.name) { articulation[i] = a; break; } } if (i == n) articulation.append(a); } else if (tag == "stafftype") { if (val == "tablature") useTablature = true; else { qDebug("unknown stafftype <%s>\n", qPrintable(val)); domError(e); } } else if (tag == "init") { InstrumentTemplate* ttt = searchTemplate(val); if (ttt) { // qDebug("Instrument template init <%s> from <%s>\n", qPrintable(trackName), qPrintable(ttt->trackName)); init(*ttt); } else qDebug("Instrument template <%s> not found\n", qPrintable(val)); } else domError(e); } // // check bar line spans // int barLine = 0; for (int i = 0; i < staves; ++i) { int bls = barlineSpan[i]; if (barLine) { if (bls) barlineSpan[i] = 0; } else { if (bls == 0) { bls = 1; barlineSpan[i] = 1; } barLine = bls; } --barLine; } for (int i = 0; i < MAX_STAVES; ++i) { if (clefIdx[i] == CLEF_INVALID) clefIdx[i] = CLEF_G; if (staffLines[i] == -1) staffLines[i] = 5; } if (channel.isEmpty()) { Channel a; a.chorus = 0; a.reverb = 0; a.name = "normal"; a.program = 0; a.bank = 0; a.volume = 100; a.pan = 60; channel.append(a); } if (useDrumset) { if (channel[0].bank == 0) channel[0].bank = 128; channel[0].updateInitList(); } if (trackName.isEmpty() && !longNames.isEmpty()) trackName = parseInstrName(longNames[0].name); }