Ejemplo n.º 1
0
void TrackList::append(Element* e)
      {
      if (e->isDurationElement()) {
            Fraction d = static_cast<DurationElement*>(e)->duration();
            _duration += d;

            bool accumulateRest = e->type() == Element::Type::REST && !isEmpty()
               && back()->type() == Element::Type::REST;
            Segment* s = accumulateRest ? static_cast<Rest*>(e)->segment() : 0;

            if (s && !s->score()->isSpannerStartEnd(s->tick(), e->track()) && !s->annotations().size()) {
                  // akkumulate rests
                  Rest* rest = static_cast<Rest*>(back());
                  Fraction d = rest->duration();
                  d += static_cast<Rest*>(e)->duration();
                  rest->setDuration(d);
                  }
            else
                  {
                  Element* element = e->clone();
                  QList<Element*>::append(element);
                  if (e->type() == Element::Type::TUPLET) {
                        Tuplet* srcTuplet = static_cast<Tuplet*>(e);
                        Tuplet* dstTuplet = static_cast<Tuplet*>(element);

                        foreach(const DurationElement* de, srcTuplet->elements())
                              dstTuplet->add(de->clone());
                        }
                  else {
Ejemplo n.º 2
0
void TestInstrumentChange::testDelete()
      {
      Score* score = test_pre("delete");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      score->deleteItem(ic);
      score->doLayout();
      test_post(score, "delete");
      }
Ejemplo n.º 3
0
int Part::harmonyCount()
      {
      if (!score())
            return 0;
      int count = 0;
      Segment::Type st = Segment::Type::ChordRest;
      for (Segment* seg = score()->firstMeasure()->first(st); seg; seg = seg->next1(st)) {
            for (Element* e : seg->annotations()) {
                  if (e->type() == Element::Type::HARMONY && e->track() >= startTrack() && e->track() < endTrack())
                        count++;
                  }
            }
      return count;
      }
Ejemplo n.º 4
0
void TestInstrumentChange::testCopy()
      {
      Score* score = test_pre("copy");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      m = m->nextMeasure();
      s = m->first(Segment::Type::ChordRest);
      InstrumentChange* nic = new InstrumentChange(*ic);
      nic->setParent(s);
      nic->setTrack(4);
      score->undoAddElement(nic);
      score->doLayout();
      test_post(score, "copy");
      }
Ejemplo n.º 5
0
void TestInstrumentChange::testChange()
      {
      Score* score = test_pre("change");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      Instrument* ni = score->staff(1)->part()->instr();
      ic->setInstrument(*ni);
      score->startCmd();
      ic->setText("Instrument Oboe");
      score->undo(new ChangeInstrument(ic, ic->instrument()));
      score->endCmd();
      score->doLayout();
      test_post(score, "change");
      }
Ejemplo n.º 6
0
Dynamic* lookupDynamic(Element* e)
      {
      Dynamic* d = 0;
      Segment* s = 0;
      if (e && e->isChord())
            s = toChord(e)->segment();
      if (s) {
            for (Element* ee : s->annotations()) {
                  if (ee->isDynamic() && ee->track() == e->track() && ee->placeBelow()) {
                        d = toDynamic(ee);
                        break;
                        }
                  }
            }
      if (d) {
            if (!d->autoplace())
                  d = 0;
            }
      return d;
      }
Ejemplo n.º 7
0
void TestInstrumentChange::testMixer()
      {
      Score* score = test_pre("mixer");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      int idx = score->staff(0)->channel(s->tick(), 0);
      Channel* c = &score->staff(0)->part()->instr(s->tick())->channel(idx);
      MidiPatch* mp = new MidiPatch;
      mp->bank = 0;
      mp->drum = false;
      mp->name = "Viola";
      mp->prog = 41;
      mp->synti = "Fluid";
      score->startCmd();
      ic->setText("Mixer Viola");
      score->undo(new ChangePatch(c, mp));
      score->endCmd();
      score->doLayout();
      test_post(score, "mixer");
      }