本文整理汇总了C++中Lyrics类的典型用法代码示例。如果您正苦于以下问题:C++ Lyrics类的具体用法?C++ Lyrics怎么用?C++ Lyrics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lyrics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void ChordRest::add(Element* e)
{
e->setParent(this);
e->setTrack(track());
switch(e->type()) {
case Element::Type::ARTICULATION:
{
Articulation* a = static_cast<Articulation*>(e);
_articulations.push_back(a);
if (a->timeStretch() != 1.0)
score()->fixTicks(); // update tempo map
}
break;
case Element::Type::LYRICS:
{
Lyrics* l = static_cast<Lyrics*>(e);
int size = _lyricsList.size();
if (l->no() >= size) {
for (int i = size-1; i < l->no(); ++i)
_lyricsList.append(0);
}
_lyricsList[l->no()] = l;
}
break;
default:
qFatal("ChordRest::add: unknown element %s", e->name());
break;
}
}
示例2: DurationElement
ChordRest::ChordRest(const ChordRest& cr, bool link)
: DurationElement(cr)
{
_durationType = cr._durationType;
_staffMove = cr._staffMove;
_beam = 0;
_tabDur = 0; // tab sur. symb. depends upon context: can't be
// simply copied from another CR
for (Articulation* a : cr._articulations) { // make deep copy
Articulation* na = new Articulation(*a);
if (link)
na->linkTo(a);
na->setParent(this);
na->setTrack(track());
_articulations.append(na);
}
_beamMode = cr._beamMode;
_up = cr._up;
_small = cr._small;
_crossMeasure = cr._crossMeasure;
_space = cr._space;
for (Lyrics* l : cr._lyricsList) { // make deep copy
if (l == 0)
continue;
Lyrics* nl = new Lyrics(*l);
if (link)
nl->linkTo(l);
nl->setParent(this);
nl->setTrack(track());
_lyricsList.append(nl);
}
}
示例3: endEdit
void ScoreView::lyricsReturn()
{
Lyrics* lyrics = (Lyrics*)editObject;
Segment* segment = lyrics->segment();
endEdit();
_score->startCmd();
Lyrics* oldLyrics = lyrics;
lyrics = static_cast<Lyrics*>(Element::create(lyrics->type(), _score));
lyrics->setTrack(oldLyrics->track());
lyrics->setParent(segment->element(oldLyrics->track()));
lyrics->setNo(oldLyrics->no() + 1);
_score->undoAddElement(lyrics);
_score->select(lyrics, SELECT_SINGLE, 0);
startEdit(lyrics, -1);
mscore->changeState(mscoreState());
adjustCanvasPosition(lyrics, false);
_score->setLayoutAll(true);
_score->end2();
_score->end1();
}
示例4: 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());
}
}
示例5: toLyrics
void ScoreView::lyricsUpDown(bool up, bool end)
{
Lyrics* lyrics = toLyrics(editData.element);
int track = lyrics->track();
ChordRest* cr = lyrics->chordRest();
int verse = lyrics->no();
Placement placement = lyrics->placement();
if (placement == Placement::ABOVE)
up = !up;
if (up) {
if (verse == 0)
return;
--verse;
}
else {
++verse;
if (verse > cr->lastVerse(placement))
return;
}
changeState(ViewState::NORMAL);
lyrics = cr->lyrics(verse, placement);
if (!lyrics) {
lyrics = new Lyrics(_score);
lyrics->setTrack(track);
lyrics->setParent(cr);
lyrics->setNo(verse);
lyrics->setPlacement(placement);
_score->startCmd();
_score->undoAddElement(lyrics);
_score->endCmd();
}
_score->select(lyrics, SelectType::SINGLE, 0);
startEdit(lyrics, Grip::NO_GRIP);
mscore->changeState(mscoreState());
adjustCanvasPosition(lyrics, false);
lyrics = toLyrics(editData.element);
TextCursor* cursor = lyrics->cursor(editData);
if (end) {
cursor->movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
cursor->movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
}
else {
cursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
cursor->movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
}
_score->setLayoutAll();
_score->update();
}
示例6: getValue
void InspectorLyric::valueChanged(int idx)
{
if (iList[idx].t == P_ID::VERSE) {
int val = getValue(iList[idx]).toInt();
Lyrics* l = toLyrics(inspector->element());
printf("value changed %d old %d\n", val, l->no());
Lyrics* nl = l->chordRest()->lyrics(val, l->placement());
if (nl) {
printf(" move away %d -> %d\n", nl->no(), l->no());
nl->undoChangeProperty(P_ID::VERSE, l->no());
}
}
InspectorBase::valueChanged(idx);
}
示例7: getValue
void InspectorLyric::valueChanged(int idx)
{
if (iList[idx].t == Pid::VERSE) {
int val = getValue(iList[idx]).toInt();
Lyrics* l = toLyrics(inspector->element());
Lyrics* nl = l->chordRest()->lyrics(val, l->placement());
if (nl) {
nl->undoChangeProperty(Pid::VERSE, l->no());
}
}
InspectorBase::valueChanged(idx);
}
示例8: Lyrics
void TuLyrics::construct()
{
Lyrics *pLyrics;
/* Step 1: Default constructor. */
try
{
pLyrics = new Lyrics();
QVERIFY(pLyrics != NULL);
QVERIFY(pLyrics->sections().isEmpty());
QCOMPARE(pLyrics->title(), QString());
delete pLyrics;
}
catch (LyricsSection::TextParseException &)
{
QFAIL("Unexpected TextParseException thrown");
}
Lyrics::LyricsSectionList sectionList;
sectionList.append(LyricsSection("test[b]1[/b]", "1", LyricsSection::NoLineWrap));
QVERIFY(sectionList.size() == 1);
/* Step 2: Parametrised constructor. */
try
{
pLyrics = new Lyrics(123, sectionList, "test2");
QCOMPARE(pLyrics->id(), 123u);
QCOMPARE(pLyrics->sections()[0].text(), QString("test[b]1[/b]"));
QCOMPARE(pLyrics->title(), QString("test2"));
delete pLyrics;
}
catch (LyricsSection::TextParseException &)
{
QFAIL("Unexpected TextParseException thrown");
}
}
示例9: readUChar
int GuitarPro5::readBeat(int tick, int voice, Measure* measure, int staffIdx, Tuplet** tuplets, bool /*mixChange*/)
{
uchar beatBits = readUChar();
bool dotted = beatBits & BEAT_DOTTED;
slide = -1;
int track = staffIdx * VOICES + voice;
if (slides.contains(track))
slide = slides.take(track);
int pause = -1;
if (beatBits & BEAT_PAUSE)
pause = readUChar();
// readDuration
int len = readChar();
int tuple = 0;
if (beatBits & BEAT_TUPLET)
tuple = readInt();
Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick);
if (beatBits & BEAT_CHORD) {
int numStrings = score->staff(staffIdx)->part()->instr()->stringData()->strings();
skip(17);
QString name = readPascalString(21);
skip(4);
// no header to be read in the GP5 format - default to true.
readChord(segment, staffIdx * VOICES, numStrings, name, true);
skip(32);
}
Lyrics* lyrics = 0;
if (beatBits & BEAT_LYRICS) {
QString txt = readDelphiString();
lyrics = new Lyrics(score);
lyrics->setText(txt);
}
gpLyrics.beatCounter++;
if (gpLyrics.beatCounter >= gpLyrics.fromBeat && gpLyrics.lyricTrack == staffIdx+1) {
int index = gpLyrics.beatCounter - gpLyrics.fromBeat;
if (index < gpLyrics.lyrics.size()) {
lyrics = new Lyrics(score);
lyrics->setText(gpLyrics.lyrics[index]);
}
}
int beatEffects = 0;
if (beatBits & BEAT_EFFECTS)
beatEffects = readBeatEffects(track, segment);
if (beatBits & BEAT_MIX_CHANGE)
readMixChange(measure);
int strings = readUChar(); // used strings mask
Fraction l = len2fraction(len);
// Some beat effects could add a Chord before this
ChordRest* cr = segment->cr(track);
if (voice != 0 && pause == 0 && strings == 0)
cr = 0;
else {
if (strings == 0) {
if (cr) {
segment->remove(cr);
delete cr;
cr = 0;
}
cr = new Rest(score);
}
else {
if (!cr)
cr = new Chord(score);
}
cr->setTrack(track);
TDuration d(l);
d.setDots(dotted ? 1 : 0);
if (dotted)
l = l + (l/2);
if (tuple) {
Tuplet* tuplet = tuplets[staffIdx * 2 + voice];
if ((tuplet == 0) || (tuplet->elementsDuration() == tuplet->baseLen().fraction() * tuplet->ratio().numerator())) {
tuplet = new Tuplet(score);
// int track = staffIdx * 2 + voice;
tuplets[staffIdx * 2 + voice] = tuplet;
tuplet->setTrack(cr->track());
setTuplet(tuplet, tuple);
tuplet->setParent(measure);
}
tuplet->setTrack(cr->track());
tuplet->setBaseLen(l);
tuplet->setDuration(l * tuplet->ratio().denominator());
cr->setTuplet(tuplet);
tuplet->add(cr);
}
cr->setDuration(l);
if (cr->type() == Element::Type::REST && (pause == 0 || l == measure->len()))
cr->setDurationType(TDuration::DurationType::V_MEASURE);
//.........这里部分代码省略.........
示例10: lyricsLine
void LyricsLineSegment::layout()
{
bool endOfSystem = false;
bool isEndMelisma = lyricsLine()->lyrics()->ticks() > 0;
Lyrics* lyr = 0;
Lyrics* nextLyr = 0;
qreal fromX = 0;
qreal toX = 0; // start and end point of intra-lyrics room
qreal sp = spatium();
System* sys;
if (lyricsLine()->ticks() <= 0) { // if no span,
_numOfDashes = 0; // nothing to draw
return; // and do nothing
}
// HORIZONTAL POSITION
// A) if line precedes a syllable, advance line end to right before the next syllable text
// if not a melisma and there is a next syllable;
if (!isEndMelisma && lyricsLine()->nextLyrics() && isSingleEndType()) {
lyr = nextLyr = lyricsLine()->nextLyrics();
sys = lyr->segment()->system();
endOfSystem = (sys != system());
// if next lyrics is on a different system, this line segment is at the end of its system:
// do not adjust for next lyrics position
if (!endOfSystem) {
qreal lyrX = lyr->bbox().x();
qreal lyrXp = lyr->pagePos().x();
qreal sysXp = sys->pagePos().x();
toX = lyrXp - sysXp + lyrX; // syst.rel. X pos.
qreal offsetX = toX - pos().x() - pos2().x() - score()->styleP(Sid::lyricsDashPad);
// delta from current end pos.| ending padding
rxpos2() += offsetX;
}
}
// B) if line follows a syllable, advance line start to after the syllable text
lyr = lyricsLine()->lyrics();
sys = lyr->segment()->system();
if (sys && isSingleBeginType()) {
qreal lyrX = lyr->bbox().x();
qreal lyrXp = lyr->pagePos().x();
qreal lyrW = lyr->bbox().width();
qreal sysXp = sys->pagePos().x();
fromX = lyrXp - sysXp + lyrX + lyrW;
// syst.rel. X pos. | lyr.advance
qreal offsetX = fromX - pos().x();
offsetX += score()->styleP(isEndMelisma ? Sid::lyricsMelismaPad : Sid::lyricsDashPad);
// delta from curr.pos. | add initial padding
rxpos() += offsetX;
rxpos2() -= offsetX;
}
// VERTICAL POSITION: at the base line of the syllable text
if (!isEndType())
rypos() = lyr->ipos().y();
else {
// use Y position of *next* syllable if there is one on same system
Lyrics* nextLyr = searchNextLyrics(lyr->segment(), lyr->staffIdx(), lyr->no(), lyr->placement());
if (nextLyr && nextLyr->segment()->system() == system())
rypos() = nextLyr->y();
else
rypos() = lyr->y();
}
// MELISMA vs. DASHES
if (isEndMelisma) { // melisma
_numOfDashes = 1;
rypos() -= lyricsLine()->lineWidth() * .5; // let the line 'sit on' the base line
qreal offsetX = score()->styleP(Sid::minNoteDistance) * mag();
// if final segment, extend slightly after the chord, otherwise shorten it
rxpos2() += (isBeginType() || isEndType()) ? -offsetX : +offsetX;
}
else { // dash(es)
// set conventional dash Y pos
rypos() -= MScore::pixelRatio * lyr->fontMetrics().xHeight() * score()->styleD(Sid::lyricsDashYposRatio);
_dashLength = score()->styleP(Sid::lyricsDashMaxLength) * mag(); // and dash length
qreal len = pos2().x();
qreal minDashLen = score()->styleS(Sid::lyricsDashMinLength).val() * sp;
qreal maxDashDist = score()->styleS(Sid::lyricsDashMaxDistance).val() * sp;
if (len < minDashLen) { // if no room for a dash
// if at end of system or dash is forced
if (endOfSystem || score()->styleB(Sid::lyricsDashForce)) {
rxpos2() = minDashLen; // draw minimal dash
_numOfDashes = 1;
_dashLength = minDashLen;
}
else // if within system or dash not forced
_numOfDashes = 0; // draw no dash
}
else if (len < (maxDashDist * 2.0)) { // if no room for two dashes
_numOfDashes = 1; // draw one dash
if (_dashLength > len) // if no room for a full dash
_dashLength = len; // shorten it
}
else
_numOfDashes = len / (maxDashDist); // draw several dashes
// adjust next lyrics horiz. position if too little a space forced to skip the dash
if (_numOfDashes == 0 && nextLyr != nullptr && len > 0)
//.........这里部分代码省略.........
示例11: while
void ScoreView::lyricsEndEdit()
{
Lyrics* lyrics = (Lyrics*)editObject;
int endTick = lyrics->segment()->tick();
// search previous lyric:
int verse = lyrics->no();
int staffIdx = lyrics->staffIdx();
// search previous lyric
Lyrics* oldLyrics = 0;
Segment* segment = lyrics->segment();
while (segment) {
const QList<Lyrics*>* nll = segment->lyricsList(staffIdx);
if (nll) {
oldLyrics = nll->value(verse);
if (oldLyrics)
break;
}
segment = segment->prev1(Segment::SegChordRest | Segment::SegGrace);
}
// if (lyrics->isEmpty() && origL->isEmpty())
if (lyrics->isEmpty())
lyrics->parent()->remove(lyrics);
else {
if (oldLyrics && oldLyrics->syllabic() == Lyrics::END) {
if (oldLyrics->endTick() >= endTick)
oldLyrics->setTicks(0);
}
}
}
示例12: run
FXint run() {
Lyrics lyrics;
lyrics.fetch(track);
return 0;
}
示例13: endEdit
void ScoreView::lyricsUnderscore()
{
Lyrics* lyrics = static_cast<Lyrics*>(editObject);
int track = lyrics->track();
Segment* segment = lyrics->segment();
int verse = lyrics->no();
int endTick = segment->tick();
endEdit();
// search next chord
Segment* nextSegment = segment;
while ((nextSegment = nextSegment->next1(Segment::Type::ChordRest))) {
Element* el = nextSegment->element(track);
if (el && el->type() == Element::Type::CHORD)
break;
}
// search previous lyric
Lyrics* oldLyrics = 0;
while (segment) {
const QList<Lyrics*>* nll = segment->lyricsList(track);
if (nll) {
oldLyrics = nll->value(verse);
if (oldLyrics)
break;
}
segment = segment->prev1(Segment::Type::ChordRest);
}
if (nextSegment == 0) {
if (oldLyrics) {
switch(oldLyrics->syllabic()) {
case Lyrics::Syllabic::SINGLE:
case Lyrics::Syllabic::END:
break;
default:
oldLyrics->undoChangeProperty(P_ID::SYLLABIC, int(Lyrics::Syllabic::END));
break;
}
if (oldLyrics->segment()->tick() < endTick)
oldLyrics->undoChangeProperty(P_ID::LYRIC_TICKS, endTick - oldLyrics->segment()->tick());
}
return;
}
_score->startCmd();
const QList<Lyrics*>* ll = nextSegment->lyricsList(track);
lyrics = ll->value(verse);
bool newLyrics = (lyrics == 0);
if (!lyrics) {
lyrics = new Lyrics(_score);
lyrics->setTrack(track);
lyrics->setParent(nextSegment->element(track));
lyrics->setNo(verse);
lyrics->setSyllabic(Lyrics::Syllabic::SINGLE);
}
else
lyrics->undoChangeProperty(P_ID::SYLLABIC, int(Lyrics::Syllabic::SINGLE));
if (oldLyrics) {
switch(oldLyrics->syllabic()) {
case Lyrics::Syllabic::SINGLE:
case Lyrics::Syllabic::END:
break;
default:
oldLyrics->undoChangeProperty(P_ID::SYLLABIC, int(Lyrics::Syllabic::END));
break;
}
if (oldLyrics->segment()->tick() < endTick)
oldLyrics->undoChangeProperty(P_ID::LYRIC_TICKS, endTick - oldLyrics->segment()->tick());
}
if (newLyrics)
_score->undoAddElement(lyrics);
_score->select(lyrics, SelectType::SINGLE, 0);
startEdit(lyrics, -1);
mscore->changeState(mscoreState());
adjustCanvasPosition(lyrics, false);
((Lyrics*)editObject)->moveCursorToEnd();
_score->setLayoutAll(true);
_score->update();
}
示例14: while
void ScoreView::lyricsEndEdit()
{
Lyrics* lyrics = static_cast<Lyrics*>(editObject);
int endTick = lyrics->segment()->tick();
// search previous lyric:
int verse = lyrics->no();
int track = lyrics->track();
// search previous lyric
Lyrics* oldLyrics = 0;
Segment* segment = lyrics->segment();
while (segment) {
const QList<Lyrics*>* nll = segment->lyricsList(track);
if (nll) {
oldLyrics = nll->value(verse);
if (oldLyrics)
break;
}
segment = segment->prev1(Segment::Type::ChordRest);
}
if (lyrics->isEmpty())
lyrics->parent()->remove(lyrics);
else {
if (oldLyrics && oldLyrics->syllabic() == Lyrics::Syllabic::END) {
if (oldLyrics->endTick() >= endTick)
oldLyrics->undoChangeProperty(P_ID::LYRIC_TICKS, 0);
}
}
}
示例15: if
//.........这里部分代码省略.........
closeSlur(1, tick, staff, voice);
else if (an[i] == '{')
openSlur(2, tick, staff, voice);
else if (an[i] == '}')
closeSlur(2, tick, staff, voice);
else if (an[i] == 'z')
openSlur(3, tick, staff, voice);
else if (an[i] == 'x')
closeSlur(3, tick, staff, voice);
else if (an[i] == '.') {
Articulation* atr = new Articulation(score);
atr->setArticulationType(Articulation_Staccato);
chord->add(atr);
}
else if (an[i] == '_') {
Articulation* atr = new Articulation(score);
atr->setArticulationType(Articulation_Tenuto);
chord->add(atr);
}
else if (an[i] == 'v') {
Articulation* atr = new Articulation(score);
atr->setArticulationType(Articulation_Upbow);
chord->add(atr);
}
else if (an[i] == 'n') {
Articulation* atr = new Articulation(score);
atr->setArticulationType(Articulation_Downbow);
chord->add(atr);
}
else if (an[i] == 't') {
Articulation* atr = new Articulation(score);
atr->setArticulationType(Articulation_Trill);
chord->add(atr);
}
else if (an[i] == 'F') {
Articulation* atr = new Articulation(score);
atr->setUp(true);
atr->setArticulationType(Articulation_Fermata);
chord->add(atr);
}
else if (an[i] == 'E') {
Articulation* atr = new Articulation(score);
atr->setUp(false);
atr->setArticulationType(Articulation_Fermata);
chord->add(atr);
}
else if (an[i] == 'O') {
// Articulation* atr = new Articulation(score);
// atr->setArticulationType(Articulation_Downbow);
// chord->add(atr);
qDebug("%06d: open string '%c' not implemented", tick, an[i].toLatin1());
}
else if (an[i] == '&') {
// skip editorial level
if (i <= an.size() && an[i+1].isDigit())
++i;
}
else if (an[i] == 'p')
dynamics += "p";
else if (an[i] == 'm')
dynamics += "m";
else if (an[i] == 'f')
dynamics += "f";
else if (an[i] == '-') // tie
;
else if (an[i] == '*') // start tuplet
;
else if (an[i] == '!') // stop tuplet
;
else if (an[i] == '+') // cautionary accidental
;
else if (an[i] == 'X') // ???
;
else if (an[i] == ' ')
;
else {
qDebug("%06d: notation '%c' not implemented", tick, an[i].toLatin1());
}
}
if (!dynamics.isEmpty()) {
Dynamic* dyn = new Dynamic(score);
dyn->setDynamicType(dynamics);
dyn->setTrack(gstaff * VOICES);
Segment* s = measure->getSegment(Segment::SegChordRest, tick);
s->add(dyn);
}
QString txt = s.mid(43, 36);
if (!txt.isEmpty()) {
QStringList sl = txt.split("|");
int no = 0;
foreach(QString w, sl) {
w = diacritical(w);
Lyrics* l = new Lyrics(score);
l->setText(w);
l->setNo(no++);
l->setTrack(gstaff * VOICES);
Segment* segment = measure->tick2segment(tick);
segment->add(l);
}