Skip to content

Commit

Permalink
Adding chords, tuplets and staff changes begin and end detection to m…
Browse files Browse the repository at this point in the history
…xsr2msr, phase 1
  • Loading branch information
jacques-menu committed Nov 4, 2024
1 parent 60c696a commit 97021a9
Show file tree
Hide file tree
Showing 45 changed files with 3,703 additions and 1,229 deletions.
2 changes: 1 addition & 1 deletion MusicFormatsVersionDate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
October 22, 2024
November 4, 2024
2 changes: 1 addition & 1 deletion documentation/FOO/mfmgPartgroupshandling.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ \chapter{Part groups handling}\label{Part groups handling}

In \mxml, part groups can overlap, even though no one seems ever to have needed that. That seems to be more a feature in the Finale handling of \mxml export that a true musical need.

\msrRepr\ does not support overlapping part group. Handling part groups is done in \mxsrToMsrBoth{mxsr2msrTranslator.h}, where overlapping groups are identified and rejected:
\msrRepr\ does not support overlapping part group. Handling part groups is done in \mxsrToMsrBoth{mxsr2msrSkeletonPopulator.h}, where overlapping groups are identified and rejected:
\begin{lstlisting}[language=Terminal]
jacquesmenu@macmini > xml2ly partgroups/OverlappingPartGroups.xml
### MusicXML ERROR ### partgroups/OverlappingPartGroups.xml:169:
Expand Down
2 changes: 1 addition & 1 deletion include/MusicFormatsVersionDate.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define MUSICFORMATS_VERSION_DATE "October 22, 2024"
#define MUSICFORMATS_VERSION_DATE "November 4, 2024"
2 changes: 2 additions & 0 deletions include/mflibrary/mfTraceOah.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,12 +920,14 @@ class EXP traceOahGroup : public oahGroup
// staff changes
// --------------------------------------

Bool fTraceStaffChangesBasics;
Bool fTraceStaffChanges;


// voices
// --------------------------------------

Bool fTraceVoiceBasics;
Bool fTraceVoices;
Bool fTraceVoicesDetails;

Expand Down
218 changes: 215 additions & 3 deletions include/passes/mxsr2msr/mxsr2msrSkeletonBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

#include "typedefs.h"

#include "mxsrNotesEvents.h"
#include "msrPartGroups.h"
#include "msrPrintObjects.h"
#include "msrTupletsEnumTypes.h"


namespace MusicFormats
Expand Down Expand Up @@ -319,6 +321,139 @@ typedef SMARTP<mxsrPartGroupsStack> S_mxsrPartGroupsStack;
EXP std::ostream& operator << (std::ostream& os, const mxsrPartGroupsStack& elt);
EXP std::ostream& operator << (std::ostream& os, const S_mxsrPartGroupsStack& elt);

//________________________________________________________________________
// class mxsr2msrVoiceHandler : public smartable
// {
// /*
// positions represent the order in which the parts appear in <part-list />,
// starting at 0 since std::vectors are used
// */
//
// public:
//
// // creation
// // ------------------------------------------------------
//
// static SMARTP<mxsr2msrVoiceHandler> create (
// const S_msrVoice& voice);
//
// protected:
//
// // constructors/destructor
// // ------------------------------------------------------
//
// mxsr2msrVoiceHandler (
// const S_msrVoice& fMsrVoice);
//
// virtual ~mxsr2msrVoiceHandler ();
//
// public:
//
// // set and get
// // ------------------------------------------------------
//
// S_msrVoice getMsrVoice () const
// { return fMsrVoice; }
//
// const std::list<S_msrTuplet>&
// getTupletsStack () const
// { return fTupletsStack; }
//
// const std::size_t getTupletsStackSize () const
// { return fTupletsStack.size (); }
//
// const S_msrTuplet getTupletsStackTop () const
// { return fTupletsStack.front (); }
//
// void setLastMetNoteInVoice (S_msrNote note)
// { fLastMetNoteInVoice = note; }
//
// S_msrNote getLastMetNoteInVoice () const
// { return fLastMetNoteInVoice; }
//
// public:
//
// // public services
// // ------------------------------------------------------
//
// void pushTupletOntoTupletsStack (const S_msrTuplet& tuplet)
// { fTupletsStack.push_front (tuplet); }
//
// // void handleTupletStartByHandler (
// // const S_msrTuplet& tuplet,
// // const S_msrVoice& currentNoteVoice);
// //
// // void handleTupletContinueByHandler (
// // const S_msrNote& note,
// // const S_msrVoice& currentNoteVoice);
// //
// // void handleTupletStopByHandler (
// // const S_msrNote& note,
// // const S_msrVoice& currentNoteVoice);
//
// void finalizeTupletStackTopAndPopItFromTupletsStack (
// int inputLineNumber,
// std::string context);
//
// public:
//
// // print
// // ------------------------------------------------------
//
// std::string asString () const;
//
// virtual void print (std::ostream& os) const;
//
// private:
//
// // private fields
// // ------------------------------------------------------
//
//
// S_msrVoice fMsrVoice;
//
// S_msrNote fLastMetNoteInVoice;
//
// std::list<S_msrTuplet>
// fTupletsStack;
//
// S_msrNote fCurrentOuterMostTupletFirstNote;
// S_msrTuplet fCurrentOuterMostTuplet;
//
// msrWholeNotes fCurrentOuterMostTupletRelativeOffset;
//
// private:
//
// // private work fields
// // ------------------------------------------------------
//
// // we use a pair containing the staff and voice numbers: JMI v0.9.70
// // std::map<S_msrVoice, S_msrTuplet>
// // std::map<std::pair<int, int>, S_msrTuplet>
// // fLastHandledTupletInVoiceMap;
//
// // // the tuplets stops are not always in first-in/first-out order, so:
// // std::set<int> fExpectedTupletsStopNumbersSet;
//
// private:
//
// // private methods
// // ------------------------------------------------------
//
// void displayTupletsStack (
// const std::string& context);
//
// void handleTupletsPendingOnTupletsStack (
// int inputLineNumber);
//
// void displayLastHandledTupletInVoiceMap (
// const std::string& header);
// };
// typedef SMARTP<mxsr2msrVoiceHandler> S_mxsr2msrVoiceHandler;
//
// EXP std::ostream& operator << (std::ostream& os, const mxsr2msrVoiceHandler& elt);
// EXP std::ostream& operator << (std::ostream& os, const S_mxsr2msrVoiceHandler& elt);

//________________________________________________________________________
class EXP mxsr2msrSkeletonBuilder :

Expand Down Expand Up @@ -425,6 +560,16 @@ class EXP mxsr2msrSkeletonBuilder :

public visitor<S_note>,

// chords
// ------------------------------------------------------

public visitor<S_chord>,

// tuplets
// ------------------------------------------------------

public visitor<S_tuplet>,

// lyrics
// ------------------------------------------------------

Expand All @@ -446,7 +591,9 @@ class EXP mxsr2msrSkeletonBuilder :
// constructors/destructor
// ------------------------------------------------------

mxsr2msrSkeletonBuilder ();
mxsr2msrSkeletonBuilder (
mxsrScoreNotesEvents&
theResultingScoreNotesEvents);

virtual ~mxsr2msrSkeletonBuilder ();

Expand Down Expand Up @@ -592,6 +739,19 @@ class EXP mxsr2msrSkeletonBuilder :
virtual void visitStart (S_note& elt);
virtual void visitEnd (S_note& elt);

// chords
// ------------------------------------------------------

virtual void visitStart (S_chord& elt);
virtual void visitEnd (S_chord& elt);

// tuplets
// ------------------------------------------------------

virtual void visitStart (S_tuplet& elt);

virtual void visitStart (S_time_modification& elt);

// lyrics
// ------------------------------------------------------

Expand All @@ -618,6 +778,12 @@ class EXP mxsr2msrSkeletonBuilder :
S_msrScore fMsrScore;


// the score notes events we shall collect for mxsr2msrSkeletonPopulator
// ------------------------------------------------------

mxsrScoreNotesEvents& fResultingScoreNotesEvents;


// credits handling
// ------------------------------------------------------

Expand Down Expand Up @@ -769,8 +935,6 @@ class EXP mxsr2msrSkeletonBuilder :
// staff handling
// ------------------------------------------------------

int fCurrentStaffMusicXMLNumber; // used throughout

S_msrStaff createStaffInCurrentPartIfNotYetDone (
int inputLineNumber,
int staffNumber);
Expand Down Expand Up @@ -807,10 +971,58 @@ class EXP mxsr2msrSkeletonBuilder :
Bool fOnGoingPrint;


// notes handling
// ------------------------------------------------------

int fCurrentNoteSequentialNumber;

int fCurrentNoteStartInputLine;
int fCurrentNoteEndInputLine;

int fPreviousNoteStartInputLine;
int fPreviousNoteEndInputLine;

int fCurrentNoteStaffNumber; // used throughout
int fPreviousNoteStaffNumber;

int fCurrentNoteVoiceNumber; // used throughout
int fPreviousNoteVoiceNumber;

/*
/Users/jacquesmenu/musicformats-git-dev/src/passes/mxsr2msr/mxsr2msrSkeletonBuilder.h:989:31: warning: private field 'fCurrentNoteVoiceNumber' is not used [-Wunused-private-field]
989 | int fCurrentNoteVoiceNumber; // used throughout
| ^
/Users/jacquesmenu/musicformats-git-dev/src/passes/mxsr2msr/mxsr2msrSkeletonBuilder.h:990:31: warning: private field 'fPreviousNoteVoiceNumber' is not used [-Wunused-private-field]
990 | int fPreviousNoteVoiceNumber;
| ^
*/

Bool fOnGoingNote;

// chords handling
// ------------------------------------------------------

Bool fCurrentNoteBelongsToAChord;
Bool fPreviousNoteBelongsToAChord;

// Bool fOnGoingChord; // JMI v0.9.71

// tuplets handling
// ------------------------------------------------------

// nested tuplets are numbered 1, 2, ...
int fCurrentTupletNumber;
int fPreviousTupletNumber;

msrTupletTypeKind fCurrentTupletTypeKind;

Bool fCurrentNoteBelongsToATuplet;

// a tuplet stop may occur in a chord before the latter's last note, hence:
Bool fThereIsAPendingTupletStop; // CHORD_TUP

// Bool fOnGoingTuplet; // JMI v0.9.71


// lyrics handling
// ------------------------------------------------------
Expand Down
11 changes: 7 additions & 4 deletions include/passes/mxsr2msr/mxsr2msrSkeletonBuilderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
#ifndef ___mxsr2msrSkeletonBuilderInterface___
#define ___mxsr2msrSkeletonBuilderInterface___

#include "mxsr2msrSkeletonBuilder.h"


namespace MusicFormats
{

//_______________________________________________________________________________
EXP S_msrScore translateMxsrToMsrSkeleton (
const Sxmlelement& theMxsr,
const S_msrOahGroup& msrOpts,
mfPassIDKind passIDKind,
const std::string& passDescription);
const Sxmlelement& theMxsr,
mxsrScoreNotesEvents& theResultingScoreNotesEvents,
const S_msrOahGroup& msrOpts,
mfPassIDKind passIDKind,
const std::string& passDescription);

//_______________________________________________________________________________
// EXP void displayMsrScoreSkeleton ( // UNUSED JMI v0.9.66
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "msrDivisions.h"
#include "msrDoubleTremolos.h"
#include "msrGlissandos.h"
#include "mxsrNotesEvents.h"
#include "msrRehearsalMarks.h"
#include "msrSlides.h"
#include "msrTablatures.h"
Expand Down Expand Up @@ -170,7 +171,7 @@ EXP std::ostream& operator << (std::ostream& os, const mxsr2msrVoiceHandler& elt
EXP std::ostream& operator << (std::ostream& os, const S_mxsr2msrVoiceHandler& elt);

//________________________________________________________________________
class EXP mxsr2msrTranslator :
class EXP mxsr2msrSkeletonPopulator :

// MXSR score partwise
// ------------------------------------------------------
Expand Down Expand Up @@ -680,10 +681,12 @@ class EXP mxsr2msrTranslator :
// constructors/destructor
// ------------------------------------------------------

mxsr2msrTranslator (
const S_msrScore& scoreSkeleton);
mxsr2msrSkeletonPopulator (
const S_msrScore& scoreSkeleton,
mxsrScoreNotesEvents&
theKnownScoreNotesEvents);

virtual ~mxsr2msrTranslator ();
virtual ~mxsr2msrSkeletonPopulator ();

// set and get
// ------------------------------------------------------
Expand Down Expand Up @@ -1260,6 +1263,12 @@ class EXP mxsr2msrTranslator :
S_msrScore fMsrScore;


// the score notes events we know from mxsr2msrSkeletonBuilder
// ------------------------------------------------------

mxsrScoreNotesEvents& fKnownScoreNotesEvents;


// part handling
// ------------------------------------------------------

Expand Down Expand Up @@ -2528,7 +2537,7 @@ class EXP mxsr2msrTranslator :
Bool fCurrentNoteBelongsToATuplet;

// a tuplet stop may occur in a chord before the latter's last note, hence:
Bool fThereIsAPendingTupletStop;
Bool fThereIsAPendingTupletStop; // CHORD_TUP
S_msrNote fNoteWithThePendingTupletStop;
S_msrVoice fVoiceOfTheNoteWithThePendingTupletStop;

Expand Down
Loading

0 comments on commit 97021a9

Please sign in to comment.