Skip to content

Commit

Permalink
Merge branch 'bug1673'
Browse files Browse the repository at this point in the history
  • Loading branch information
tedfelix committed Apr 2, 2024
2 parents f640f1c + 2034e8e commit 9bfedf8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 63 deletions.
26 changes: 12 additions & 14 deletions src/document/io/MusicXMLImportHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
Copyright 2000-2023 the Rosegarden development team.
Copyright 2000-2024 the Rosegarden development team.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
Expand All @@ -18,26 +18,23 @@
#define RG_MODULE_STRING "[MusicXMLImportHelper]"

#include "MusicXMLImportHelper.h"

#include "base/Event.h"
#include "base/BaseProperties.h"
#include "misc/Debug.h"
#include "misc/Strings.h"
#include "base/Composition.h"
#include "base/Studio.h"
#include "base/Instrument.h"
#include "base/MidiProgram.h"
#include "base/NotationTypes.h"
#include "gui/editors/notation/NotationProperties.h"
#include "base/StaffExportTypes.h"
#include "base/NotationTypes.h" // for Clef
#include "base/StaffExportTypes.h" // for Brackets
#include "base/Segment.h"
#include "base/Track.h"

#include <QString>

namespace Rosegarden

namespace Rosegarden
{

using namespace BaseProperties;

MusicXMLImportHelper::MusicXMLImportHelper(Composition *composition) :
m_composition(composition)
Expand Down Expand Up @@ -110,8 +107,7 @@ MusicXMLImportHelper::setVoice(const QString &voice)
SegmentMap::iterator s = m_segments.find(m_staff+"/");
if (s != m_segments.end()) {
m_segments[m_staff+"/"+m_mainVoice[m_staff]] = (*s).second;
QString label = "MusicXML, id="+m_staff+"/"+m_mainVoice[m_staff];
(*s).second->setLabel(label.toStdString());
(*s).second->setLabel(m_label.toStdString());
m_segments.erase(s);
}
m_voice = m_mainVoice[m_staff];
Expand All @@ -128,8 +124,7 @@ MusicXMLImportHelper::setVoice(const QString &voice)
}
if (createSegment) {
Segment *segment = new Segment(Segment::Internal, m_curTime);
QString label = "MusicXML, id="+m_staff+"/"+tmpVoice;
segment->setLabel(label.toStdString());
segment->setLabel(m_label.toStdString());
m_composition->addSegment(segment);
segment->setTrack(m_tracks[m_staff]->getId());
m_segments[m_staff+"/"+tmpVoice] = segment;
Expand All @@ -142,6 +137,7 @@ MusicXMLImportHelper::setVoice(const QString &voice)
bool
MusicXMLImportHelper::setLabel(const QString &label)
{
m_label = label;
for (TrackMap::iterator i = m_tracks.begin(); i != m_tracks.end(); ++i) {
((*i).second)->setLabel(label.toStdString());
}
Expand Down Expand Up @@ -194,7 +190,8 @@ MusicXMLImportHelper::insertClef(const Clef &clef, int number)
bool
MusicXMLImportHelper::insert(Event *event)
{
if (event->has(IS_GRACE_NOTE) && event->get<Bool>(IS_GRACE_NOTE)) {
if (event->has(BaseProperties::IS_GRACE_NOTE) &&
event->get<Bool>(BaseProperties::IS_GRACE_NOTE)) {
Segment *segment = m_segments[m_staff+"/"+m_voice];
Segment::iterator start, end;
segment->getTimeSlice(m_curTime, start, end);
Expand Down Expand Up @@ -337,4 +334,5 @@ MusicXMLImportHelper::setBracketType(int bracket)
}
}


}
93 changes: 44 additions & 49 deletions src/document/io/MusicXMLImportHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,67 +19,32 @@
#ifndef RG_MUSICXMLIMPORTHELPER_H
#define RG_MUSICXMLIMPORTHELPER_H

#include "base/BaseProperties.h"
#include "base/Composition.h"
#include "base/Instrument.h"
#include "base/NotationTypes.h"
#include "base/StaffExportTypes.h"
#include "base/Segment.h"
#include "base/MidiProgram.h"
#include "base/Studio.h"
#include "base/Event.h"
#include "base/Track.h"
#include "base/NotationTypes.h"
#include "gui/editors/notation/NotationProperties.h"
#include "base/TimeT.h"

#include <QString>

#include <string>
#include <vector>
#include <queue>

#include <QString>
#include <map>


namespace Rosegarden
{

// class Segment;
// class Composition;

// typedef std::map<QString, timeT> IndicationMap;
// typedef std::map<QString, int> UnpitchedMap;
class Composition;
class Track;
class Segment;
class Event;
class Key;
class TimeSignature;
class Clef;


class MusicXMLImportHelper {
public:

class IndicationStart {
public:
IndicationStart(const QString &staff="", const QString &voice="",
const std::string &name="", timeT time=0, int number=1,
const std::string &endName="") :
m_staff(staff),
m_voice(voice),
m_name(name),
m_endName((endName == "") ? name : endName),
m_time(time),
m_number(number)
{
};
QString m_staff;
QString m_voice;
std::string m_name;
std::string m_endName;
timeT m_time;
int m_number;
};

// struct IndicationCMP {
// bool operator()(const IndicationStart &a, const IndicationStart &b) {
// return true;
// };
// };

typedef std::vector<IndicationStart> IndicationVector;

typedef std::map<QString, Track*> TrackMap;
typedef std::map<QString, Segment *> SegmentMap;
typedef std::map<QString, timeT> TimeMap;
Expand Down Expand Up @@ -108,7 +73,34 @@ class MusicXMLImportHelper {
void setInstrument(InstrumentId instrument);
void setBracketType(int bracket);

protected:
private:

class IndicationStart {
public:
IndicationStart(const QString &staff="", const QString &voice="",
const std::string &name="", timeT time=0, int number=1,
const std::string &endName="") :
m_staff(staff),
m_voice(voice),
m_name(name),
m_endName((endName == "") ? name : endName),
m_time(time),
m_number(number)
{
};
QString m_staff;
QString m_voice;
std::string m_name;
std::string m_endName;
timeT m_time{};
int m_number{1};
};
//struct IndicationCMP {
// bool operator()(const IndicationStart &a, const IndicationStart &b) {
// return true;
// };
//};

Composition *m_composition;
VoiceMap m_mainVoice;
QString m_staff;
Expand All @@ -118,11 +110,14 @@ class MusicXMLImportHelper {

timeT m_curTime;
int m_divisions;
typedef std::vector<IndicationStart> IndicationVector;
IndicationVector m_indications;
PercussionMap m_unpitched;

QString m_label;
};


}


#endif

0 comments on commit 9bfedf8

Please sign in to comment.