MuseScore  3.4
Music composition and notation
mxmlwriter.h
Go to the documentation of this file.
1 //=============================================================================
2 // BWW to MusicXML converter
3 // Part of MusE Score
4 // Linux Music Score Editor
5 //
6 // Copyright (C) 2010 Werner Schweer and others
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License version 2.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //=============================================================================
20 
21 #ifndef MXMLWRITER_H
22 #define MXMLWRITER_H
23 
29 #include <QtCore/QMap>
30 #include <QtCore/QString>
31 #include <QtCore/QTextStream>
32 
33 #include "writer.h"
34 
35 class QIODevice;
36 
37 namespace Bww {
38 
43  class MxmlWriter : public Writer
44  {
45  public:
46  MxmlWriter();
47  void beginMeasure(const Bww::MeasureBeginFlags mbf);
48  void endMeasure(const Bww::MeasureEndFlags mef);
49  void header(const QString title, const QString type,
50  const QString composer, const QString footer,
51  const unsigned int temp);
52  void note(const QString pitch, const QVector<BeamType> beamList,
53  const QString type, const int dots,
54  bool tieStart = false, bool tieStop = false,
55  StartStop triplet = ST_NONE,
56  bool grace = false);
57  void setOutDevice(QIODevice *outDevice) { out.setDevice(outDevice); }
58  void tsig(const int beats, const int beat);
59  void trailer();
60  private:
61  int wholeDur() const { return 3 * 64; }
62  struct StepAlterOct {
63  QChar s;
64  int a;
65  int o;
66  StepAlterOct(QChar step = 'C', int alter = 0, int oct = 1)
67  : s(step), a(alter), o(oct) {};
68  };
69  QTextStream out;
70  int beats;
71  int beat;
72  QMap<QString, StepAlterOct> stepAlterOctMap;
73  QMap<QString, QString> typeMap;
74  unsigned int regularMeasureNumber;
75  unsigned int irregularMeasureNumber;
76  unsigned int tempo;
77  unsigned int ending;
78  };
79 
80 } // namespace Bww
81 
82 #endif // MXMLWRITER_H
unsigned int irregularMeasureNumber
Current irregular measure number.
Definition: mxmlwriter.h:75
int beats
Number of beats.
Definition: mxmlwriter.h:70
The writer that generates MusicXML output.
Definition: mxmlwriter.h:43
MxmlWriter()
MxmlWriter constructor.
Definition: mxmlwriter.cpp:36
QChar s
< MusicXML step/alter/oct values
Definition: mxmlwriter.h:63
QMap< QString, StepAlterOct > stepAlterOctMap
Map bww pitch to step/alter/oct.
Definition: mxmlwriter.h:72
int wholeDur() const
Whole note duration.
Definition: mxmlwriter.h:61
void endMeasure(const Bww::MeasureEndFlags mef)
End the current measure.
Definition: mxmlwriter.cpp:149
void tsig(const int beats, const int beat)
Store beats and beat type for later use.
Definition: mxmlwriter.cpp:332
int beat
Beat type.
Definition: mxmlwriter.h:71
unsigned int tempo
Tempo (0 = not specified)
Definition: mxmlwriter.h:76
The flags that need to be handled at the beginning of a measure.
Definition: writer.h:53
Symbol type to text translation.
Definition: lexer.cpp:34
unsigned int ending
Current ending.
Definition: mxmlwriter.h:77
unsigned int regularMeasureNumber
Current regular measure number.
Definition: mxmlwriter.h:74
The flags that need to be handled at the end of a measure.
Definition: writer.h:72
void beginMeasure(const Bww::MeasureBeginFlags mbf)
Begin a new measure.
Definition: mxmlwriter.cpp:68
void setOutDevice(QIODevice *outDevice)
Definition: mxmlwriter.h:57
QTextStream out
The output text stream.
Definition: mxmlwriter.h:69
Definition: symbols.h:53
StepAlterOct(QChar step='C', int alter=0, int oct=1)
Definition: mxmlwriter.h:66
void header(const QString title, const QString type, const QString composer, const QString footer, const unsigned int temp)
Write the header.
Definition: mxmlwriter.cpp:278
int a
Definition: mxmlwriter.h:64
Definition of class Writer.
StartStop
Definition: symbols.h:51
int o
Definition: mxmlwriter.h:65
Definition: mxmlwriter.h:62
The writer that generates the output.
Definition: writer.h:91
QMap< QString, QString > typeMap
Map bww note types to MusicXML.
Definition: mxmlwriter.h:73
void trailer()
Write the trailer.
Definition: mxmlwriter.cpp:347
void note(const QString pitch, const QVector< BeamType > beamList, const QString type, const int dots, bool tieStart=false, bool tieStop=false, StartStop triplet=ST_NONE, bool grace=false)
Write a single note.
Definition: mxmlwriter.cpp:187