Skip to content

Commit

Permalink
Merge pull request rism-digital#3800 from martha-thomae/scoringup_branch
Browse files Browse the repository at this point in the history
Scoring up implementation as functor
  • Loading branch information
lpugin authored Feb 6, 2025
2 parents 4528635 + 39fc769 commit cb7bfaf
Show file tree
Hide file tree
Showing 10 changed files with 914 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,11 @@
8F7DD0551EAF3682001B072A /* fb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F7DD0531EAF3682001B072A /* fb.cpp */; };
8F7DD0561EAF3682001B072A /* fb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F7DD0531EAF3682001B072A /* fb.cpp */; };
8F7DD0571EAF3682001B072A /* fb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F7DD0531EAF3682001B072A /* fb.cpp */; };
B464F48F2C6D664300A778D2 /* scoringupfunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */; };
B464F4902C6D664300A778D2 /* scoringupfunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */; };
B464F4912C6D664300A778D2 /* scoringupfunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */; };
B464F4932C6D665300A778D2 /* scoringupfunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = B464F4922C6D665300A778D2 /* scoringupfunctor.h */; };
B464F4942C6D665300A778D2 /* scoringupfunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = B464F4922C6D665300A778D2 /* scoringupfunctor.h */; };
BB4C4A5A22A9318B001F6AF0 /* humlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40CA06581E351161009CFDD7 /* humlib.cpp */; };
BB4C4A5B22A9318E001F6AF0 /* humlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 40CA064C1E351125009CFDD7 /* humlib.h */; settings = {ATTRIBUTES = (Public, ); }; };
BB4C4A8822A93225001F6AF0 /* c_wrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DD11DC22240E78B00A405D8 /* c_wrapper.cpp */; };
Expand Down Expand Up @@ -2230,6 +2235,8 @@
8F59293218854BF800FE51AD /* vrv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vrv.h; path = include/vrv/vrv.h; sourceTree = "<group>"; };
8F59293318854BF800FE51AD /* vrvdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vrvdef.h; path = include/vrv/vrvdef.h; sourceTree = "<group>"; };
8F7DD0531EAF3682001B072A /* fb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fb.cpp; path = src/fb.cpp; sourceTree = "<group>"; };
B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scoringupfunctor.cpp; path = src/scoringupfunctor.cpp; sourceTree = "<group>"; };
B464F4922C6D665300A778D2 /* scoringupfunctor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scoringupfunctor.h; path = include/vrv/scoringupfunctor.h; sourceTree = "<group>"; };
BB4C4A5222A930A3001F6AF0 /* VerovioFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VerovioFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BB4C4A5522A930A3001F6AF0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = bindings/iOS/Info.plist; sourceTree = SOURCE_ROOT; };
BB4C4BCA22A941F9001F6AF0 /* data */ = {isa = PBXFileReference; lastKnownFileType = folder; path = data; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -3108,6 +3115,8 @@
E765675628BBF9CD00BC6490 /* functors */ = {
isa = PBXGroup;
children = (
B464F4922C6D665300A778D2 /* scoringupfunctor.h */,
B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */,
E786CD09298AA3BC009BAC58 /* horizontal-layout */,
E786CD0A298AA3D8009BAC58 /* vertical-layout */,
E7908EA12985829F0004C1F9 /* alignfunctor.cpp */,
Expand Down Expand Up @@ -3318,6 +3327,7 @@
8F59294218854BF800FE51AD /* iopae.h in Headers */,
8F59294318854BF800FE51AD /* keysig.h in Headers */,
403B0514244F3E4D00EE4F71 /* gliss.h in Headers */,
B464F4932C6D665300A778D2 /* scoringupfunctor.h in Headers */,
E741ACFF299A3D3400854426 /* calcslurdirectionfunctor.h in Headers */,
4DEF8A6221B7AACC0093A76B /* f.h in Headers */,
4DACC9DE2990F29A00B55913 /* atts_performance.h in Headers */,
Expand Down Expand Up @@ -3650,6 +3660,7 @@
BB4C4ACA22A932B6001F6AF0 /* pages.h in Headers */,
BB4C4ACC22A932B6001F6AF0 /* pb.h in Headers */,
BB4C4B1222A932C8001F6AF0 /* expansion.h in Headers */,
B464F4942C6D665300A778D2 /* scoringupfunctor.h in Headers */,
BB4C4AC822A932B6001F6AF0 /* page.h in Headers */,
4DACC9952990F29A00B55913 /* atts_neumes.h in Headers */,
4DACC9CF2990F29A00B55913 /* atts_mei.h in Headers */,
Expand Down Expand Up @@ -4286,6 +4297,7 @@
4DB3D89E1F7E7FAA00B5FC2B /* fig.cpp in Sources */,
4D1AC9772B6A9BB200434023 /* filereader.cpp in Sources */,
4D4FCD121F54570E0009C455 /* staffdef.cpp in Sources */,
B464F48F2C6D664300A778D2 /* scoringupfunctor.cpp in Sources */,
8F086EE2188539540037FD8E /* verticalaligner.cpp in Sources */,
4DEC4D9621C81E3B00D1D273 /* expan.cpp in Sources */,
4D508C3026D4E64C00020F35 /* crc.cpp in Sources */,
Expand Down Expand Up @@ -4757,6 +4769,7 @@
4D6413802035F68600BB630E /* mdiv.cpp in Sources */,
4D766F0320ACAD6E006875D8 /* neume.cpp in Sources */,
4DACC9C22990F29A00B55913 /* atts_cmn.cpp in Sources */,
B464F4902C6D664300A778D2 /* scoringupfunctor.cpp in Sources */,
4D94722120CA702C00C780C8 /* linkinginterface.cpp in Sources */,
4DACCA152990F2E600B55913 /* att.cpp in Sources */,
4DB3D8EB1F83D18000B5FC2B /* proport.cpp in Sources */,
Expand Down Expand Up @@ -5050,6 +5063,7 @@
4DACC9C32990F29A00B55913 /* atts_cmn.cpp in Sources */,
BB4C4AEB22A932BC001F6AF0 /* editorial.cpp in Sources */,
BB4C4B8F22A932DF001F6AF0 /* text.cpp in Sources */,
B464F4912C6D664300A778D2 /* scoringupfunctor.cpp in Sources */,
4DACCA162990F2E600B55913 /* att.cpp in Sources */,
BB4C4ADF22A932BC001F6AF0 /* annot.cpp in Sources */,
E79ADDCA26BD645B00527E4B /* runtimeclock.cpp in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions include/vrv/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ class Doc : public Object {
void ConvertMarkupDoc(bool permanent = true);

/**
* Calls the scoringUpFunctor and applies it.
*/
void ScoringUpDoc();

/*
* Convert the doc from mensural to a flattened version with no ligatures and the selected editorial markup.
*/
void ConvertToMensuralViewDoc();
Expand Down
1 change: 1 addition & 0 deletions include/vrv/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ class Options {

OptionIntMap m_durationEquivalence;
OptionBool m_ligatureAsBracket;
OptionBool m_mensuralScoreUp;
OptionBool m_mensuralResponsiveView;
OptionBool m_mensuralToCmn;

Expand Down
127 changes: 127 additions & 0 deletions include/vrv/scoringupfunctor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/////////////////////////////////////////////////////////////////////////////
// Name: scoringupfunctor.h
// Author: Martha E. M. Thomae Elias
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
///
#ifndef __VRV_SCORINGUPFUNCTOR_H__
#define __VRV_SCORINGUPFUNCTOR_H__

#include "functor.h"

namespace vrv {

//----------------------------------------------------------------------------
// ScoringUpFunctor
//----------------------------------------------------------------------------

/**
* This class...
*/
class ScoringUpFunctor : public Functor {
public:
/**
* @name Constructors, destructors
*/
///@{
ScoringUpFunctor();
virtual ~ScoringUpFunctor() = default;
///@}

/*
* Abstract base implementation
*/
bool ImplementsEndInterface() const override { return true; }

/*
* Methods
*/
/**
* @name: Divide the notes of a voice into sequences to be processed individualy
*/
///@{
void ProcessPerfectMensurPassage(
const ArrayOfElementDurPairs &m_dursInVoiceWithSameMensur, data_DURATION noteLevel);
std::vector<ArrayOfElementDurPairs> SubdivideIntoBoundedSequences(
const ArrayOfElementDurPairs &dursInVoiceSameMensur, data_DURATION boundUnit);
void ProcessBoundedSequences(const std::vector<ArrayOfElementDurPairs> &listOfSequences, data_DURATION boundUnit);
void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
///@}

/**
* @name: Apply the principles of imperfection and alteration (find @dur.quality of notes: perfecta / imperfecta /
* altera) for sequences with or without dots of division
*/
///@{
bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd,
data_DURATION unit);
void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit, data_DURATION boundUnit);
///@}

/**
* @name: Find the duration value of the note in minims or another given unit
*/
///@{
double GetDurNumberValue(
const std::pair<LayerElement *, data_DURATION> &elementDurPair, bool followedByDot, LayerElement *nextElement);
double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq);
double GetValueInUnit(double valueInMinims, data_DURATION unit);
///@}

/**
* @name Apply the modifications of imperfection and alteration or leaves the notes with their default perfect value
*/
///@{
Note *ImperfectionAPP(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
Note *ImperfectionAPA(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
Note *Alteration(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
bool LeavePerfect(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit);
void ApplyAugmentationsAndPerfections();
///@}

/*
* Functor interface
*/
///@{
FunctorCode VisitLayerEnd(Layer *layer) override;
FunctorCode VisitLayerElement(LayerElement *layerElement) override;
///@}
///

protected:
//
private:
//

public:
//

private:
// The current score time in the measure (incremented by each element)
double m_currentScoreTime;
// The current Mensur
Mensur *m_currentMensur;
int m_modusMaior;
int m_modusMinor;
int m_tempus;
int m_prolatio;
std::tuple<int, int, int, int> m_mensurAsTuplet;
// The data of each voice in the form of an array of pairs made up of 'mensuration' {m_modusMaior, m_modusMinor,
// m_tempus, m_prolatio} and the notes/rests/dots in that voice that follows that mensuration
// (m_dursInVoiceWithSameMensur)
std::vector<std::pair<std::tuple<int, int, int, int>, ArrayOfElementDurPairs>> m_voiceData;
// Vector of pairs of elements (that are notes, rests, or dots) and their durations
ArrayOfElementDurPairs m_dursInVoiceWithSameMensur;
// Vector of vectors of pairs of elements (that are notes, rests, or dots) and their durations
std::vector<ArrayOfElementDurPairs> m_listOfSequences;
// List of pairs made of the form {note, following_dot} for notes followed by dots of augmentation
std::list<std::pair<Note *, Dot *>> m_listOfAugNotesDotsPairs;
// List of pairs made of the form {note, following_dot} for notes followed by dots of perfection
std::list<std::pair<Note *, Dot *>> m_listOfPerfNotesDotsPairs;
};

} // namespace vrv

#endif /* scoringupfunctor_h */
2 changes: 2 additions & 0 deletions include/vrv/vrvdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ typedef std::vector<std::pair<LayerElement *, LayerElement *>> MeasureTieEndpoin

typedef bool (*NotePredicate)(const Note *);

typedef std::vector<std::pair<LayerElement *, data_DURATION>> ArrayOfElementDurPairs;

/**
* Generic int map recursive structure for storing hierachy of values
* For example, we want to process all staves one by one, and within each staff
Expand Down
7 changes: 7 additions & 0 deletions src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "resetfunctor.h"
#include "runningelement.h"
#include "score.h"
#include "scoringupfunctor.h"
#include "setscoredeffunctor.h"
#include "slur.h"
#include "smufl.h"
Expand Down Expand Up @@ -1461,6 +1462,12 @@ void Doc::ConvertMarkupDoc(bool permanent)
}
}

void Doc::ScoringUpDoc()
{
ScoringUpFunctor scoringUp;
this->Process(scoringUp);
}

void Doc::ConvertToMensuralViewDoc()
{
if (this->IsCastOff()) {
Expand Down
2 changes: 1 addition & 1 deletion src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ Mensur *Layer::GetCurrentMensur()
const Mensur *Layer::GetCurrentMensur() const
{
const Staff *staff = vrv_cast<const Staff *>(this->GetFirstAncestor(STAFF));
assert(staff && staff->m_drawingStaffDef);
// assert(staff && staff->m_drawingStaffDef);
return staff->m_drawingStaffDef->GetCurrentMensur();
}

Expand Down
5 changes: 5 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,11 @@ Options::Options()
m_mensuralToCmn.Init(false);
this->Register(&m_mensuralToCmn, "mensuralToCmn", &m_mensural);

m_mensuralScoreUp.SetInfo(
"Mensural scoring up", "Score up the mensural voices by providing a dur.quality to the notes");
m_mensuralScoreUp.Init(false);
this->Register(&m_mensuralScoreUp, "mensuralScoreUp", &m_mensural);

/********* Method JSON options to the command-line *********/

m_jsonCmdLineOptions.SetLabel("Method JSON options for the command-line", "7-methodJson");
Expand Down
Loading

0 comments on commit cb7bfaf

Please sign in to comment.