本文整理汇总了C++中Chord类的典型用法代码示例。如果您正苦于以下问题:C++ Chord类的具体用法?C++ Chord怎么用?C++ Chord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: staff
bool Arpeggio::edit(MuseScoreView*, Grip curGrip, int key, Qt::KeyboardModifiers modifiers, const QString&)
{
if (curGrip != Grip::END || !(modifiers & Qt::ShiftModifier))
return false;
if (key == Qt::Key_Down) {
Staff* s = staff();
Part* part = s->part();
int n = part->nstaves();
int ridx = part->staves()->indexOf(s);
if (ridx >= 0) {
if (_span + ridx < n)
++_span;
}
}
else if (key == Qt::Key_Up) {
if (_span > 1)
--_span;
}
else
return false;
layout();
Chord* c = chord();
rxpos() = -(width() + spatium() * .5);
c->layoutArpeggio2();
return true;
}
示例2: searchNote
Note* Score::upAlt(Element* element)
{
Element* re = 0;
if (element->type() == REST) {
if (_is.track() <= 0)
return 0;
_is.setTrack(_is.track() - 1);
re = searchNote(static_cast<Rest*>(element)->tick(), _is.track());
}
else if (element->type() == NOTE) {
// find segment
Chord* chord = static_cast<Note*>(element)->chord();
Segment* segment = chord->segment();
// collect all notes for this segment in noteList:
QList<Note*> rnl;
int tracks = nstaves() * VOICES;
for (int track = 0; track < tracks; ++track) {
Element* el = segment->element(track);
if (!el || el->type() != CHORD)
continue;
rnl.append(static_cast<Chord*>(el)->notes());
qSort(rnl.begin(), rnl.end(), noteLessThan);
int idx = rnl.indexOf(static_cast<Note*>(element));
if (idx < rnl.size()-1)
++idx;
re = rnl.value(idx);
}
}
if (re == 0)
return 0;
if (re->type() == CHORD)
re = ((Chord*)re)->notes().front();
return (Note*)re;
}
示例3: switch
Element* Rest::drop(const DropData& data)
{
Element* e = data.element;
switch (e->type()) {
case ARTICULATION:
if (e->subtype() == Articulation_Fermata)
score()->addArticulation(this, (Articulation*)e);
return 0;
case ICON:
{
switch(e->subtype()) {
case ICON_SBEAM:
score()->undoChangeBeamMode(this, BEAM_BEGIN);
break;
case ICON_MBEAM:
score()->undoChangeBeamMode(this, BEAM_MID);
break;
case ICON_NBEAM:
score()->undoChangeBeamMode(this, BEAM_NO);
break;
case ICON_BEAM32:
score()->undoChangeBeamMode(this, BEAM_BEGIN32);
break;
case ICON_BEAM64:
score()->undoChangeBeamMode(this, BEAM_BEGIN64);
break;
case ICON_AUTOBEAM:
score()->undoChangeBeamMode(this, BEAM_AUTO);
break;
}
}
delete e;
break;
case CHORD:
{
Chord* c = static_cast<Chord*>(e);
Note* n = c->upNote();
Direction dir = c->stemDirection();
score()->select(0, SELECT_SINGLE, 0);
NoteVal nval;
nval.pitch = n->pitch();
nval.headGroup = n->headGroup();
Fraction d = score()->inputState().duration().fraction();
if (!d.isZero()) {
Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir);
if (seg) {
ChordRest* cr = static_cast<ChordRest*>(seg->element(track()));
if (cr)
score()->nextInputPos(cr, true);
}
}
delete e;
}
break;
default:
return ChordRest::drop(data);
}
return 0;
}
示例4: createScore
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords)
{
MCursor c;
c.setTimeSig(_sig);
c.createScore("score8");
c.addPart("voice");
c.move(0, 0);
c.addKeySig(0);
TimeSig* nts = c.addTimeSig(_sig);
GroupNode node {0, 0};
Groups ng;
ng.push_back(node);
nts->setGroups(ng);
for (int i = 0; i < n; ++i) {
Chord* chord = c.addChord(67, t);
int tick = chord->rtick();
chord->setBeamMode(_groups.beamMode(tick, t));
chords->push_back(chord);
}
c.score()->parts().front()->setLongName("");
c.score()->style()->set(ST_linearStretch, 1.1);
return c.score();
}
示例5: chord
QLineF Arpeggio::dragAnchor() const
{
Chord* c = chord();
if (c)
return QLineF(pagePos(), c->upNote()->pagePos());
return QLineF();
}
示例6: createScore
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords)
{
MCursor c;
c.setTimeSig(_sig);
c.createScore("score8");
c.addPart("voice");
c.move(0, 0);
c.addKeySig(Key::C);
TimeSig* nts = c.addTimeSig(_sig);
GroupNode node {0, 0};
Groups ng;
ng.push_back(node);
nts->setGroups(ng);
for (int i = 0; i < n; ++i) {
Chord* chord = c.addChord(67, t);
int tick = chord->rtick();
chord->setBeamMode(_groups.beamMode(tick, t));
chords->push_back(chord);
}
c.score()->pageFormat()->setEvenLeftMargin(0.0);
c.score()->pageFormat()->setOddLeftMargin(0.0);
c.score()->parts().front()->setLongName("");
c.score()->style()->set(StyleIdx::linearStretch, 1.3);
c.score()->style()->set(StyleIdx::MusicalSymbolFont, QString("Bravura"));
c.score()->style()->set(StyleIdx::MusicalTextFont, QString("Bravura Text"));
return c.score();
}
示例7: 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));
}
示例8: up
void Stem::editDrag(const EditData& ed)
{
qreal yDelta = ed.delta.y();
_userLen += up() ? -yDelta : yDelta;
layout();
Chord* c = static_cast<Chord*>(parent());
if (c->hook())
c->hook()->move(QPointF(0.0, ed.delta.y()));
}
示例9: track
void Ambitus::updateRange()
{
if (!segment())
return;
Chord* chord;
int firstTrack = track();
int lastTrack = firstTrack + VOICES-1;
int pitchTop = -1000;
int pitchBottom = 1000;
int tpcTop = 0; // Initialized to prevent warning
int tpcBottom = 0; // Initialized to prevent warning
int trk;
Measure* meas = segment()->measure();
Segment* segm = meas->findSegment(SegmentType::ChordRest, segment()->tick());
bool stop = meas->sectionBreak();
while (segm) {
// moved to another measure?
if (segm->measure() != meas) {
// if section break has been found, stop here
if (stop)
break;
// update meas and stop condition
meas = segm->measure();
stop = meas->sectionBreak();
}
// scan all relevant tracks of this segment for chords
for (trk = firstTrack; trk <= lastTrack; trk++) {
Element* e = segm->element(trk);
if (!e || !e->isChord())
continue;
chord = toChord(e);
// update pitch range (with associated tpc's)
for (Note* n : chord->notes()) {
if (!n->play()) // skip notes which are not to be played
continue;
int pitch = n->ppitch();
if (pitch > pitchTop) {
pitchTop = pitch;
tpcTop = n->tpc();
}
if (pitch < pitchBottom) {
pitchBottom = pitch;
tpcBottom = n->tpc();
}
}
}
segm = segm->nextCR();
}
if (pitchTop > -1000) { // if something has been found, update this
_topPitch = pitchTop;
_bottomPitch = pitchBottom;
_topTpc = tpcTop;
_bottomTpc = tpcBottom;
}
}
示例10:
bool operator==(const Chord &c1, const Chord &c2)
{
if (c1.getChordText() != c2.getChordText())
return false;
if (c1.getBeat() != c2.getBeat())
return false;
return true;
}
示例11: GetDrawingDur
int Note::GetDrawingDur( )
{
Chord* chordParent = dynamic_cast<Chord*>(this->GetFirstParent( CHORD, MAX_CHORD_DEPTH));
if( chordParent ) {
return chordParent->GetActualDur();
}
else {
return GetActualDur();
}
}
示例12: drumNoteSelected
void DrumTools::drumNoteSelected(int val)
{
Element* element = drumPalette->element(val);
Chord* ch = static_cast<Chord*>(element);
Note* note = ch->downNote();
int ticks = MScore::defaultPlayDuration;
int pitch = note->pitch();
seq->startNote(staff->part()->instr()->channel(0), pitch, 80, ticks, 0.0);
_score->inputState().setDrumNote(note->pitch());
}
示例13: while
void MTrack::processPendingNotes(QList<MidiChord> &midiChords,
int voice,
const Fraction &startChordTickFrac,
const Fraction &nextChordTick)
{
Score* score = staff->score();
int track = staff->idx() * VOICES + voice;
Drumset* drumset = staff->part()->instr()->drumset();
bool useDrumset = staff->part()->instr()->useDrumset();
// all midiChords here should have the same onTime value
// and all notes in each midiChord should have the same duration
Fraction startChordTick = startChordTickFrac;
while (!midiChords.isEmpty()) {
Fraction tick = startChordTick;
Fraction len = nextChordTick - tick;
if (len <= Fraction(0))
break;
len = findMinDuration(midiChords, len);
Measure* measure = score->tick2measure(tick.ticks());
len = splitDurationOnBarBoundary(len, tick, measure);
auto dl = toDurationList(measure, voice, tick, len, Meter::DurationType::NOTE);
if (dl.isEmpty())
break;
const TDuration &d = dl[0].second;
const Fraction &tupletRatio = dl[0].first;
len = d.fraction() / tupletRatio;
Chord* chord = new Chord(score);
chord->setTrack(track);
chord->setDurationType(d);
chord->setDuration(d.fraction());
Segment* s = measure->getSegment(chord, tick.ticks());
s->add(chord);
chord->setUserPlayEvents(true);
addElementToTuplet(voice, tick, len, chord);
for (int k = 0; k < midiChords.size(); ++k) {
MidiChord& midiChord = midiChords[k];
setMusicNotesFromMidi(score, midiChord.notes, startChordTick,
len, chord, tick, drumset, useDrumset);
if (!midiChord.notes.empty() && midiChord.notes.first().len <= len) {
midiChords.removeAt(k);
--k;
continue;
}
setTies(chord, score, midiChord.notes);
for (auto &midiNote: midiChord.notes)
midiNote.len -= len;
}
startChordTick += len;
}
fillGapWithRests(score, voice, startChordTick,
nextChordTick - startChordTick, track);
}
示例14: while
int generator::getNoteFrequencyByIndex(const Chord& tonicChord, int index){
// 1-indexation here
int octave = 0;
while (index < 1){
octave--;
index += 7;
}
while (index > 7){
octave++;
index -= 7;
}
int baseFrequency = tonicChord.getNote().getFrequency() + octave * 12;
// FixMe: do not use switches for this
//later
if (tonicChord.getMode() == MAJOR){
switch(index){
case 1:
return baseFrequency + 0;
case 2:
return baseFrequency + 2;
case 3:
return baseFrequency + 4;
case 4:
return baseFrequency + 5;
case 5:
return baseFrequency + 7;
case 6:
return baseFrequency + 9;
case 7:
return baseFrequency + 11;
default:
return baseFrequency + 12;
}
} else {
switch(index){
case 1:
return baseFrequency + 0;
case 2:
return baseFrequency + 2;
case 3:
return baseFrequency + 3;
case 4:
return baseFrequency + 5;
case 5:
return baseFrequency + 7;
case 6:
return baseFrequency + 8;
case 7:
return baseFrequency + 10;
default:
return baseFrequency + 12;
}
}
}
示例15: note
Placement Fingering::calculatePlacement() const
{
Note* n = note();
if (!n)
return Placement::ABOVE;
Chord* chord = n->chord();
Staff* staff = chord->staff();
Part* part = staff->part();
int nstaves = part->nstaves();
bool voices = chord->measure()->hasVoices(staff->idx());
bool below = voices ? !chord->up() : (nstaves > 1) && (staff->rstaff() == nstaves - 1);
return below ? Placement::BELOW : Placement::ABOVE;
}