Dear list.
I found a problem in Export to Music XML. This can be demonstrated by a simple
example. Make a track with just 4 notes in key C major. The notes are B, B#,
A# and Cb.
When you export this to a Music XML file and read it into a tool like mscore
you see B, C, B# and B. The B# becomes C and Cb becomes B which looks strange
but is correct. However, the A# becomes a B# which definite wrong.
This could be corrected in MusicXmlExporter.cpp by replacing
long p = 0;
e->get<Int>(PITCH, p);
pitch = p;
by
pitch = Pitch(*e);
Now the accidentals are correct but B# is displayed one octave too high and
the Cb one octave too low. This is caused by Pitch::getOctave(). This method
doesn't take care of any accidentals.
This is solved by introducing a new method Pitch::getOctaveAccidental().
After some testing I saw the Export to MUP shows a similar problem which could
also be solved by replacing Pitch::getOctave() by the new
Pitch::getOctaveAccidental().
The attached patch solved both problem in both MUP and MusicXML exporter.
Now I have spent some time looking at MusicXmlExporter I found a lot of
features are missing. Is somebody working on this or should it be a nice task
for me?
Best regards,
Niek.
Index: src/base/NotationTypes.h
===================================================================
--- src/base/NotationTypes.h (revision 12290)
+++ src/base/NotationTypes.h (working copy)
@@ -923,6 +923,13 @@
int getOctave(int octaveBase = -2) const;
/**
+ * Return the octave containing this pitch, including the accidentals.
+ * The octaveBase argument specifies the octave containing MIDI pitch 0;
+ * middle-C is in octave octaveBase + 5.
+ */
+ int getOctaveAccidental(int octaveBase = -2, Accidental acc = Accidentals::NoAccidental) const;
+
+ /**
* Return the pitch within the octave, in the range 0 to 11.
*/
int getPitchInOctave() const;
Index: src/base/NotationTypes.cpp
===================================================================
--- src/base/NotationTypes.cpp (revision 12290)
+++ src/base/NotationTypes.cpp (working copy)
@@ -1695,6 +1695,22 @@
return m_pitch / 12 + octaveBase;
}
+int
+Pitch::getOctaveAccidental(int octaveBase, Accidental acc) const
+{
+ int t_pitch = m_pitch;
+ if (acc == Accidentals::DoubleFlat) {
+ t_pitch += 2;
+ } else if (acc == Accidentals::Flat) {
+ t_pitch += 1;
+ } else if (acc == Accidentals::Sharp) {
+ t_pitch -= 1;
+ } else if (acc == Accidentals::DoubleSharp) {
+ t_pitch -= 2;
+ }
+ return t_pitch / 12 + octaveBase;
+}
+
int
Pitch::getPitchInOctave() const
{
Index: src/document/io/MupExporter.cpp
===================================================================
--- src/document/io/MupExporter.cpp (revision 12290)
+++ src/document/io/MupExporter.cpp (working copy)
@@ -410,7 +410,7 @@
Pitch p(pitch, accidental);
Accidental acc(p.getDisplayAccidental(ck.second));
char note(p.getNoteName(ck.second));
- int octave(p.getOctave());
+ int octave(p.getOctaveAccidental(-2, acc));
// just to avoid assuming that the note names returned by Pitch are in
// the same set as those expected by Mup -- in practice they are the same
Index: src/document/io/MusicXmlExporter.cpp
===================================================================
--- src/document/io/MusicXmlExporter.cpp (revision 12290)
+++ src/document/io/MusicXmlExporter.cpp (working copy)
@@ -100,9 +100,7 @@
str << "\t\t\t\t<pitch>" << std::endl;
- long p = 0;
- e->get<Int>(PITCH, p);
- pitch = p;
+ pitch = Pitch(*e);
str << "\t\t\t\t\t<step>" << pitch.getNoteName(key) << "</step>" << std::endl;
@@ -128,7 +126,7 @@
str << "\t\t\t\t\t<alter>2</alter>" << std::endl;
}
- int octave = pitch.getOctave( -1);
+ int octave = pitch.getOctaveAccidental(-1, acc);
str << "\t\t\t\t\t<octave>" << octave << "</octave>" << std::endl;
str << "\t\t\t\t</pitch>" << std::endl;
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@lists.sourceforge.net - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel