当前位置: 首页>>代码示例>>C++>>正文


C++ Segment::add方法代码示例

本文整理汇总了C++中Segment::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::add方法的具体用法?C++ Segment::add怎么用?C++ Segment::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Segment的用法示例。


在下文中一共展示了Segment::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fillGapWithRests

void MTrack::fillGapWithRests(Score* score, int voice,
                              const Fraction &startChordTickFrac,
                              const Fraction &restLength, int track)
      {
      Fraction startChordTick = startChordTickFrac;
      Fraction restLen = restLength;
      while (restLen > 0) {
            Fraction len = restLen;
            Measure* measure = score->tick2measure(startChordTick.ticks());
            if (startChordTick >= Fraction::fromTicks(measure->tick() + measure->ticks())) {
                  qDebug("tick2measure: %d end of score?", startChordTick.ticks());
                  startChordTick += restLen;
                  restLen = Fraction(0);
                  break;
                  }
            len = splitDurationOnBarBoundary(len, startChordTick, measure);

            if (len >= Fraction::fromTicks(measure->ticks())) {
                              // rest to the whole measure
                  len = Fraction::fromTicks(measure->ticks());
                  if (voice == 0) {
                        TDuration duration(TDuration::V_MEASURE);
                        Rest* rest = new Rest(score, duration);
                        rest->setDuration(measure->len());
                        rest->setTrack(track);
                        Segment* s = measure->getSegment(rest, startChordTick.ticks());
                        s->add(rest);
                        }
                  restLen -= len;
                  startChordTick += len;
                  }
            else {
                  auto dl = toDurationList(measure, voice, startChordTick, len,
                                           Meter::DurationType::REST);
                  if (dl.isEmpty()) {
                        qDebug("cannot create duration list for len %d", len.ticks());
                        restLen = Fraction(0);      // fake
                        break;
                        }
                  for (const auto &durationPair: dl) {
                        const TDuration &duration = durationPair.second;
                        const Fraction &tupletRatio = durationPair.first;
                        len = duration.fraction() / tupletRatio;
                        Rest* rest = new Rest(score, duration);
                        rest->setDuration(duration.fraction());
                        rest->setTrack(track);
                        Segment* s = measure->getSegment(Segment::SegChordRest,
                                                         startChordTick.ticks());
                        s->add(rest);
                        addElementToTuplet(voice, startChordTick, len, rest);
                        restLen -= len;
                        startChordTick += len;
                        }
                  }

            }
      }
开发者ID:Skibol,项目名称:MuseScore,代码行数:57,代码来源:importmidi.cpp

示例2: fillGapsWithRests

void fillGapsWithRests(Score* score, int ctick, int restLen, int track)
      {
      bool useDots = preferences.midiImportOperations.currentTrackOperations().useDots;
      while (restLen > 0) {
            int len = restLen;
            Measure* measure = score->tick2measure(ctick);
            if (ctick >= measure->tick() + measure->ticks()) {
                  qDebug("tick2measure: %d end of score?", ctick);
                  ctick += restLen;
                  restLen = 0;
                  break;
                  }
            // split rest on measure boundary
            if ((ctick + len) > measure->tick() + measure->ticks())
                  len = measure->tick() + measure->ticks() - ctick;
            if (len >= measure->ticks()) {
                  len = measure->ticks();
                  TDuration d(TDuration::V_MEASURE);
                  Rest* rest = new Rest(score, d);
                  rest->setDuration(measure->len());
                  rest->setTrack(track);
                  Segment* s = measure->getSegment(rest, ctick);
                  s->add(rest);
                  restLen -= len;
                  ctick   += len;
                  }
            else {
                  QList<TDuration> dl = Meter::toDurationList(ctick - measure->tick(),
                                                              ctick + len - measure->tick(),
                                                              measure->timesig(),
                                                              Meter::DurationType::REST,
                                                              useDots);
                  if (dl.isEmpty()) {
                        qDebug("cannot create duration list for len %d", len);
                        restLen = 0;      // fake
                        break;
                        }
                  foreach (TDuration d, dl) {
                        Rest* rest = new Rest(score, d);
                        rest->setDuration(d.fraction());
                        rest->setTrack(track);
                        Segment* s = measure->getSegment(Segment::SegChordRest, ctick);
                        s->add(rest);
                        restLen -= d.ticks();
                        ctick   += d.ticks();
                        }
                  }
            }
开发者ID:akinsgre,项目名称:MuseScore,代码行数:48,代码来源:importmidi.cpp

示例3: setTempoToScore

void setTempoToScore(Score *score, int tick, double beatsPerSecond)
      {
      if (score->tempomap()->find(tick) != score->tempomap()->end())
            return;
                  // don't repeat tempo, always set only tempo for tick 0
      if (tick > 0 && score->tempo(tick) == beatsPerSecond)
            return;

      score->setTempo(tick, beatsPerSecond);

      auto *data = preferences.midiImportOperations.data();
      if (data->trackOpers.showTempoText.value()) {
            const int tempoInBpm = qRound(beatsPerSecond * 60.0);

            TempoText *tempoText = new TempoText(score);
            tempoText->setTempo(beatsPerSecond);
            tempoText->setXmlText(QString("<sym>metNoteQuarterUp</sym> = %1").arg(tempoInBpm));
            tempoText->setTrack(0);

            Measure *measure = score->tick2measure(tick);
            if (!measure) {
                  qDebug("MidiTempo::setTempoToScore: no measure for tick %d", tick);
                  return;
                  }
            Segment *segment = measure->getSegment(Segment::Type::ChordRest, tick);
            if (!segment) {
                  qDebug("MidiTempo::setTempoToScore: no chord/rest segment for tempo at %d", tick);
                  return;
                  }
            segment->add(tempoText);
            data->hasTempoText = true;      // to show tempo text column in the MIDI import panel
            }
      }
开发者ID:Angeldude,项目名称:MuseScore,代码行数:33,代码来源:importmidi_tempo.cpp

示例4: RehearsalMark

void GuitarPro5::readMeasures(int /*startingTempo*/)
      {
      Measure* measure = score->firstMeasure();
      bool mixChange = false;
      for (int bar = 0; bar < measures; ++bar, measure = measure->nextMeasure()) {
            const GpBar& gpbar = bars[bar];

            if (!gpbar.marker.isEmpty()) {
                  Text* s = new RehearsalMark(score);
                  s->setText(gpbar.marker.trimmed());
                  s->setTrack(0);
                  Segment* segment = measure->getSegment(Segment::Type::ChordRest, measure->tick());
                  segment->add(s);
                  }

            Tuplet* tuplets[staves * 2];     // two voices
            for (int track = 0; track < staves*2; ++track)
                  tuplets[track] = 0;

            for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
                  readMeasure(measure, staffIdx, tuplets, mixChange);
                  if (!(((bar == (measures-1)) && (staffIdx == (staves-1))))) {
                        /*int a = */  readChar();
                        // qDebug("    ======skip %02x", a);
                        }
                  }
            if (bar == 1 && !mixChange)
                  setTempo(tempo, score->firstMeasure());
            }
      }
开发者ID:jpirie,项目名称:MuseScore,代码行数:30,代码来源:importgtp-gp5.cpp

示例5: addNote

void Lilypond::addNote(const LNote& lnote)
      {
      createMeasure();

      Segment* segment = new Segment(measure);
      segment->setSubtype(SegChordRest);
      segment->setTick(tick);
      segment->setParent(measure);
      measure->add(segment);

      Chord* chord = new Chord(score);
      chord->setTrack(staff->idx() * VOICES);
      chord->setParent(segment);
      Duration d;
      d.setVal(lnote.len);
      chord->setDurationType(d);

      segment->add(chord);

      Note* note = new Note(score);
      note->setPitch(lnote.pitch);
      note->setTpcFromPitch();
      note->setParent(chord);
      note->setTrack(staff->idx() * VOICES);
      chord->add(note);
      tick += lnote.len;
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:27,代码来源:lilypond.cpp

示例6: readSegments

//-----------------------------------------------------
// 
//-----------------------------------------------------
int readSegments() 
{
	int scan_index;
	int type;
	int n_beams;	
	int ret;	
	float angle, range;
	float timestamp;
	int n_lasers;
	int level;
	int n_segments;
	Segment *s;
	int num_readings;
	int position;

	while ( !feof(fin) ) {
		//start reading segments
		ret = fscanf(fin, "%d %f %d %d %d %d %d", &scan_index, &timestamp, &n_lasers, &level, &n_segments, &type, &n_beams);
		if ( ret == 7 ) {

			if (mScan!=NULL) {
				if ( scan_index != mScan->scan_id ) {
					outputScan();
					delete mScan;
					mScan=NULL;
				}
			}
			
			if (mScan==NULL) {
				mScan = new MultiScan(n_lasers);			
				mScan->scan_id = scan_index;

			//cerr << "mScan->scan_id: " << mScan->scan_id << endl;

				mScan->timestamp = timestamp;		
			}	

			// read multi scan
			s = new Segment;
			s->type = type;
			for(int k=0; k<n_beams; k++) {
				Beam *b = new Beam;;
				fscanf(fin, " %d %d %f %f", &num_readings, &position, &angle, &range );
				b->range = range;
				b->angle = angle;
				s->add(b);				
			}
			mScan->scans[level]->add(s);
		} // end if ( ret == 3 ) {			
	} //end while ( !feof(fin) )
	
	if ( mScan != NULL ) {
		outputScan();			
		delete mScan;
		mScan = NULL;
	}

	return 1;
}
开发者ID:ChingHengWang,项目名称:ed_perception,代码行数:62,代码来源:plot_segments.cpp

示例7: processPendingNotes

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);
      }
开发者ID:Skibol,项目名称:MuseScore,代码行数:55,代码来源:importmidi.cpp

示例8: addKeySig

void MCursor::addKeySig(Key key)
      {
      createMeasures();
      Measure* measure = _score->tick2measure(_tick);
      Segment* segment = measure->getSegment(Segment::Type::KeySig, _tick);
      int n = _score->nstaves();
      for (int i = 0; i < n; ++i) {
            KeySig* ks = new KeySig(_score);
            ks->setKey(key);
            ks->setTrack(i * VOICES);
            segment->add(ks);
            }
      }
开发者ID:Soerboe,项目名称:MuseScore,代码行数:13,代码来源:mcursor.cpp

示例9: segmentScan

//-----------------------------------------------------
// segment a scan
// ----------------------------------------------------
void LegsDetector::segmentScan(double threshold, int n_readings, double *angles, double *ranges, dyntab_segments *segments)
{

	//cerr << "LegsDetector::segmentScan" << endl; 

	Segment *s;
	Beam *b=NULL, *b_prev=NULL;	

	s = new Segment;
	//start with a segment
	for (int i=0; i<n_readings; i++) {			
		// read the first point
		b = new Beam;
		b->range = ranges[i];
		b->angle = angles[i];
		b->num_readings = n_readings;
		b->position = i;					
		if ( s->num() > 0 ) {
			if ( fabs(b_prev->range - b->range) < threshold ) {
				// same segment
				b_prev = b;
				b->segment_id = segments->num(); 
				s->add(b);					
			}
			else {
				segments->add(s);
				s = new Segment;
				b->segment_id = segments->num(); 
				s->add(b);
				b_prev = b;
			} 
		}	
		else {
			b_prev = b;
			s->add(b);	
		}						
	}
	segments->add(s);
} 
开发者ID:Thordreck,项目名称:people_detector,代码行数:42,代码来源:LegsDetector.cpp

示例10: addTimeSig

TimeSig* MCursor::addTimeSig(const Fraction& f)
      {
      createMeasures();
      Measure* measure = _score->tick2measure(_tick);
      Segment* segment = measure->getSegment(Segment::Type::TimeSig, _tick);
      TimeSig* ts = 0;
      for (int i = 0; i < _score->nstaves(); ++i) {
            ts = new TimeSig(_score);
            ts->setSig(f, TimeSigType::NORMAL);
            ts->setTrack(i * VOICES);
            segment->add(ts);
            }
      _score->sigmap()->add(_tick, SigEvent(f));
      return ts;
      }
开发者ID:Soerboe,项目名称:MuseScore,代码行数:15,代码来源:mcursor.cpp

示例11: setTempo

static void setTempo(Score* score, int tempo)
      {
      TempoText* tt = new TempoText(score);
      tt->setTempo(double(tempo)/60.0);
      tt->setTrack(0);

      QTextCursor* c = tt->startCursorEdit();
      c->movePosition(QTextCursor::EndOfLine);
      addSymbolToText(SymCode(0xe105, 1), c);
      c->insertText(" = ");
      c->insertText(QString("%1").arg(tempo));
      tt->endEdit();

      Measure* measure = score->firstMeasure();
      Segment* segment = measure->getSegment(Segment::SegChordRest, 0);
      segment->add(tt);
      }
开发者ID:kcleung,项目名称:MuseScore,代码行数:17,代码来源:importbww.cpp

示例12: addRest

void Lilypond::addRest()
      {
      createMeasure();

      Segment* segment = new Segment(measure);
      segment->setSubtype(SegChordRest);
      segment->setTick(tick);
      segment->setParent(measure);
      measure->add(segment);

      Rest* rest = new Rest(score);
      rest->setTrack(staff->idx() * VOICES);
      rest->setParent(segment);
      Duration d;
      d.setVal(curLen);
      rest->setDurationType(d);
      segment->add(rest);
      tick += curLen;
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:19,代码来源:lilypond.cpp

示例13: addChord

Chord* MCursor::addChord(int pitch, const TDuration& duration)
      {
      createMeasures();
      Measure* measure = _score->tick2measure(_tick);
      Segment* segment = measure->getSegment(Segment::Type::ChordRest, _tick);
      Chord* chord = static_cast<Chord*>(segment->element(_track));
      if (chord == 0) {
            chord = new Chord(_score);
            chord->setTrack(_track);
            chord->setDurationType(duration);
            chord->setDuration(duration.fraction());
            segment->add(chord);
            }
      Note* note = new Note(_score);
      chord->add(note);
      note->setPitch(pitch);
      note->setTpcFromPitch();
      _tick += duration.ticks();
      return chord;
      }
开发者ID:Soerboe,项目名称:MuseScore,代码行数:20,代码来源:mcursor.cpp

示例14: applySwing

void SwingDetector::applySwing()
      {
      if (elements.size() != 2 && elements.size() != 3)
            return;

      Tuplet *tuplet = nullptr;
      for (ChordRest *el: elements) {
            el->setDurationType(TDuration::DurationType::V_EIGHTH);
            el->setTicks(Fraction(1, 8));
            el->setDots(0);
            if (el->tuplet()) {
                  if (!tuplet)
                        tuplet = el->tuplet();
                  tuplet->remove(el);
                  el->setTuplet(nullptr);
                  }
            }

      const ChordRest *first = elements.front();
      const int startTick = first->segment()->tick().ticks();
      ChordRest *last = elements.back();
      last->segment()->remove(last);
      Segment *s = last->measure()->getSegment(SegmentType::ChordRest, Fraction::fromTicks(startTick + MScore::division / 2));
      s->add(last);

      if (elements.size() == 3) {
                  // remove central rest
            ChordRest *cr = elements[1];
            cr->score()->removeElement(cr);
            delete cr;
            }

      if (tuplet) {
                  // delete tuplet
            delete tuplet;
            tuplet = nullptr;
            }
      if (!swingApplied)
            swingApplied = true;
      }
开发者ID:Jojo-Schmitz,项目名称:MuseScore,代码行数:40,代码来源:importmidi_swing.cpp

示例15: assignKeyListToStaff

void assignKeyListToStaff(const KeyList &kl, Staff *staff)
      {
      Score* score = staff->score();
      const int track = staff->idx() * VOICES;
      Key pkey = Key::C;

      for (auto it = kl.begin(); it != kl.end(); ++it) {
            const int tick = it->first;
            Key key  = it->second.key();
            if ((key == Key::C) && (key == pkey))     // dont insert uneccessary C key
                  continue;
            pkey = key;
            KeySig* ks = new KeySig(score);
            ks->setTrack(track);
            ks->setGenerated(false);
            ks->setKey(key);
            ks->setMag(staff->mag());
            Measure* m = score->tick2measure(tick);
            Segment* seg = m->getSegment(ks, tick);
            seg->add(ks);
            }
      }
开发者ID:Angeldude,项目名称:MuseScore,代码行数:22,代码来源:importmidi_key.cpp


注:本文中的Segment::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。