本文整理汇总了C++中ChordRest类的典型用法代码示例。如果您正苦于以下问题:C++ ChordRest类的具体用法?C++ ChordRest怎么用?C++ ChordRest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChordRest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selection
FiguredBass* Score::addFiguredBass()
{
Element* el = selection().element();
if (el == 0 || (el->type() != NOTE && el->type() != FIGURED_BASS)) {
QMessageBox::information(0,
QMessageBox::tr("MuseScore:"),
QMessageBox::tr("No note or figured bass selected:\n"
"Please select a single note or figured bass and retry operation\n"),
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
}
ChordRest* cr;
if (el->type() == NOTE)
cr = static_cast<Note*>(el)->chord();
else if (el->type() == FIGURED_BASS)
cr = static_cast<FiguredBass*>(el)->chordRest();
else
return 0;
QList<Lyrics*> ll = cr->lyricsList();
int no = ll.size();
FiguredBass* fb = new FiguredBass(this);
fb->setTrack(cr->track());
fb->setParent(cr);
fb->setNo(no);
undoAddElement(fb);
select(fb, SELECT_SINGLE, 0);
return fb;
}
示例2: if
ChordRest* Selection::firstChordRest(int track) const
{
if (_el.size() == 1) {
Element* el = _el[0];
if (el->type() == Element::NOTE)
return static_cast<ChordRest*>(el->parent());
else if (el->type() == Element::REST)
return static_cast<ChordRest*>(el);
return 0;
}
ChordRest* cr = 0;
foreach (Element* el, _el) {
if (el->type() == Element::NOTE)
el = el->parent();
if (el->isChordRest()) {
if (track != -1 && el->track() != track)
continue;
if (cr) {
if (static_cast<ChordRest*>(el)->tick() < cr->tick())
cr = static_cast<ChordRest*>(el);
}
else
cr = static_cast<ChordRest*>(el);
}
}
return cr;
}
示例3: areTiesConsistent
bool areTiesConsistent(const Staff *staff)
{
const int strack = staff->idx() * VOICES;
for (int voice = 0; voice < VOICES; ++voice) {
bool isTie = false;
for (Segment *seg = staff->score()->firstSegment(); seg; seg = seg->next1()) {
if (seg->segmentType() == Segment::Type::ChordRest) {
ChordRest *cr = static_cast<ChordRest *>(seg->element(strack + voice));
if (cr && cr->type() == Element::Type::REST && isTie) {
printInconsistentTieLocation(seg->measure()->no(), staff->idx());
return false;
}
if (isTiedBack(seg, strack, voice)) {
if (!isTie) {
printInconsistentTieLocation(seg->measure()->no(), staff->idx());
return false;
}
isTie = false;
}
if (isTiedFor(seg, strack, voice)) {
if (isTie) {
printInconsistentTieLocation(seg->measure()->no(), staff->idx());
return false;
}
isTie = true;
}
}
}
if (isTie)
return false;
}
return true;
}
示例4: setLineWidth
void LyricsLine::layout()
{
if (lyrics()->ticks() > 0) { // melisma
setLineWidth(Spatium(MELISMA_DEFAULT_LINE_THICKNESS));
// Lyrics::_ticks points to the beginning of the last spanned segment,
// but the line shall include it:
// include the duration of this last segment in the melisma duration
bool ticksSet = false;
Segment* lastSeg = score()->tick2segment(lyrics()->endTick(), false, Segment::Type::ChordRest, false);
if (lastSeg) {
// if last segment found, locate the first non-empty ChordRest
// in the same staff of this LyricsLine and use its duration
int firstTrack = (track() >> 2) << 2;
int lastTrack = firstTrack + VOICES;
for (int i = firstTrack; i < lastTrack; i++) {
ChordRest* cr = static_cast<ChordRest*>(lastSeg->elementAt(i));
if (cr) {
setTicks(lyrics()->ticks() + cr->durationTicks());
ticksSet = true;
break;
}
}
}
// no suitable ChordRest found? go to the end of the last known segment
if (!ticksSet)
setTicks(lyrics()->ticks());
}
示例5: readFile
void TestTools::undoChangeVoice()
{
QString readFile(DIR + "undoChangeVoice.mscx");
QString writeFile1("undoChangeVoice01-test.mscx");
QString reference1(DIR + "undoChangeVoice01-ref.mscx");
QString writeFile2("undoChangeVoice02-test.mscx");
QString reference2(DIR + "undoChangeVoice02-ref.mscx");
Score* score = readScore(readFile);
score->doLayout();
// do
score->deselectAll();
// select bottom note of all voice 1 chords
for (Segment* s = score->firstSegment(Segment::Type::ChordRest); s; s = s->next1()) {
ChordRest* cr = static_cast<ChordRest*>(s->element(0));
if (cr && cr->type() == Element::Type::CHORD) {
Ms::Chord* c = static_cast<Ms::Chord*>(cr);
score->select(c->downNote(), SelectType::ADD);
}
}
// change voice
score->changeVoice(1);
QVERIFY(saveCompareScore(score, writeFile1, reference1));
// undo
score->undo()->undo();
QVERIFY(saveCompareScore(score, writeFile2, reference2));
delete score;
}
示例6: tupletDialog
void MuseScore::tupletDialog()
{
if (!cs)
return;
ChordRest* cr = cs->getSelectedChordRest();
if (cr == 0)
return;
TupletDialog td;
if (!td.exec())
return;
Tuplet* tuplet = new Tuplet(cs);
tuplet->setTrack(cr->track());
tuplet->setTick(cr->tick());
td.setupTuplet(tuplet);
// tuplet->setRatio(tuplet->ratio().reduced());
Fraction f1(cr->duration());
tuplet->setDuration(f1);
Fraction f = f1 * tuplet->ratio();
f.reduce();
printf("len %s ratio %s base %s\n",
qPrintable(f1.print()),
qPrintable(tuplet->ratio().print()),
qPrintable(f.print()));
tuplet->setBaseLen(Fraction(1, f.denominator()));
Measure* measure = cr->measure();
tuplet->setParent(measure);
cs->cmdCreateTuplet(cr, tuplet);
}
示例7: toLyrics
void ScoreView::lyricsEndEdit()
{
Lyrics* lyrics = toLyrics(editData.element);
// if not empty, make sure this new lyrics does not fall in the middle
// of an existing melisma from a previous lyrics; in case, shorten it
int verse = lyrics->no();
Placement placement = lyrics->placement();
int track = lyrics->track();
// search previous lyric
Lyrics* prevLyrics = 0;
Segment* prevSegment = lyrics->segment()->prev1(SegmentType::ChordRest);
Segment* segment = prevSegment;
while (segment) {
ChordRest* cr = toChordRest(segment->element(track));
if (cr) {
prevLyrics = cr->lyrics(verse, placement);
if (prevLyrics)
break;
}
segment = segment->prev1(SegmentType::ChordRest);
}
if (prevLyrics && prevLyrics->syllabic() == Lyrics::Syllabic::END) {
int endTick = prevSegment->tick(); // a prev. melisma should not go beyond this segment
if (prevLyrics->endTick() >= endTick)
prevLyrics->undoChangeProperty(Pid::LYRIC_TICKS, endTick - prevLyrics->segment()->tick());
}
}
示例8: tick2measure
Segment* Score::tick2segmentEnd(int track, int tick) const
{
Measure* m = tick2measure(tick);
if (m == 0) {
qDebug("tick2segment(): not found tick %d\n", tick);
return 0;
}
// loop over all segments
for (Segment* segment = m->first(Segment::SegChordRest); segment; segment = segment->next(Segment::SegChordRest)) {
ChordRest* cr = static_cast<ChordRest*>(segment->element(track));
if (!cr)
continue;
// TODO LVI: check if following is correct, see exceptions in
// ExportMusicXml::chord() and ExportMusicXml::rest()
int endTick = cr->tick() + cr->actualTicks();
if (endTick < tick)
continue; // not found yet
else if (endTick == tick) {
return segment; // found it
}
else {
// endTick > tick (beyond the tick we are looking for)
return 0;
}
}
return 0;
}
示例9: score
QPointF Pedal::linePos(GripLine grip, System** sys) const
{
qreal x;
qreal nhw = score()->noteHeadWidth();
System* s;
if (grip == GripLine::START) {
ChordRest* c = static_cast<ChordRest*>(startElement());
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
if (beginHook() && beginHookType() == HookType::HOOK_45)
x += nhw * .5;
}
else {
ChordRest* c = static_cast<ChordRest*>(endElement());
if (c) {
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
}
else {
int t = tick2();
Measure* m = score()->tick2measure(t);
s = m->system();
x = m->tick2pos(t);
}
if (endHook() && endHookType() == HookType::HOOK_45)
x += nhw * .5;
else
x += nhw;
}
*sys = s;
return QPointF(x, 0);
}
示例10: while
void Glissando::layout()
{
Chord* chord = static_cast<Chord*>(parent());
if (chord == 0) {
return;
}
Note* anchor2 = chord->upNote();
Segment* s = chord->segment();
s = s->prev1();
while (s) {
if ((s->subtype() & (Segment::SegChordRestGrace)) && s->element(track()))
break;
s = s->prev1();
}
if (s == 0) {
qDebug("no segment for first note of glissando found\n");
return;
}
ChordRest* cr = static_cast<ChordRest*>(s->element(track()));
if (cr == 0 || cr->type() != CHORD) {
qDebug("no first note for glissando found, track %d\n", track());
return;
}
Note* anchor1 = static_cast<Chord*>(cr)->upNote();
setPos(0.0, 0.0);
QPointF cp1 = anchor1->pagePos();
QPointF cp2 = anchor2->pagePos();
// construct line from notehead to notehead
qreal x1 = (anchor1->headWidth()) - (cp2.x() - cp1.x());
qreal y1 = anchor1->pos().y();
qreal x2 = anchor2->pos().x();
qreal y2 = anchor2->pos().y();
// on TAB's, adjust lower end point from string line height to base of note height (= ca. half line spacing)
if (chord->staff()->isTabStaff()) {
qreal yOff = chord->staff()->lineDistance() * 0.5 * spatium();
if (anchor1->pitch() > anchor2->pitch()) // descending glissando:
y2 += yOff; // move ending point to base of note
else // ascending glissando:
y1 += yOff; // move starting point to base of note
}
QLineF fullLine(x1, y1, x2, y2);
// shorten line on each side by offsets
qreal xo = spatium() * .5;
qreal yo = xo; // spatium() * .5;
QPointF p1 = fullLine.pointAt(xo / fullLine.length());
QPointF p2 = fullLine.pointAt(1 - (yo / fullLine.length()));
line = QLineF(p1, p2);
qreal lw = spatium() * .15 * .5;
QRectF r = QRectF(line.p1(), line.p2()).normalized();
setbbox(r.adjusted(-lw, -lw, lw, lw));
}
示例11: addTempo
void MuseScore::addTempo()
{
ChordRest* cr = cs->getSelectedChordRest();
if (!cr)
return;
// double bps = 2.0;
SigEvent event = cs->sigmap()->timesig(cr->tick());
Fraction f = event.nominal();
QString text(QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)));
switch (f.denominator()) {
case 1:
text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5d));
break;
case 2:
text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e));
break;
case 4:
text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f));
break;
case 8:
if(f.numerator() % 3 == 0)
text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
else
text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60));
break;
case 16:
if(f.numerator() % 3 == 0)
text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
else
text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd61));
break;
case 32:
if(f.numerator() % 3 == 0)
text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd61)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
else
text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd62));
break;
case 64:
if(f.numerator() % 3 == 0)
text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd62)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
else
text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd63));
break;
default:
break;
}
TempoText* tt = new TempoText(cs);
tt->setParent(cr->segment());
tt->setTrack(cr->track());
tt->setText(text);
tt->setFollowText(true);
//tt->setTempo(bps);
cs->undoAddElement(tt);
cv->startEdit(tt);
}
示例12: addTempo
void MuseScore::addTempo()
{
ChordRest* cr = cs->getSelectedChordRest();
if (!cr)
return;
// double bps = 2.0;
SigEvent event = cs->sigmap()->timesig(cr->tick());
Fraction f = event.nominal();
QString text("<sym>noteQuarterUp</sym> = 80");
switch (f.denominator()) {
case 1:
text = "<sym>noteWhole</sym> = 80";
break;
case 2:
text = "<sym>noteHalfUp</sym> = 80";
break;
case 4:
text = "<sym>noteQuarterUp</sym> = 80";
break;
case 8:
if(f.numerator() % 3 == 0)
text = "<sym>noteQuarterUp</sym><sym>textAugmentationDot</sym> = 80";
else
text = "<sym>note8thUp</sym> = 80";
break;
case 16:
if(f.numerator() % 3 == 0)
text = text = "<sym>note8thUp</sym><sym>textAugmentationDot</sym> = 80";
else
text = "<sym>note16thUp</sym> = 80";
break;
case 32:
if(f.numerator() % 3 == 0)
text = "<sym>note16thUp</sym><sym>textAugmentationDot</sym> = 80";
else
text = "<sym>note32thUp</sym> = 80";
break;
case 64:
if(f.numerator() % 3 == 0)
text = "<sym>note32thUp</sym><sym>textAugmentationDot</sym> = 80";
else
text = "<sym>note64thUp</sym> = 80";
break;
default:
break;
}
TempoText* tt = new TempoText(cs);
tt->setParent(cr->segment());
tt->setTrack(cr->track());
tt->setText(text);
tt->setFollowText(true);
//tt->setTempo(bps);
cs->undoAddElement(tt);
cv->startEdit(tt);
}
示例13: score
QPointF Pedal::linePos(GripLine grip, System** sys) const
{
qreal x;
qreal nhw = score()->noteHeadWidth();
System* s = nullptr;
if (grip == GripLine::START) {
ChordRest* c = static_cast<ChordRest*>(startElement());
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
if (beginHook() && beginHookType() == HookType::HOOK_45)
x += nhw * .5;
}
else {
ChordRest* c = nullptr;
Element* e = endElement();
if (!e || e == startElement()) {
// pedal marking on single note - extend to next note or end of measure
Segment* seg = startSegment();
if (seg) {
seg = seg->next();
for ( ; seg; seg = seg->next()) {
if (seg->segmentType() == Segment::Type::ChordRest) {
if (seg->element(track()))
break;
}
else if (seg->segmentType() == Segment::Type::EndBarLine) {
break;
}
}
}
if (seg) {
s = seg->system();
x = seg->pos().x() + seg->measure()->pos().x() - nhw * 2;
}
}
else {
c = static_cast<ChordRest*>(endElement());
if (c) {
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
}
}
if (!s) {
int t = tick2();
Measure* m = score()->tick2measure(t);
s = m->system();
x = m->tick2pos(t);
}
if (endHook() && endHookType() == HookType::HOOK_45)
x += nhw * .5;
else
x += nhw;
}
*sys = s;
return QPointF(x, 0);
}
示例14: QDialog
ArticulationProperties::ArticulationProperties(Articulation* na, QWidget* parent)
: QDialog(parent)
{
setupUi(this);
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
articulation = na;
ChordRest* cr = articulation->chordRest();
if (cr) {
Segment* segment = cr->segment();
Part* part = articulation->staff()->part();
Instrument* instrument = part->instr(segment->tick());
// const QList<NamedEventList>& midiActions() const;
// const QList<MidiArticulation>& articulation() const;
// const QList<Channel>& channel() const;
foreach(const Channel& a, instrument->channel()) {
if (a.name.isEmpty() || a.name == "normal")
channelList->addItem(tr("normal"));
else
channelList->addItem(a.name);
}
foreach(const NamedEventList& el, instrument->midiActions()) {
midiActionList->addItem(el.name);
}
}
#if 0
foreach(const NamedEventList& e, instrument->midiActions)
midiActionList->addItem(e.name);
articulationChange->setChecked(!articulation->articulationName().isEmpty());
midiAction->setChecked(!articulation->midiActionName().isEmpty());
if (!articulation->articulationName().isEmpty()) {
QList<QListWidgetItem*> wl = articulationList
->findItems(st->articulationName(), Qt::MatchExactly);
if (!wl.isEmpty())
articulationList->setCurrentRow(articulationList->row(wl[0]));
}
if (!articulation->midiActionName().isEmpty()) {
QList<QListWidgetItem*> wl = midiActionList
->findItems(st->midiActionName(), Qt::MatchExactly);
if (!wl.isEmpty())
midiActionList->setCurrentRow(midiActionList->row(wl[0]));
}
#endif
direction->setCurrentIndex(int(articulation->direction()));
anchor->setCurrentIndex(int(articulation->anchor()));
connect(this, SIGNAL(accepted()), SLOT(saveValues()));
}
示例15: test_pre
void TestChordSymbol::testAddPart()
{
MasterScore* score = test_pre("add-part");
Segment* seg = score->firstSegment(Segment::Type::ChordRest);
ChordRest* cr = seg->cr(0);
Harmony* harmony = new Harmony(score);
harmony->setHarmony("C7");
harmony->setTrack(cr->track());
harmony->setParent(cr->segment());
score->undoAddElement(harmony);
score->doLayout();
test_post(score, "add-part");
}