Skip to content

Commit

Permalink
omr update
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 21, 2013
1 parent 8df9531 commit 39c4367
Show file tree
Hide file tree
Showing 22 changed files with 760 additions and 260 deletions.
1 change: 1 addition & 0 deletions aeolus/sparm_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SyntiParameterData : public QSharedData {

public:
SyntiParameterData();
virtual ~SyntiParameterData() {}
SyntiParameterData(const QString& name, float val);
SyntiParameterData(int id, const QString& name, float);
SyntiParameterData(const QString& name, const QString& val);
Expand Down
4 changes: 2 additions & 2 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ void ChordRest::writeProperties(Xml& xml) const

bool ChordRest::readProperties(XmlReader& e)
{
if (DurationElement::readProperties(e))
return true;
const QStringRef& tag(e.name());

if (tag == "BeamMode") {
Expand Down Expand Up @@ -348,6 +346,8 @@ bool ChordRest::readProperties(XmlReader& e)
element->read(e);
add(element);
}
else if (DurationElement::readProperties(e))
return true;
else
return false;
return true;
Expand Down
12 changes: 5 additions & 7 deletions libmscore/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ int DurationElement::actualTicks() const

bool DurationElement::readProperties(XmlReader& e)
{
if (Element::readProperties(e))
return true;
const QStringRef& tag(e.name());
if (tag == "Tuplet") {
if (e.name() == "Tuplet") {
// setTuplet(0);
int i = e.readInt();
Tuplet* t = e.findTuplet(i);
Expand All @@ -100,10 +97,11 @@ bool DurationElement::readProperties(XmlReader& e)
e.addTuplet(t);
}
}
return true;
}
else
return false;
return true;
if (Element::readProperties(e))
return true;
return false;
}

//---------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,18 @@ bool Element::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());

if (tag == "color")
_color = e.readColor();
if (tag == "track")
setTrack(e.readInt());
else if (tag == "visible")
_visible = e.readInt();
else if (tag == "selected")
_selected = e.readInt();
else if (tag == "pos")
_readPos = e.readPoint() * spatium();
else if (tag == "userOff")
_userOff = e.readPoint();
else if (tag == "color")
_color = e.readColor();
else if (tag == "selected")
_selected = e.readInt();
else if (tag == "lid") {
int id = e.readInt();
_links = score()->links().value(id);
Expand Down Expand Up @@ -707,12 +711,8 @@ bool Element::readProperties(XmlReader& e)
setUserOff(pt);
// _readPos = QPointF();
}
else if (tag == "pos")
_readPos = e.readPoint() * spatium();
else if (tag == "voice")
setTrack((_track/VOICES)*VOICES + e.readInt());
else if (tag == "track")
setTrack(e.readInt());
else if (tag == "tag") {
QString val(e.readElementText());
for (int i = 1; i < MAX_TAGS; i++) {
Expand Down
3 changes: 2 additions & 1 deletion libmscore/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ void AccidentalState::init(const KeySigEvent& ks)

KeySigEvent KeyList::key(int tick) const
{
if (empty())
if (empty()) {
return KeySigEvent();
}
auto i = upper_bound(tick);
if (i == begin())
return KeySigEvent();
Expand Down
2 changes: 1 addition & 1 deletion libmscore/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum {
KEY_MAX = KEY_C_S,
INVALID_KEY = KEY_MIN-1,
NUM_OF_KEYS = KEY_MAX - KEY_MIN + 1
};
};

// the delta in key value to reach the next (or prev) enharmonically equivalent key:
static const int KEY_DELTA_ENHARMONIC = 12;
Expand Down
4 changes: 0 additions & 4 deletions libmscore/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ class Measure : public MeasureBase {
void push_back(Segment* e);
void push_front(Segment* e);

// void* pTimesig() { return &_timesig; }
// void* pLen() { return &_len; }

public:
Measure(Score* = 0);
Measure(const Measure&);
Expand Down Expand Up @@ -176,7 +173,6 @@ class Measure : public MeasureBase {
bool irregular() const { return _irregular; }
void setIrregular(bool val) { _irregular = val; }
int noOffset() const { return _noOffset; }
// Text* noText() const { return _noText; }

MeasureNumberMode measureNumberMode() const { return _noMode; }
void setMeasureNumberMode(MeasureNumberMode v) { _noMode = v; }
Expand Down
2 changes: 1 addition & 1 deletion libmscore/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ qDebug("cannot make gap in staff %d at tick %d", staffIdx, dst->tick());
int id = e.intAttribute("id");
Spanner* spanner = e.findSpanner(id);
if (spanner) {
e.spanner().removeOne(spanner);
e.removeSpanner(spanner);
int tick = e.tick() - tickStart + dstTick;
Measure* m = tick2measure(tick);
Segment* seg = m->undoGetSegment(Segment::SegChordRest, tick);
Expand Down
4 changes: 1 addition & 3 deletions libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,7 @@ void Tie::write(Xml& xml) const
void Tie::read(XmlReader& e)
{
while (e.readNextStartElement()) {
if (Element::readProperties(e))
;
else if (SlurTie::readProperties(e))
if (SlurTie::readProperties(e) || Element::readProperties(e))
;
else
e.unknown();
Expand Down
22 changes: 17 additions & 5 deletions libmscore/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,29 @@ void XmlReader::unknown() const
abort();
}

//---------------------------------------------------------
// addSpanner
//---------------------------------------------------------

void XmlReader::addSpanner(Spanner* s)
{
_spanner.insert(s->id(), s);
}

void XmlReader::removeSpanner(Spanner* s)
{
_spanner.remove(s->id());
}

//---------------------------------------------------------
// findSpanner
//---------------------------------------------------------

Spanner* XmlReader::findSpanner(int id) const
{
int n = _spanner.size();
for (int i = 0; i < n; ++i) {
if (_spanner.at(i)->id() == id)
return _spanner.at(i);
}
auto i = _spanner.find(id);
if (i != _spanner.end())
return *i;
return 0;
}

Expand Down
16 changes: 9 additions & 7 deletions libmscore/xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class XmlReader : public QXmlStreamReader {
// Score read context (for read optimizations):
int _tick;
int _track;
QList<Spanner*> _spanner;
QHash<int, Spanner*> _spanner;
QList<Beam*> _beams;
QList<Tuplet*> _tuplets;
QList<ClefList*> _clefListList; // used reading 1.2 scores
Expand Down Expand Up @@ -75,16 +75,18 @@ class XmlReader : public QXmlStreamReader {
void setTick(int val) { _tick = val; }
int track() const { return _track; }
void setTrack(int val) { _track = val; }
void addSpanner(Spanner* s) { _spanner.append(s); }
void addTuplet(Tuplet* s);
void addBeam(Beam* s) { _beams.append(s); }
void removeSpanner(Spanner* s) { _spanner.removeOne(s); }

void addSpanner(Spanner* s);
void removeSpanner(Spanner* s);
Spanner* findSpanner(int) const;
Beam* findBeam(int) const;

void addTuplet(Tuplet* s);
Tuplet* findTuplet(int) const;

QList<Spanner*>& spanner() { return _spanner; }
void addBeam(Beam* s) { _beams.append(s); }
Beam* findBeam(int) const;

QHash<int,Spanner*>& spanner() { return _spanner; }
QList<Tuplet*>& tuplets() { return _tuplets; }
QList<Beam*>& beams() { return _beams; }
QList<ClefList*>& clefListList() { return _clefListList; }
Expand Down
8 changes: 4 additions & 4 deletions mtest/libmscore/layout/tst_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class TestBenchmark : public QObject, public MTest
private slots:
void initTestCase();
void benchmark3();
void benchmark1();
void benchmark2();
// void benchmark1();
// void benchmark2();
};

//---------------------------------------------------------
Expand All @@ -60,7 +60,7 @@ void TestBenchmark::benchmark3()
score->loadMsc(path, false);
}
}

#if 0
void TestBenchmark::benchmark1()
{
score = readScore(DIR + "goldberg.mscx");
Expand All @@ -76,7 +76,7 @@ void TestBenchmark::benchmark2()
score->doLayout();
}
}

#endif

QTEST_MAIN(TestBenchmark)
#include "tst_benchmark.moc"
Expand Down
26 changes: 23 additions & 3 deletions omr/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,29 @@ TODO:
- Systeme erkennen

System-Preamble erkennen:
- Schlüssel erkennen
* Schlüssel erkennen
* Taktart erkennen
- Tonartvorzeichen erkennen
- Taktart erkennen
- Vorzeichen erkennen
- Notenhälse
- Flags
- Beams

===========================================
* create OmrMeasure
* distribute notes into measures
* detect timesig
- detect clef

* create notes in score
for simple cases
* create chords

panel:
- note head detection threshold

score gui:
- hover with mouse and detect element
- show info about element

- Seite aufbauen

Loading

0 comments on commit 39c4367

Please sign in to comment.