From c98e2edf6b1ba261312ad15ca98291f9decdee3f Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 15 Aug 2024 00:35:59 +0200 Subject: [PATCH 01/88] Add header and source for scoringup functor and call them in doc - scoringupfunctor is based on midifunctor - scoringupfunctor header has an abstract base implementation, which allows for line 1395 in doc.cpp to not give the error of 'ScoringUpFunctor is an abstract class' --- Verovio.xcodeproj/project.pbxproj | 14 +++++++ include/vrv/doc.h | 5 +++ include/vrv/scoringupfunctor.h | 68 +++++++++++++++++++++++++++++++ src/doc.cpp | 7 ++++ src/scoringupfunctor.cpp | 59 +++++++++++++++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 include/vrv/scoringupfunctor.h create mode 100644 src/scoringupfunctor.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 0f0b7a4035..24c3e6ab27 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -1054,6 +1054,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 */; }; @@ -2198,6 +2203,8 @@ 8F59293218854BF800FE51AD /* vrv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vrv.h; path = include/vrv/vrv.h; sourceTree = ""; }; 8F59293318854BF800FE51AD /* vrvdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vrvdef.h; path = include/vrv/vrvdef.h; sourceTree = ""; }; 8F7DD0531EAF3682001B072A /* fb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fb.cpp; path = src/fb.cpp; sourceTree = ""; }; + B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scoringupfunctor.cpp; path = src/scoringupfunctor.cpp; sourceTree = ""; }; + B464F4922C6D665300A778D2 /* scoringupfunctor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scoringupfunctor.h; path = include/vrv/scoringupfunctor.h; sourceTree = ""; }; 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; }; @@ -3068,6 +3075,8 @@ E765675628BBF9CD00BC6490 /* functors */ = { isa = PBXGroup; children = ( + B464F4922C6D665300A778D2 /* scoringupfunctor.h */, + B464F48E2C6D664300A778D2 /* scoringupfunctor.cpp */, E786CD09298AA3BC009BAC58 /* horizontal-layout */, E786CD0A298AA3D8009BAC58 /* vertical-layout */, E7908EA12985829F0004C1F9 /* alignfunctor.cpp */, @@ -3278,6 +3287,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 */, @@ -3604,6 +3614,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 */, @@ -4233,6 +4244,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 */, @@ -4697,6 +4709,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 */, @@ -4986,6 +4999,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 */, diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 48876eec45..841fab1ca5 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -372,6 +372,11 @@ class Doc : public Object { */ void ConvertMarkupDoc(bool permanent = true); + /** + * Calls the scoringUpFunctor and applies it. + */ + void ScoringUpDoc(); + /** * Sync the coordinate provided trought to m_drawingFacsX/Y. * Call the SyncToFacsimile functor. diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h new file mode 100644 index 0000000000..24b2000dde --- /dev/null +++ b/include/vrv/scoringupfunctor.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////// +// 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; } + + + /* + * Other methods + */ + + /* + * Functor interface + */ + ///@{ + FunctorCode VisitLayer(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; + // The current notation type + data_NOTATIONTYPE m_notationType; +}; + +} // namespace vrv + +#endif /* scoringupfunctor_h */ diff --git a/src/doc.cpp b/src/doc.cpp index 4300e41b8d..039278d4f9 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -53,6 +53,7 @@ #include "resetfunctor.h" #include "runningelement.h" #include "score.h" +#include "scoringupfunctor.h" #include "setscoredeffunctor.h" #include "slur.h" #include "smufl.h" @@ -1389,6 +1390,12 @@ void Doc::ConvertMarkupDoc(bool permanent) } } +void Doc::ScoringUpDoc() +{ + ScoringUpFunctor scoringUp; + this->Process(scoringUp); +} + void Doc::SyncFromFacsimileDoc() { PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp new file mode 100644 index 0000000000..1d101a68b8 --- /dev/null +++ b/src/scoringupfunctor.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: scoringupfunctor.cpp +// Author: Martha E. M. Thomae Elias +// Created: 2024 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// +/// +#include "scoringupfunctor.h" + +//---------------------------------------------------------------------------- + +#include "layer.h" +#include "page.h" +#include "note.h" +#include "rest.h" +#include "staff.h" +#include "system.h" +#include "vrv.h" + +//---------------------------------------------------------------------------- + +namespace vrv { + +//---------------------------------------------------------------------------- +// ScoringUpFunctor +//---------------------------------------------------------------------------- + +ScoringUpFunctor::ScoringUpFunctor() : Functor() +{ + m_currentScoreTime = 0.0; + m_currentMensur = NULL; + m_notationType = NOTATIONTYPE_cmn; +} + +FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) +{ + m_currentScoreTime = 0.0; + m_currentMensur = layer->GetCurrentMensur(); + return FUNCTOR_CONTINUE; +} + +FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) +{ + if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; + + LayerElement *element = layerElement->ThisOrSameasLink(); + Note note; + + if (element->Is(REST) || element->Is(NOTE)) { + double dur = element->GetAlignmentDuration(m_currentMensur, NULL, true, NOTATIONTYPE_mensural); + LogDebug("the dur is: ", dur); + } else if (element->Is(MENSUR)) { + this->m_currentMensur = vrv_cast(layerElement); + LogDebug("the mensur is:", m_currentMensur); + }return FUNCTOR_CONTINUE; +} + + +} // namespace vrv From 04643681434ed85134adc6449dc9c7d8339ad4e2 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 16 Aug 2024 03:27:46 +0200 Subject: [PATCH 02/88] Test ScoringUpDoc with debug messages for durs of notes and rests, and tempus for mensur. Added a provisional line in iomei.cpp 'm_doc->ScoringUpDoc()' to test the ScoringUpDoc and the related scoringup functor. Needed to remove an 'assert' in layer.cpp for things to run. And then add some debug messages for note and rests (and mensur) that are working good. --- src/iomei.cpp | 1 + src/layer.cpp | 2 +- src/scoringupfunctor.cpp | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/iomei.cpp b/src/iomei.cpp index eeb2f76348..f6a17c542c 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4044,6 +4044,7 @@ bool MEIInput::ReadDoc(pugi::xml_node root) if (success) { m_doc->ConvertToPageBasedDoc(); m_doc->ConvertMarkupDoc(!m_doc->GetOptions()->m_preserveAnalyticalMarkup.GetValue()); + m_doc->ScoringUpDoc(); } if (success && !m_hasScoreDef) { diff --git a/src/layer.cpp b/src/layer.cpp index 560e5642bb..38a2947d24 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -525,7 +525,7 @@ Mensur *Layer::GetCurrentMensur() const Mensur *Layer::GetCurrentMensur() const { const Staff *staff = vrv_cast(this->GetFirstAncestor(STAFF)); - assert(staff && staff->m_drawingStaffDef); + //assert(staff && staff->m_drawingStaffDef); return staff->m_drawingStaffDef->GetCurrentMensur(); } diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 1d101a68b8..c57a330cc5 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -44,14 +44,22 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; LayerElement *element = layerElement->ThisOrSameasLink(); - Note note; if (element->Is(REST) || element->Is(NOTE)) { - double dur = element->GetAlignmentDuration(m_currentMensur, NULL, true, NOTATIONTYPE_mensural); - LogDebug("the dur is: ", dur); + data_DURATION dur; + if (element->Is(NOTE)) { + Note *note = vrv_cast(element); + assert(note); + dur = note->GetDur(); + } else { + Rest *rest = vrv_cast(element); + assert(rest); + dur = rest->GetDur(); + } LogDebug("the dur is: ", dur); } else if (element->Is(MENSUR)) { - this->m_currentMensur = vrv_cast(layerElement); - LogDebug("the mensur is:", m_currentMensur); + Mensur *currentMensur = vrv_cast(layerElement); + data_TEMPUS tempus = currentMensur->GetTempus(); + LogDebug("the mensur is:", tempus); }return FUNCTOR_CONTINUE; } From d409a559752c365d3a64bf99c1f8648ed806c3cb Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 16 Aug 2024 03:28:37 +0200 Subject: [PATCH 03/88] Add again the private variables for mensur --- src/scoringupfunctor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c57a330cc5..adf5966685 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -57,9 +57,9 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) dur = rest->GetDur(); } LogDebug("the dur is: ", dur); } else if (element->Is(MENSUR)) { - Mensur *currentMensur = vrv_cast(layerElement); - data_TEMPUS tempus = currentMensur->GetTempus(); - LogDebug("the mensur is:", tempus); + this->m_currentMensur = vrv_cast(layerElement); + data_TEMPUS m_tempus = m_currentMensur->GetTempus(); + LogDebug("the mensur is:", m_tempus); }return FUNCTOR_CONTINUE; } From f141c9ade0a2fdc23a953517246d93b61ba3f406 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 16 Aug 2024 15:59:18 +0200 Subject: [PATCH 04/88] Test adding durquality values --- src/scoringupfunctor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index adf5966685..59872972bb 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -51,6 +51,7 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) Note *note = vrv_cast(element); assert(note); dur = note->GetDur(); + note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); From 2114a56c4c6edc8be65c62164f96ec3ed0b3da94 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 21 Aug 2024 23:13:37 +0200 Subject: [PATCH 05/88] Get a vector of data_DURATION objects for a layer Still have to fix the 'ScoringUpFunctor::GetLayerElements', probably make it a private method --- include/vrv/scoringupfunctor.h | 1 + src/scoringupfunctor.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 24b2000dde..90b3c9ddd0 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -45,6 +45,7 @@ class ScoringUpFunctor : public Functor { ///@{ FunctorCode VisitLayer(Layer *layer) override; FunctorCode VisitLayerElement(LayerElement *layerElement) override; + FunctorCode GetLayerElements(std::vector layer_children); ///@} /// diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 59872972bb..ea5352d1e1 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,6 +25,9 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- +std::vector layer_children; + + ScoringUpFunctor::ScoringUpFunctor() : Functor() { m_currentScoreTime = 0.0; @@ -36,6 +39,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) { m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); + layer_children = {}; return FUNCTOR_CONTINUE; } @@ -51,12 +55,13 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) Note *note = vrv_cast(element); assert(note); dur = note->GetDur(); - note->SetDurQuality(DURQUALITY_mensural_imperfecta); + //note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); dur = rest->GetDur(); } LogDebug("the dur is: ", dur); + layer_children.insert(layer_children.end(), dur); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); data_TEMPUS m_tempus = m_currentMensur->GetTempus(); @@ -64,5 +69,12 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) }return FUNCTOR_CONTINUE; } +FunctorCode ScoringUpFunctor::GetLayerElements(std::vector layer_children) +{ + for(data_DURATION dur: layer_children){ + LogDebug("dur is:", dur); + std::cout << dur << std::endl; + }return FUNCTOR_CONTINUE; +} } // namespace vrv From 97cf79d4f1ecfce4a12d9f0686f83f0a9a323881 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 15:55:14 +0200 Subject: [PATCH 06/88] Change to a method --- include/vrv/scoringupfunctor.h | 7 ++++--- src/scoringupfunctor.cpp | 35 +++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 90b3c9ddd0..a4b83fdc95 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -45,16 +45,17 @@ class ScoringUpFunctor : public Functor { ///@{ FunctorCode VisitLayer(Layer *layer) override; FunctorCode VisitLayerElement(LayerElement *layerElement) override; - FunctorCode GetLayerElements(std::vector layer_children); + //FunctorCode GetLayerElements(); ///@} /// protected: // private: - // + //std::vector GetLayerElementsDurQuals(data_MODUSMAIOR, data_MODUSMINOR, data_TEMPUS, data_PROLATIO, std::vector layer_children_durs); public: - // + std::vector dursInVoiceSameMensur = {}; + void findQuals(std::vector dursInVoiceSameMensur); private: // The current score time in the measure (incremented by each element) double m_currentScoreTime; diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index ea5352d1e1..7bafb8d6f4 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,8 +25,9 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -std::vector layer_children; - +//std::vector> layer_children_durs = {}; +///std::vector dursInVoiceSameMensur = {}; +///void findQuals(std::vector dursInVoiceSameMensur); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -39,7 +40,10 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) { m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); - layer_children = {}; + if (!dursInVoiceSameMensur.empty()){ + findQuals(dursInVoiceSameMensur); + dursInVoiceSameMensur = {}; //restart for next voice (layer) + } return FUNCTOR_CONTINUE; } @@ -60,21 +64,34 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) Rest *rest = vrv_cast(element); assert(rest); dur = rest->GetDur(); - } LogDebug("the dur is: ", dur); - layer_children.insert(layer_children.end(), dur); + } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), dur); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); - data_TEMPUS m_tempus = m_currentMensur->GetTempus(); - LogDebug("the mensur is:", m_tempus); + //GetLayerElementsDurQuals(m_currentMensur->GetModusmaior(), m_currentMensur->GetModusminor(), m_currentMensur->GetTempus(), m_currentMensur->GetProlatio(), dursInVoiceSameMensur); }return FUNCTOR_CONTINUE; } -FunctorCode ScoringUpFunctor::GetLayerElements(std::vector layer_children) +/*std::vector GetLayerElementsDurQuals(data_MODUSMAIOR, data_MODUSMINOR, data_TEMPUS, data_PROLATIO, std::vector dursInVoiceSameMensur){ + + std::vector layer_children_durquals = {}; + + return layer_children_durquals; +}*/ + +/*FunctorCode ScoringUpFunctor::GetLayerElements() { - for(data_DURATION dur: layer_children){ + for(data_DURATION dur: dursInVoiceSameMensur){ LogDebug("dur is:", dur); std::cout << dur << std::endl; }return FUNCTOR_CONTINUE; +}*/ + +void findQuals(std::vector dursInVoiceSameMensur) +{ + for(data_DURATION dur: dursInVoiceSameMensur){ + LogDebug("dur is:", dur); + std::cout << dur << std::endl; + } } } // namespace vrv From 7a0a61a9be54df8dca4d6be66f94c1e71f9e5a42 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 15:56:45 +0200 Subject: [PATCH 07/88] Clean extra lines of code --- include/vrv/scoringupfunctor.h | 3 +-- src/scoringupfunctor.cpp | 17 ----------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index a4b83fdc95..404d94b1c3 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -45,14 +45,13 @@ class ScoringUpFunctor : public Functor { ///@{ FunctorCode VisitLayer(Layer *layer) override; FunctorCode VisitLayerElement(LayerElement *layerElement) override; - //FunctorCode GetLayerElements(); ///@} /// protected: // private: - //std::vector GetLayerElementsDurQuals(data_MODUSMAIOR, data_MODUSMINOR, data_TEMPUS, data_PROLATIO, std::vector layer_children_durs); + // public: std::vector dursInVoiceSameMensur = {}; void findQuals(std::vector dursInVoiceSameMensur); diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 7bafb8d6f4..b24ac4622c 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,7 +25,6 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -//std::vector> layer_children_durs = {}; ///std::vector dursInVoiceSameMensur = {}; ///void findQuals(std::vector dursInVoiceSameMensur); @@ -67,25 +66,9 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), dur); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); - //GetLayerElementsDurQuals(m_currentMensur->GetModusmaior(), m_currentMensur->GetModusminor(), m_currentMensur->GetTempus(), m_currentMensur->GetProlatio(), dursInVoiceSameMensur); }return FUNCTOR_CONTINUE; } -/*std::vector GetLayerElementsDurQuals(data_MODUSMAIOR, data_MODUSMINOR, data_TEMPUS, data_PROLATIO, std::vector dursInVoiceSameMensur){ - - std::vector layer_children_durquals = {}; - - return layer_children_durquals; -}*/ - -/*FunctorCode ScoringUpFunctor::GetLayerElements() -{ - for(data_DURATION dur: dursInVoiceSameMensur){ - LogDebug("dur is:", dur); - std::cout << dur << std::endl; - }return FUNCTOR_CONTINUE; -}*/ - void findQuals(std::vector dursInVoiceSameMensur) { for(data_DURATION dur: dursInVoiceSameMensur){ From 0ab0bfbe687ecae1a20283f25537aa0725305cee Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 16:01:31 +0200 Subject: [PATCH 08/88] Move variable and method declaration to cpp --- include/vrv/scoringupfunctor.h | 4 ++-- src/scoringupfunctor.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 404d94b1c3..a322133b1d 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -53,8 +53,8 @@ class ScoringUpFunctor : public Functor { private: // public: - std::vector dursInVoiceSameMensur = {}; - void findQuals(std::vector dursInVoiceSameMensur); + //std::vector dursInVoiceSameMensur = {}; + //void findQuals(std::vector dursInVoiceSameMensur); private: // The current score time in the measure (incremented by each element) double m_currentScoreTime; diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index b24ac4622c..c71265cad5 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,8 +25,8 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -///std::vector dursInVoiceSameMensur = {}; -///void findQuals(std::vector dursInVoiceSameMensur); +std::vector dursInVoiceSameMensur = {}; +void findQuals(std::vector dursInVoiceSameMensur); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -73,7 +73,6 @@ void findQuals(std::vector dursInVoiceSameMensur) { for(data_DURATION dur: dursInVoiceSameMensur){ LogDebug("dur is:", dur); - std::cout << dur << std::endl; } } From db58bff1fa8bd0aa6f248218905562345fcbd70a Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 16:29:26 +0200 Subject: [PATCH 09/88] Divide dursInVoiceSameMensur into subsequences these are meant to be processed later to find the durQuality of the notes --- src/scoringupfunctor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c71265cad5..a2f79ffff8 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -26,7 +26,7 @@ namespace vrv { //---------------------------------------------------------------------------- std::vector dursInVoiceSameMensur = {}; -void findQuals(std::vector dursInVoiceSameMensur); +void subdivideSeq(std::vector dursInVoiceSameMensur); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -40,7 +40,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ - findQuals(dursInVoiceSameMensur); + subdivideSeq(dursInVoiceSameMensur); dursInVoiceSameMensur = {}; //restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -69,10 +69,17 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) }return FUNCTOR_CONTINUE; } -void findQuals(std::vector dursInVoiceSameMensur) +void subdivideSeq(std::vector dursInVoiceSameMensur) { + std::vector> sequence = {}; + std::vector subsequence = {}; for(data_DURATION dur: dursInVoiceSameMensur){ - LogDebug("dur is:", dur); + if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { + sequence.insert(sequence.end(), subsequence); + subsequence = {dur}; + } else { + subsequence.insert(subsequence.end(), dur); + }LogDebug("dur is:", dur); } } From f49a9d155ebe2c293bcd93ec7ca84eeabe38b10b Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 22:09:53 +0200 Subject: [PATCH 10/88] Obtain xml:ids for notes and rests --- src/scoringupfunctor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index a2f79ffff8..3388060ad6 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,6 +25,7 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- +//std::vector> dursInVoiceSameMensur = {}; std::vector dursInVoiceSameMensur = {}; void subdivideSeq(std::vector dursInVoiceSameMensur); @@ -54,14 +55,17 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) if (element->Is(REST) || element->Is(NOTE)) { data_DURATION dur; + std::string xmlid; if (element->Is(NOTE)) { Note *note = vrv_cast(element); assert(note); + xmlid = note->GetID(); dur = note->GetDur(); //note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); + xmlid = rest->GetID(); dur = rest->GetDur(); } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), dur); } else if (element->Is(MENSUR)) { From ff4444610661e5c2887aeffd4a433eb8f31ac3ac Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 22:28:32 +0200 Subject: [PATCH 11/88] Use vectors of pairs of ids and durs --- src/scoringupfunctor.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 3388060ad6..374425437d 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,9 +25,9 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -//std::vector> dursInVoiceSameMensur = {}; -std::vector dursInVoiceSameMensur = {}; -void subdivideSeq(std::vector dursInVoiceSameMensur); +std::vector> dursInVoiceSameMensur = {}; +//std::vector dursInVoiceSameMensur = {}; +void subdivideSeq(std::vector> dursInVoiceSameMensur); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -67,22 +67,23 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) assert(rest); xmlid = rest->GetID(); dur = rest->GetDur(); - } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), dur); + } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {xmlid, dur}); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); }return FUNCTOR_CONTINUE; } -void subdivideSeq(std::vector dursInVoiceSameMensur) +void subdivideSeq(std::vector> dursInVoiceSameMensur) { - std::vector> sequence = {}; - std::vector subsequence = {}; - for(data_DURATION dur: dursInVoiceSameMensur){ + std::vector>> sequence = {}; + std::vector> subsequence = {}; + for(std::pair xmlIdDurPair : dursInVoiceSameMensur){ + data_DURATION dur = xmlIdDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { sequence.insert(sequence.end(), subsequence); - subsequence = {dur}; + subsequence = {xmlIdDurPair}; } else { - subsequence.insert(subsequence.end(), dur); + subsequence.insert(subsequence.end(), xmlIdDurPair); }LogDebug("dur is:", dur); } } From ed144a9864ad6b08618fa15911e1e4147034d50c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 22:32:30 +0200 Subject: [PATCH 12/88] Correct subsequences to start and end with 'long notes' --- src/scoringupfunctor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 374425437d..1dc0a1d216 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -80,6 +80,7 @@ void subdivideSeq(std::vector> dursInVoice for(std::pair xmlIdDurPair : dursInVoiceSameMensur){ data_DURATION dur = xmlIdDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { + subsequence.insert(subsequence.end(), xmlIdDurPair); sequence.insert(sequence.end(), subsequence); subsequence = {xmlIdDurPair}; } else { From 6d7e57a821cb50ffc66f566b992aca2fe449d60b Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 27 Aug 2024 23:07:33 +0200 Subject: [PATCH 13/88] Pass seq and subse to overloaded function to determine the durquality. This function sums the durational values of the notes smaller than the breve, for which it calls another function that converts the 'dur' values into the equivalent 'durational numerical values' with a switch --- src/scoringupfunctor.cpp | 58 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 1dc0a1d216..bfc9f52ced 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -26,8 +26,11 @@ namespace vrv { //---------------------------------------------------------------------------- std::vector> dursInVoiceSameMensur = {}; -//std::vector dursInVoiceSameMensur = {}; -void subdivideSeq(std::vector> dursInVoiceSameMensur); +std::vector>> sequence; +std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); +void findDurQuals(std::vector>> sequence); +void findDurQuals(std::vector> subsequence); +double durNumberValue(data_DURATION dur); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -41,7 +44,8 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ - subdivideSeq(dursInVoiceSameMensur); + sequence = subdivideSeq(dursInVoiceSameMensur); + findDurQuals(sequence); dursInVoiceSameMensur = {}; //restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -73,7 +77,7 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) }return FUNCTOR_CONTINUE; } -void subdivideSeq(std::vector> dursInVoiceSameMensur) +std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur) { std::vector>> sequence = {}; std::vector> subsequence = {}; @@ -87,6 +91,52 @@ void subdivideSeq(std::vector> dursInVoice subsequence.insert(subsequence.end(), xmlIdDurPair); }LogDebug("dur is:", dur); } + return sequence; } +void findDurQuals(std::vector>> sequence){ + for (std::vector> subseq: sequence){ + findDurQuals(subseq); + } +} + +void findDurQuals(std::vector> subsequence){ + double sum = 0; + for (std::pair xmlIdDurPair : subsequence){ + data_DURATION dur = xmlIdDurPair.second; + sum += durNumberValue(dur); + } + + int remainder = (int)sum % 3; + if (remainder == 1) { + // Imperfection a.p.p. + } else if (remainder == 2) { + // Alteration + } else { + // Regular values + } +} + +double durNumberValue(data_DURATION dur) { + double durnum = 0; + switch(dur) { + case DURATION_semibrevis: + durnum = 1; + break; + case DURATION_minima: + durnum = 0.5; + break; + case DURATION_semiminima: + durnum = 0.25; + break; + case DURATION_fusa: + durnum = 0.125; + break; + case DURATION_semifusa: + durnum = 0.0625; + break; + } return durnum; +} + + } // namespace vrv From 8053f401b6b38446f64d69d382ba3b8ed3c083d7 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 30 Aug 2024 04:40:53 +0200 Subject: [PATCH 14/88] Add methods for imperfection and alteration --- src/scoringupfunctor.cpp | 46 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index bfc9f52ced..731d37281b 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -31,6 +31,9 @@ std::vector>> subdivideSeq(std void findDurQuals(std::vector>> sequence); void findDurQuals(std::vector> subsequence); double durNumberValue(data_DURATION dur); +void imperfectionAPP(std::vector> subsequence); +void imperfectionAPA(std::vector> subsequence); +void alteration(std::vector> subsequence); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -108,13 +111,42 @@ void findDurQuals(std::vector> subsequence } int remainder = (int)sum % 3; - if (remainder == 1) { + if (sum <= 3) { + switch (remainder) { + case 0: + break; + case 1: + imperfectionAPP(subsequence); + break; + case 2: + alteration(subsequence); + break; + } + } else { + switch (remainder) { + case 0: + imperfectionAPP(subsequence); + alteration(subsequence); + break; + case 1: + imperfectionAPP(subsequence); + break; + case 2: + imperfectionAPP(subsequence); + imperfectionAPA(subsequence); + break; + } + } + +/* if (remainder == 1) { // Imperfection a.p.p. + imperfectionAPP(subsequence); } else if (remainder == 2) { // Alteration + alteration(subsequence); } else { // Regular values - } + }*/ } double durNumberValue(data_DURATION dur) { @@ -138,5 +170,15 @@ double durNumberValue(data_DURATION dur) { } return durnum; } +void imperfectionAPP(std::vector> subsequence){ + +} +void imperfectionAPA(std::vector> subsequence){ + +} +void alteration(std::vector> subsequence){ + +} + } // namespace vrv From 8892095f5f5b8530fc55dd278b5555d353851b35 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 30 Aug 2024 05:04:18 +0200 Subject: [PATCH 15/88] Add all the principles of imperfection and alteration (including their exceptions) --- src/scoringupfunctor.cpp | 43 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 731d37281b..20734643ae 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -111,42 +111,59 @@ void findDurQuals(std::vector> subsequence } int remainder = (int)sum % 3; - if (sum <= 3) { + bool dotOfPerf = false; //When true, it forces a perfect value + bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) + bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the subsequence. When true, it doesn't allow for alteration + bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the subsequence, checking if it is greater or equal to the last note of the subsequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) + + // Principles of imperfection and alteration (and their exceptions). + // The implementation is based on the rules outlined by Willi Apel, with perfect groupings of notes and the remainder: + if (sum <= 3) { // For sum = 0, 1, 2, or 3 switch (remainder) { case 0: - break; + break; //No modifications case 1: + if (dotOfPerf) { + imperfectionAPA(subsequence); + break; + }//Other, the default case: imperfectionAPP(subsequence); break; case 2: + if (dotOfImperf || smallNoteValue) { + imperfectionAPP(subsequence); + imperfectionAPA(subsequence); + break; + }//Other, the default case: alteration(subsequence); break; } - } else { + } else { // For sum > 3 switch (remainder) { case 0: + if (dotOfPerf || smallNoteValue) { + break; //No modifications + }//Other, the default case: imperfectionAPP(subsequence); alteration(subsequence); break; case 1: + if (dotOfPerf) { + imperfectionAPA(subsequence); + break; + }//Other, the default case: imperfectionAPP(subsequence); break; case 2: + if (dotOfPerf || simileAnteSimile) { + alteration(subsequence); + break; + }//Other, the default case: imperfectionAPP(subsequence); imperfectionAPA(subsequence); break; } } - -/* if (remainder == 1) { - // Imperfection a.p.p. - imperfectionAPP(subsequence); - } else if (remainder == 2) { - // Alteration - alteration(subsequence); - } else { - // Regular values - }*/ } double durNumberValue(data_DURATION dur) { From c4c39ed6ee0253708f45dbb01884438518eb958c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 30 Aug 2024 05:30:09 +0200 Subject: [PATCH 16/88] Start sketch of imperfection and alteration functions --- src/scoringupfunctor.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 20734643ae..baaab104f2 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -188,13 +188,21 @@ double durNumberValue(data_DURATION dur) { } void imperfectionAPP(std::vector> subsequence){ - + std::string firstNoteID = subsequence.at(0).first; + Note *firstNote; // still need to find this based on the ID (or to pass to the function the element itself + firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } + void imperfectionAPA(std::vector> subsequence){ - + std::string lastNoteID = subsequence.at(-1).first; + Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself + lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } + void alteration(std::vector> subsequence){ - + std::string penultNoteID = subsequence.at(-2).first; + Note *penultNote; // still need to find this based on the ID (or to pass to the function the element itself + penultNote->SetDurQuality(DURQUALITY_mensural_altera); } From 75c6bb7f0dfc6d33bf664b658fd8c6ce68d31d20 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 30 Aug 2024 05:33:51 +0200 Subject: [PATCH 17/88] Add comment: missing 'rest at' conditions to forbid imperfection/alteration --- src/scoringupfunctor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index baaab104f2..94ff9e96e5 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -163,7 +163,7 @@ void findDurQuals(std::vector> subsequence imperfectionAPA(subsequence); break; } - } + }// Missing "rest at" conditions } double durNumberValue(data_DURATION dur) { From b5fcc9dfacda79f1f21449f82213be2bece3c716 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 31 Aug 2024 01:01:03 +0200 Subject: [PATCH 18/88] Comment lines out for the program to keep working --- src/scoringupfunctor.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 94ff9e96e5..636f2e9ab5 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -188,21 +188,21 @@ double durNumberValue(data_DURATION dur) { } void imperfectionAPP(std::vector> subsequence){ - std::string firstNoteID = subsequence.at(0).first; - Note *firstNote; // still need to find this based on the ID (or to pass to the function the element itself - firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + //std::string firstNoteID = subsequence.at(0).first; + //Note *firstNote; // still need to find this based on the ID (or to pass to the function the element itself + //firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } void imperfectionAPA(std::vector> subsequence){ - std::string lastNoteID = subsequence.at(-1).first; - Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself - lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + //std::string lastNoteID = subsequence.at(-1).first; + //Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself + //lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } void alteration(std::vector> subsequence){ - std::string penultNoteID = subsequence.at(-2).first; - Note *penultNote; // still need to find this based on the ID (or to pass to the function the element itself - penultNote->SetDurQuality(DURQUALITY_mensural_altera); + //std::string penultNoteID = subsequence.at(-2).first; + //Note *penultNote; // still need to find this based on the ID (or to pass to the function the element itself + //penultNote->SetDurQuality(DURQUALITY_mensural_altera); } From 2d2b3fa1d2305a527861fe4f696e3fd594ee221e Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 31 Aug 2024 01:28:47 +0200 Subject: [PATCH 19/88] Try to solve the issue of getting the notes/rests by ID to set the durquality Temporary solution: define another vector for notes and another for rests that relate the ids to the actual note or rest objects --- src/scoringupfunctor.cpp | 94 ++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 636f2e9ab5..179e910f78 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -25,15 +25,18 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- +std::vector> notes = {}; +std::vector> rests = {}; std::vector> dursInVoiceSameMensur = {}; -std::vector>> sequence; + +std::vector>> listOfSequences; std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); -void findDurQuals(std::vector>> sequence); -void findDurQuals(std::vector> subsequence); +void findDurQuals(std::vector>> listOfSequences, std::vector> notes, std::vector> rests); +void findDurQuals(std::vector> sequence, std::vector> notes, std::vector> rests); double durNumberValue(data_DURATION dur); -void imperfectionAPP(std::vector> subsequence); -void imperfectionAPA(std::vector> subsequence); -void alteration(std::vector> subsequence); +void imperfectionAPP(std::vector> sequence, std::vector> notes, std::vector> rests); +void imperfectionAPA(std::vector> sequence, std::vector> notes, std::vector> rests); +void alteration(std::vector> sequence, std::vector> notes, std::vector> rests); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -47,9 +50,11 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ - sequence = subdivideSeq(dursInVoiceSameMensur); - findDurQuals(sequence); + listOfSequences = subdivideSeq(dursInVoiceSameMensur); + findDurQuals(listOfSequences, notes, rests); dursInVoiceSameMensur = {}; //restart for next voice (layer) + notes = {}; + rests = {}; } return FUNCTOR_CONTINUE; } @@ -68,12 +73,14 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) assert(note); xmlid = note->GetID(); dur = note->GetDur(); + notes.insert(notes.end(), {xmlid, *note}); //note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); xmlid = rest->GetID(); dur = rest->GetDur(); + rests.insert(rests.end(), {xmlid, *rest}); } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {xmlid, dur}); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); @@ -82,30 +89,30 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur) { - std::vector>> sequence = {}; - std::vector> subsequence = {}; + std::vector>> listOfSequences = {}; + std::vector> sequence = {}; for(std::pair xmlIdDurPair : dursInVoiceSameMensur){ data_DURATION dur = xmlIdDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { - subsequence.insert(subsequence.end(), xmlIdDurPair); - sequence.insert(sequence.end(), subsequence); - subsequence = {xmlIdDurPair}; + sequence.insert(sequence.end(), xmlIdDurPair); + listOfSequences.insert(listOfSequences.end(), sequence); + sequence = {xmlIdDurPair}; } else { - subsequence.insert(subsequence.end(), xmlIdDurPair); + sequence.insert(sequence.end(), xmlIdDurPair); }LogDebug("dur is:", dur); } - return sequence; + return listOfSequences; } -void findDurQuals(std::vector>> sequence){ - for (std::vector> subseq: sequence){ - findDurQuals(subseq); +void findDurQuals(std::vector>> listOfSequences, std::vector> notes, std::vector> rests){ + for (std::vector> subseq: listOfSequences){ + findDurQuals(subseq, notes, rests); } } -void findDurQuals(std::vector> subsequence){ +void findDurQuals(std::vector> sequence, std::vector> notes, std::vector> rests){ double sum = 0; - for (std::pair xmlIdDurPair : subsequence){ + for (std::pair xmlIdDurPair : sequence){ data_DURATION dur = xmlIdDurPair.second; sum += durNumberValue(dur); } @@ -113,8 +120,8 @@ void findDurQuals(std::vector> subsequence int remainder = (int)sum % 3; bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) - bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the subsequence. When true, it doesn't allow for alteration - bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the subsequence, checking if it is greater or equal to the last note of the subsequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) + bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the sequence. When true, it doesn't allow for alteration + bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) // Principles of imperfection and alteration (and their exceptions). // The implementation is based on the rules outlined by Willi Apel, with perfect groupings of notes and the remainder: @@ -124,18 +131,18 @@ void findDurQuals(std::vector> subsequence break; //No modifications case 1: if (dotOfPerf) { - imperfectionAPA(subsequence); + imperfectionAPA(sequence, notes, rests); break; }//Other, the default case: - imperfectionAPP(subsequence); + imperfectionAPP(sequence, notes, rests); break; case 2: if (dotOfImperf || smallNoteValue) { - imperfectionAPP(subsequence); - imperfectionAPA(subsequence); + imperfectionAPP(sequence, notes, rests); + imperfectionAPA(sequence, notes, rests); break; }//Other, the default case: - alteration(subsequence); + alteration(sequence, notes, rests); break; } } else { // For sum > 3 @@ -144,23 +151,23 @@ void findDurQuals(std::vector> subsequence if (dotOfPerf || smallNoteValue) { break; //No modifications }//Other, the default case: - imperfectionAPP(subsequence); - alteration(subsequence); + imperfectionAPP(sequence, notes, rests); + alteration(sequence, notes, rests); break; case 1: if (dotOfPerf) { - imperfectionAPA(subsequence); + imperfectionAPA(sequence, notes, rests); break; }//Other, the default case: - imperfectionAPP(subsequence); + imperfectionAPP(sequence, notes, rests); break; case 2: if (dotOfPerf || simileAnteSimile) { - alteration(subsequence); + alteration(sequence, notes, rests); break; }//Other, the default case: - imperfectionAPP(subsequence); - imperfectionAPA(subsequence); + imperfectionAPP(sequence, notes, rests); + imperfectionAPA(sequence, notes, rests); break; } }// Missing "rest at" conditions @@ -187,20 +194,23 @@ double durNumberValue(data_DURATION dur) { } return durnum; } -void imperfectionAPP(std::vector> subsequence){ - //std::string firstNoteID = subsequence.at(0).first; - //Note *firstNote; // still need to find this based on the ID (or to pass to the function the element itself - //firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); +void imperfectionAPP(std::vector> sequence, std::vector> notes, std::vector> rests){ + std::string firstNoteID = sequence.at(0).first; + for(std::pair note : notes){ + if(note.first == firstNoteID){ + note.second.SetDurQuality(DURQUALITY_mensural_imperfecta); + } + } } -void imperfectionAPA(std::vector> subsequence){ - //std::string lastNoteID = subsequence.at(-1).first; +void imperfectionAPA(std::vector> sequence, std::vector> notes, std::vector> rests){ + //std::string lastNoteID = sequence.at(-1).first; //Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself //lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } -void alteration(std::vector> subsequence){ - //std::string penultNoteID = subsequence.at(-2).first; +void alteration(std::vector> sequence, std::vector> notes, std::vector> rests){ + //std::string penultNoteID = sequence.at(-2).first; //Note *penultNote; // still need to find this based on the ID (or to pass to the function the element itself //penultNote->SetDurQuality(DURQUALITY_mensural_altera); } From 593ae25409878298b1a49e06045ddb748a47db20 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 31 Aug 2024 01:52:43 +0200 Subject: [PATCH 20/88] Add changes for alteration The right note is found, and the durquality seems to change, but the chagnes are not stored, which makes me think that I should use a pointer to the note rather than a copy --- src/scoringupfunctor.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 179e910f78..277ad9351c 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -198,7 +198,10 @@ void imperfectionAPP(std::vector> sequence std::string firstNoteID = sequence.at(0).first; for(std::pair note : notes){ if(note.first == firstNoteID){ - note.second.SetDurQuality(DURQUALITY_mensural_imperfecta); + Note theNote = note.second; + theNote.SetDurQuality(DURQUALITY_mensural_imperfecta); + LogDebug("the note"); + break; } } } @@ -210,9 +213,15 @@ void imperfectionAPA(std::vector> sequence } void alteration(std::vector> sequence, std::vector> notes, std::vector> rests){ - //std::string penultNoteID = sequence.at(-2).first; - //Note *penultNote; // still need to find this based on the ID (or to pass to the function the element itself - //penultNote->SetDurQuality(DURQUALITY_mensural_altera); + std::string penultNoteID = sequence.at(sequence.size()-2).first; + for(std::pair note : notes){ + if(note.first == penultNoteID){ + Note theNote = note.second; + theNote.SetDurQuality(DURQUALITY_mensural_altera); + LogDebug("the note"); + break; + } + } } From 758fa11313b78d856f033f2ddc127f624fc7d93f Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 31 Aug 2024 02:13:55 +0200 Subject: [PATCH 21/88] Trying to fix the pointers to the notes Seemed to work within the imperfection and alteration function (based on the console), but some other function that calls them might be causing an issue --- src/scoringupfunctor.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 277ad9351c..0ae0c48f58 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -31,12 +31,12 @@ std::vector> dursInVoiceSameMensur = {}; std::vector>> listOfSequences; std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); -void findDurQuals(std::vector>> listOfSequences, std::vector> notes, std::vector> rests); -void findDurQuals(std::vector> sequence, std::vector> notes, std::vector> rests); +void findDurQuals(std::vector>> listOfSequences, std::vector> *notes, std::vector> *rests); +void findDurQuals(std::vector> sequence, std::vector> *notes, std::vector> *rests); double durNumberValue(data_DURATION dur); -void imperfectionAPP(std::vector> sequence, std::vector> notes, std::vector> rests); -void imperfectionAPA(std::vector> sequence, std::vector> notes, std::vector> rests); -void alteration(std::vector> sequence, std::vector> notes, std::vector> rests); +void imperfectionAPP(std::vector> sequence, std::vector> *notes, std::vector> *rests); +void imperfectionAPA(std::vector> sequence, std::vector> *notes, std::vector> *rests); +void alteration(std::vector> sequence, std::vector> *notes, std::vector> *rests); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -51,7 +51,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ listOfSequences = subdivideSeq(dursInVoiceSameMensur); - findDurQuals(listOfSequences, notes, rests); + findDurQuals(listOfSequences, ¬es, &rests); dursInVoiceSameMensur = {}; //restart for next voice (layer) notes = {}; rests = {}; @@ -104,13 +104,13 @@ std::vector>> subdivideSeq(std return listOfSequences; } -void findDurQuals(std::vector>> listOfSequences, std::vector> notes, std::vector> rests){ +void findDurQuals(std::vector>> listOfSequences, std::vector> *notes, std::vector> *rests){ for (std::vector> subseq: listOfSequences){ findDurQuals(subseq, notes, rests); } } -void findDurQuals(std::vector> sequence, std::vector> notes, std::vector> rests){ +void findDurQuals(std::vector> sequence, std::vector> *notes, std::vector> *rests){ double sum = 0; for (std::pair xmlIdDurPair : sequence){ data_DURATION dur = xmlIdDurPair.second; @@ -194,30 +194,30 @@ double durNumberValue(data_DURATION dur) { } return durnum; } -void imperfectionAPP(std::vector> sequence, std::vector> notes, std::vector> rests){ +void imperfectionAPP(std::vector> sequence, std::vector> *notes, std::vector> *rests){ std::string firstNoteID = sequence.at(0).first; - for(std::pair note : notes){ + for(std::pair note : *notes){ if(note.first == firstNoteID){ - Note theNote = note.second; - theNote.SetDurQuality(DURQUALITY_mensural_imperfecta); + Note *theNote = ¬e.second; + theNote->SetDurQuality(DURQUALITY_mensural_imperfecta); LogDebug("the note"); break; } } } -void imperfectionAPA(std::vector> sequence, std::vector> notes, std::vector> rests){ +void imperfectionAPA(std::vector> sequence, std::vector> *notes, std::vector> *rests){ //std::string lastNoteID = sequence.at(-1).first; //Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself //lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } -void alteration(std::vector> sequence, std::vector> notes, std::vector> rests){ +void alteration(std::vector> sequence, std::vector> *notes, std::vector> *rests){ std::string penultNoteID = sequence.at(sequence.size()-2).first; - for(std::pair note : notes){ + for(std::pair note : *notes){ if(note.first == penultNoteID){ - Note theNote = note.second; - theNote.SetDurQuality(DURQUALITY_mensural_altera); + Note *theNote = ¬e.second; + theNote->SetDurQuality(DURQUALITY_mensural_altera); LogDebug("the note"); break; } From 6621587ed84febcb5d891c7f7ba1a3ff933e93f9 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 31 Aug 2024 02:36:12 +0200 Subject: [PATCH 22/88] Use maps of ids to notes/rests and fix pointer issue For the latter (the pointer issue), I needed to use Note* and Rest* within the map (or pairs that I used before). --- src/scoringupfunctor.cpp | 81 +++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 0ae0c48f58..3413760a05 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -16,6 +16,7 @@ #include "staff.h" #include "system.h" #include "vrv.h" +#include //---------------------------------------------------------------------------- @@ -25,18 +26,18 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -std::vector> notes = {}; -std::vector> rests = {}; +std::map notesDictionary; +std::map restsDictionary; std::vector> dursInVoiceSameMensur = {}; std::vector>> listOfSequences; std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); -void findDurQuals(std::vector>> listOfSequences, std::vector> *notes, std::vector> *rests); -void findDurQuals(std::vector> sequence, std::vector> *notes, std::vector> *rests); +void findDurQuals(std::vector>> listOfSequences, std::map notesDictionary, std::map restsDictionary); +void findDurQuals(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); double durNumberValue(data_DURATION dur); -void imperfectionAPP(std::vector> sequence, std::vector> *notes, std::vector> *rests); -void imperfectionAPA(std::vector> sequence, std::vector> *notes, std::vector> *rests); -void alteration(std::vector> sequence, std::vector> *notes, std::vector> *rests); +void imperfectionAPP(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); +void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); +void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -51,10 +52,8 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ listOfSequences = subdivideSeq(dursInVoiceSameMensur); - findDurQuals(listOfSequences, ¬es, &rests); + findDurQuals(listOfSequences, notesDictionary, restsDictionary); dursInVoiceSameMensur = {}; //restart for next voice (layer) - notes = {}; - rests = {}; } return FUNCTOR_CONTINUE; } @@ -73,14 +72,14 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) assert(note); xmlid = note->GetID(); dur = note->GetDur(); - notes.insert(notes.end(), {xmlid, *note}); + notesDictionary[xmlid] = note; //note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); xmlid = rest->GetID(); dur = rest->GetDur(); - rests.insert(rests.end(), {xmlid, *rest}); + restsDictionary[xmlid] = rest; } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {xmlid, dur}); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); @@ -104,13 +103,13 @@ std::vector>> subdivideSeq(std return listOfSequences; } -void findDurQuals(std::vector>> listOfSequences, std::vector> *notes, std::vector> *rests){ +void findDurQuals(std::vector>> listOfSequences, std::map notesDictionary, std::map restsDictionary){ for (std::vector> subseq: listOfSequences){ - findDurQuals(subseq, notes, rests); + findDurQuals(subseq, notesDictionary, restsDictionary); } } -void findDurQuals(std::vector> sequence, std::vector> *notes, std::vector> *rests){ +void findDurQuals(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ double sum = 0; for (std::pair xmlIdDurPair : sequence){ data_DURATION dur = xmlIdDurPair.second; @@ -131,18 +130,18 @@ void findDurQuals(std::vector> sequence, s break; //No modifications case 1: if (dotOfPerf) { - imperfectionAPA(sequence, notes, rests); + imperfectionAPA(sequence, notesDictionary, restsDictionary); break; }//Other, the default case: - imperfectionAPP(sequence, notes, rests); + imperfectionAPP(sequence, notesDictionary, restsDictionary); break; case 2: if (dotOfImperf || smallNoteValue) { - imperfectionAPP(sequence, notes, rests); - imperfectionAPA(sequence, notes, rests); + imperfectionAPP(sequence, notesDictionary, restsDictionary); + imperfectionAPA(sequence, notesDictionary, restsDictionary); break; }//Other, the default case: - alteration(sequence, notes, rests); + alteration(sequence, notesDictionary, restsDictionary); break; } } else { // For sum > 3 @@ -151,23 +150,23 @@ void findDurQuals(std::vector> sequence, s if (dotOfPerf || smallNoteValue) { break; //No modifications }//Other, the default case: - imperfectionAPP(sequence, notes, rests); - alteration(sequence, notes, rests); + imperfectionAPP(sequence, notesDictionary, restsDictionary); + alteration(sequence, notesDictionary, restsDictionary); break; case 1: if (dotOfPerf) { - imperfectionAPA(sequence, notes, rests); + imperfectionAPA(sequence, notesDictionary, restsDictionary); break; }//Other, the default case: - imperfectionAPP(sequence, notes, rests); + imperfectionAPP(sequence, notesDictionary, restsDictionary); break; case 2: if (dotOfPerf || simileAnteSimile) { - alteration(sequence, notes, rests); + alteration(sequence, notesDictionary, restsDictionary); break; }//Other, the default case: - imperfectionAPP(sequence, notes, rests); - imperfectionAPA(sequence, notes, rests); + imperfectionAPP(sequence, notesDictionary, restsDictionary); + imperfectionAPA(sequence, notesDictionary, restsDictionary); break; } }// Missing "rest at" conditions @@ -194,34 +193,24 @@ double durNumberValue(data_DURATION dur) { } return durnum; } -void imperfectionAPP(std::vector> sequence, std::vector> *notes, std::vector> *rests){ +void imperfectionAPP(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ std::string firstNoteID = sequence.at(0).first; - for(std::pair note : *notes){ - if(note.first == firstNoteID){ - Note *theNote = ¬e.second; - theNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - LogDebug("the note"); - break; - } - } + Note *firstNote = notesDictionary[firstNoteID]; + firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + LogDebug("thenote!"); } -void imperfectionAPA(std::vector> sequence, std::vector> *notes, std::vector> *rests){ +void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ //std::string lastNoteID = sequence.at(-1).first; //Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself //lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); } -void alteration(std::vector> sequence, std::vector> *notes, std::vector> *rests){ +void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ std::string penultNoteID = sequence.at(sequence.size()-2).first; - for(std::pair note : *notes){ - if(note.first == penultNoteID){ - Note *theNote = ¬e.second; - theNote->SetDurQuality(DURQUALITY_mensural_altera); - LogDebug("the note"); - break; - } - } + Note *penultNote = notesDictionary[penultNoteID]; + penultNote->SetDurQuality(DURQUALITY_mensural_altera); + LogDebug("thenote!"); } From 64e1cfee8d34d3b4fdf1a03b2d3e5a73450b5a93 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 14:21:55 +0200 Subject: [PATCH 23/88] Add imperfection a.p.a. code --- src/scoringupfunctor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 3413760a05..1cd4f9e343 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -201,9 +201,10 @@ void imperfectionAPP(std::vector> sequence } void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ - //std::string lastNoteID = sequence.at(-1).first; - //Note *lastNote; // still need to find this based on the ID (or to pass to the function the element itself - //lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + std::string lastNoteID = sequence.at(sequence.size()-1).first; + Note *lastNote = notesDictionary[lastNoteID]; + lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + LogDebug("thenote!"); } void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ From d0e1c7e3a8d4bfd279dfc226b1e4f5287f690339 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 14:35:30 +0200 Subject: [PATCH 24/88] Add 'rest' condition that forbids alteration --- src/scoringupfunctor.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 1cd4f9e343..436ef98219 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -38,6 +38,7 @@ double durNumberValue(data_DURATION dur); void imperfectionAPP(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); +bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -136,7 +137,7 @@ void findDurQuals(std::vector> sequence, s imperfectionAPP(sequence, notesDictionary, restsDictionary); break; case 2: - if (dotOfImperf || smallNoteValue) { + if (dotOfImperf || smallNoteValue || isPenultimateValueARest(sequence, restsDictionary)) { imperfectionAPP(sequence, notesDictionary, restsDictionary); imperfectionAPA(sequence, notesDictionary, restsDictionary); break; @@ -147,7 +148,7 @@ void findDurQuals(std::vector> sequence, s } else { // For sum > 3 switch (remainder) { case 0: - if (dotOfPerf || smallNoteValue) { + if (dotOfPerf || smallNoteValue || isPenultimateValueARest(sequence, restsDictionary)) { break; //No modifications }//Other, the default case: imperfectionAPP(sequence, notesDictionary, restsDictionary); @@ -214,5 +215,12 @@ void alteration(std::vector> sequence, std LogDebug("thenote!"); } +bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary){ + std::string penultNoteID = sequence.at(sequence.size()-2).first; + if (restsDictionary[penultNoteID]) {return true;} + else {return false;} + LogDebug("thenote!"); +} + } // namespace vrv From ad2868a299b611c3942db77915ad3f15e06b06c4 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 14:50:56 +0200 Subject: [PATCH 25/88] Add 'short note value' condition to forbid alteration --- src/scoringupfunctor.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 436ef98219..71685c4d45 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -39,6 +39,7 @@ void imperfectionAPP(std::vector> sequence void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary); +bool isPenultimateValueShort(std::vector> sequence, std::map notesDictionary); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -121,6 +122,7 @@ void findDurQuals(std::vector> sequence, s bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the sequence. When true, it doesn't allow for alteration + bool restValue = false; bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) // Principles of imperfection and alteration (and their exceptions). @@ -137,7 +139,9 @@ void findDurQuals(std::vector> sequence, s imperfectionAPP(sequence, notesDictionary, restsDictionary); break; case 2: - if (dotOfImperf || smallNoteValue || isPenultimateValueARest(sequence, restsDictionary)) { + smallNoteValue = isPenultimateValueShort(sequence, notesDictionary); + restValue = isPenultimateValueARest(sequence, restsDictionary); + if (dotOfImperf || smallNoteValue || restValue) { imperfectionAPP(sequence, notesDictionary, restsDictionary); imperfectionAPA(sequence, notesDictionary, restsDictionary); break; @@ -219,8 +223,18 @@ bool isPenultimateValueARest(std::vector> std::string penultNoteID = sequence.at(sequence.size()-2).first; if (restsDictionary[penultNoteID]) {return true;} else {return false;} - LogDebug("thenote!"); } +bool isPenultimateValueShort(std::vector> sequence, std::map notesDictionary){ + std::string penultNoteID = sequence.at(sequence.size()-2).first; + bool smallNoteValue = false; + if (notesDictionary[penultNoteID]) { + Note *penultNote = notesDictionary[penultNoteID]; + data_DURATION dur = penultNote->GetDur(); + if (dur == DURATION_fusa || dur == DURATION_semifusa || dur == DURATION_minima || dur == DURATION_semiminima){ + smallNoteValue = true; + } + } return smallNoteValue; +} } // namespace vrv From 9138d9856d5844a871ea1e64c0b495e98c7ebef0 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 14:52:37 +0200 Subject: [PATCH 26/88] Finish documentating flags that forbid alteration --- src/scoringupfunctor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 71685c4d45..b6615ed72c 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -122,7 +122,7 @@ void findDurQuals(std::vector> sequence, s bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the sequence. When true, it doesn't allow for alteration - bool restValue = false; + bool restValue = false; //Flag that evaluates if the penultimate value in the sequence is a rest. When true, it doesn't allow for alteration bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) // Principles of imperfection and alteration (and their exceptions). @@ -152,7 +152,9 @@ void findDurQuals(std::vector> sequence, s } else { // For sum > 3 switch (remainder) { case 0: - if (dotOfPerf || smallNoteValue || isPenultimateValueARest(sequence, restsDictionary)) { + smallNoteValue = isPenultimateValueShort(sequence, notesDictionary); + restValue = isPenultimateValueARest(sequence, restsDictionary); + if (dotOfPerf || smallNoteValue || restValue) { break; //No modifications }//Other, the default case: imperfectionAPP(sequence, notesDictionary, restsDictionary); From eab73c06d374f1622e4b545f8c9241fb5f71d543 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 14:53:43 +0200 Subject: [PATCH 27/88] Remove comment --- src/scoringupfunctor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index b6615ed72c..244fe9f1d2 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -176,7 +176,7 @@ void findDurQuals(std::vector> sequence, s imperfectionAPA(sequence, notesDictionary, restsDictionary); break; } - }// Missing "rest at" conditions + } } double durNumberValue(data_DURATION dur) { From c789e829ff1a1c23892040a92835854a8b6080d2 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 17:41:36 +0200 Subject: [PATCH 28/88] Remove unnecessary comments and debug statements --- src/scoringupfunctor.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 244fe9f1d2..754e259dfd 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -75,7 +75,6 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) xmlid = note->GetID(); dur = note->GetDur(); notesDictionary[xmlid] = note; - //note->SetDurQuality(DURQUALITY_mensural_imperfecta); } else { Rest *rest = vrv_cast(element); assert(rest); @@ -204,21 +203,18 @@ void imperfectionAPP(std::vector> sequence std::string firstNoteID = sequence.at(0).first; Note *firstNote = notesDictionary[firstNoteID]; firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - LogDebug("thenote!"); } void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ std::string lastNoteID = sequence.at(sequence.size()-1).first; Note *lastNote = notesDictionary[lastNoteID]; lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - LogDebug("thenote!"); } void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ std::string penultNoteID = sequence.at(sequence.size()-2).first; Note *penultNote = notesDictionary[penultNoteID]; penultNote->SetDurQuality(DURQUALITY_mensural_altera); - LogDebug("thenote!"); } bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary){ From 7a495705c83244cee236fa735daad709fd588b36 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 18:34:31 +0200 Subject: [PATCH 29/88] Change implementation to use references to elements still need to test it --- src/scoringupfunctor.cpp | 185 +++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 96 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 754e259dfd..bf421646c8 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -26,20 +26,17 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -std::map notesDictionary; -std::map restsDictionary; -std::vector> dursInVoiceSameMensur = {}; - -std::vector>> listOfSequences; -std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); -void findDurQuals(std::vector>> listOfSequences, std::map notesDictionary, std::map restsDictionary); -void findDurQuals(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); +std::vector> dursInVoiceSameMensur = {}; + +std::vector>> listOfSequences; +std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); + +void findDurQuals(std::vector>> listOfSequences); +void findDurQuals(std::vector> sequence); double durNumberValue(data_DURATION dur); -void imperfectionAPP(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); -void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); -void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary); -bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary); -bool isPenultimateValueShort(std::vector> sequence, std::map notesDictionary); +bool imperfectionAPP(std::vector> sequence); +bool imperfectionAPA(std::vector> sequence); +bool alteration(std::vector> sequence); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -54,7 +51,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ listOfSequences = subdivideSeq(dursInVoiceSameMensur); - findDurQuals(listOfSequences, notesDictionary, restsDictionary); + findDurQuals(listOfSequences); dursInVoiceSameMensur = {}; //restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -66,58 +63,54 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) LayerElement *element = layerElement->ThisOrSameasLink(); - if (element->Is(REST) || element->Is(NOTE)) { - data_DURATION dur; - std::string xmlid; + if (element->Is(REST) || element->Is(NOTE) || element->Is(DOT)) { + data_DURATION dur = DURATION_NONE; if (element->Is(NOTE)) { Note *note = vrv_cast(element); assert(note); - xmlid = note->GetID(); dur = note->GetDur(); - notesDictionary[xmlid] = note; - } else { + } else if (element->Is(REST)) { Rest *rest = vrv_cast(element); assert(rest); - xmlid = rest->GetID(); dur = rest->GetDur(); - restsDictionary[xmlid] = rest; - } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {xmlid, dur}); + } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {element, dur}); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(layerElement); }return FUNCTOR_CONTINUE; } -std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur) +std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur) { - std::vector>> listOfSequences = {}; - std::vector> sequence = {}; - for(std::pair xmlIdDurPair : dursInVoiceSameMensur){ - data_DURATION dur = xmlIdDurPair.second; + std::vector>> listOfSequences = {}; + std::vector> sequence = {}; + for(std::pair elementDurPair : dursInVoiceSameMensur){ + data_DURATION dur = elementDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { - sequence.insert(sequence.end(), xmlIdDurPair); + sequence.insert(sequence.end(), elementDurPair); listOfSequences.insert(listOfSequences.end(), sequence); - sequence = {xmlIdDurPair}; + sequence = {elementDurPair}; } else { - sequence.insert(sequence.end(), xmlIdDurPair); + sequence.insert(sequence.end(), elementDurPair); }LogDebug("dur is:", dur); } return listOfSequences; } -void findDurQuals(std::vector>> listOfSequences, std::map notesDictionary, std::map restsDictionary){ - for (std::vector> subseq: listOfSequences){ - findDurQuals(subseq, notesDictionary, restsDictionary); +void findDurQuals(std::vector>> listOfSequences){ + for (std::vector> subseq: listOfSequences){ + findDurQuals(subseq); } } -void findDurQuals(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ +void findDurQuals(std::vector> sequence){ double sum = 0; - for (std::pair xmlIdDurPair : sequence){ - data_DURATION dur = xmlIdDurPair.second; + for (std::pair elementDurPair : sequence){ + data_DURATION dur = elementDurPair.second; sum += durNumberValue(dur); } int remainder = (int)sum % 3; + bool alterationFlag, impappFlag, impapaFlag; bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the sequence. When true, it doesn't allow for alteration @@ -131,49 +124,44 @@ void findDurQuals(std::vector> sequence, s case 0: break; //No modifications case 1: - if (dotOfPerf) { - imperfectionAPA(sequence, notesDictionary, restsDictionary); + impappFlag = imperfectionAPP(sequence); + if (!impappFlag || dotOfPerf) { + imperfectionAPA(sequence); break; - }//Other, the default case: - imperfectionAPP(sequence, notesDictionary, restsDictionary); - break; + } break; case 2: - smallNoteValue = isPenultimateValueShort(sequence, notesDictionary); - restValue = isPenultimateValueARest(sequence, restsDictionary); - if (dotOfImperf || smallNoteValue || restValue) { - imperfectionAPP(sequence, notesDictionary, restsDictionary); - imperfectionAPA(sequence, notesDictionary, restsDictionary); + //smallNoteValue = isPenultimateValueShort(sequence); + //restValue = isPenultimateValueARest(sequence); + alterationFlag = alteration(sequence); + if (!alterationFlag || dotOfImperf) { + imperfectionAPP(sequence); + imperfectionAPA(sequence); break; - }//Other, the default case: - alteration(sequence, notesDictionary, restsDictionary); - break; + } break; } } else { // For sum > 3 switch (remainder) { case 0: - smallNoteValue = isPenultimateValueShort(sequence, notesDictionary); - restValue = isPenultimateValueARest(sequence, restsDictionary); - if (dotOfPerf || smallNoteValue || restValue) { + //smallNoteValue = isPenultimateValueShort(sequence); + //restValue = isPenultimateValueARest(sequence); + impappFlag = imperfectionAPP(sequence); + alterationFlag = alteration(sequence); + if (!alterationFlag || dotOfPerf) { break; //No modifications - }//Other, the default case: - imperfectionAPP(sequence, notesDictionary, restsDictionary); - alteration(sequence, notesDictionary, restsDictionary); - break; + } break; case 1: - if (dotOfPerf) { - imperfectionAPA(sequence, notesDictionary, restsDictionary); + impappFlag = imperfectionAPP(sequence); + if (!impappFlag || dotOfPerf) { + imperfectionAPA(sequence); break; - }//Other, the default case: - imperfectionAPP(sequence, notesDictionary, restsDictionary); - break; + } break; case 2: - if (dotOfPerf || simileAnteSimile) { - alteration(sequence, notesDictionary, restsDictionary); + impappFlag = imperfectionAPP(sequence); + impapaFlag = imperfectionAPA(sequence); + if (!impappFlag || !impapaFlag ||dotOfPerf || simileAnteSimile) { + alteration(sequence); break; - }//Other, the default case: - imperfectionAPP(sequence, notesDictionary, restsDictionary); - imperfectionAPA(sequence, notesDictionary, restsDictionary); - break; + } break; } } } @@ -199,40 +187,45 @@ double durNumberValue(data_DURATION dur) { } return durnum; } -void imperfectionAPP(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ - std::string firstNoteID = sequence.at(0).first; - Note *firstNote = notesDictionary[firstNoteID]; - firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); -} - -void imperfectionAPA(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ - std::string lastNoteID = sequence.at(sequence.size()-1).first; - Note *lastNote = notesDictionary[lastNoteID]; - lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); -} - -void alteration(std::vector> sequence, std::map notesDictionary, std::map restsDictionary){ - std::string penultNoteID = sequence.at(sequence.size()-2).first; - Note *penultNote = notesDictionary[penultNoteID]; - penultNote->SetDurQuality(DURQUALITY_mensural_altera); +bool imperfectionAPP(std::vector> sequence) { + LayerElement* firstElement = sequence.at(0).first; + if (firstElement->Is(NOTE)){ + Note *firstNote = vrv_cast(firstElement); + assert(firstNote); + firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return true; + } else { + return false; + } } -bool isPenultimateValueARest(std::vector> sequence, std::map restsDictionary){ - std::string penultNoteID = sequence.at(sequence.size()-2).first; - if (restsDictionary[penultNoteID]) {return true;} - else {return false;} +bool imperfectionAPA(std::vector> sequence) { + LayerElement* lastElement = sequence.at(sequence.size()-1).first; + if (lastElement->Is(NOTE)){ + Note *lastNote = vrv_cast(lastElement); + assert(lastNote); + lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return true; + } else { + return false; + } } -bool isPenultimateValueShort(std::vector> sequence, std::map notesDictionary){ - std::string penultNoteID = sequence.at(sequence.size()-2).first; - bool smallNoteValue = false; - if (notesDictionary[penultNoteID]) { - Note *penultNote = notesDictionary[penultNoteID]; +bool alteration(std::vector> sequence){ + LayerElement* penultElement = sequence.at(sequence.size()-2).first; + if (penultElement->Is(NOTE)) { + Note *penultNote = vrv_cast(penultElement); + assert(penultNote); data_DURATION dur = penultNote->GetDur(); - if (dur == DURATION_fusa || dur == DURATION_semifusa || dur == DURATION_minima || dur == DURATION_semiminima){ - smallNoteValue = true; + if (dur == DURATION_fusa || dur == DURATION_semifusa || dur == DURATION_minima || dur == DURATION_semiminima) { + return false; + } else { + penultNote->SetDurQuality(DURQUALITY_mensural_altera); + return true; } - } return smallNoteValue; + } else { + return false; + } } } // namespace vrv From 87c1aa07b7a1cbb922bd98ddfa91386e109b838c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 20:15:57 +0200 Subject: [PATCH 30/88] Refine documentation and note values for the principles of imp and alt --- src/scoringupfunctor.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index bf421646c8..c926a1f4af 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -113,8 +113,6 @@ void findDurQuals(std::vector> sequence) bool alterationFlag, impappFlag, impapaFlag; bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) - bool smallNoteValue = false; //Flag that evaluates the value of the penultimate note in the sequence. When true, it doesn't allow for alteration - bool restValue = false; //Flag that evaluates if the penultimate value in the sequence is a rest. When true, it doesn't allow for alteration bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) // Principles of imperfection and alteration (and their exceptions). @@ -188,8 +186,10 @@ double durNumberValue(data_DURATION dur) { } bool imperfectionAPP(std::vector> sequence) { - LayerElement* firstElement = sequence.at(0).first; - if (firstElement->Is(NOTE)){ + std::pair firstElementDurPair = sequence.at(0); + LayerElement* firstElement = firstElementDurPair.first; + data_DURATION firstDur = firstElementDurPair.second; + if (firstElement->Is(NOTE) && firstDur == DURATION_brevis){ Note *firstNote = vrv_cast(firstElement); assert(firstNote); firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); @@ -200,8 +200,10 @@ bool imperfectionAPP(std::vector> sequen } bool imperfectionAPA(std::vector> sequence) { - LayerElement* lastElement = sequence.at(sequence.size()-1).first; - if (lastElement->Is(NOTE)){ + std::pair lastElementDurPair = sequence.at(sequence.size()-1); + LayerElement* lastElement = lastElementDurPair.first; + data_DURATION lastDur = lastElementDurPair.second; + if (lastElement->Is(NOTE) && lastDur == DURATION_brevis){ Note *lastNote = vrv_cast(lastElement); assert(lastNote); lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); @@ -212,16 +214,19 @@ bool imperfectionAPA(std::vector> sequen } bool alteration(std::vector> sequence){ - LayerElement* penultElement = sequence.at(sequence.size()-2).first; + std::pair penultElementDurPair = sequence.at(sequence.size()-2); + LayerElement* penultElement = penultElementDurPair.first; + //Evaluates what is the type of the penultimate element in the sequence; when it is a rest, it forbids alteration (return false). if (penultElement->Is(NOTE)) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); - data_DURATION dur = penultNote->GetDur(); - if (dur == DURATION_fusa || dur == DURATION_semifusa || dur == DURATION_minima || dur == DURATION_semiminima) { - return false; - } else { + data_DURATION penultDur = penultNote->GetDur(); + //Evaluates the value of the penultimate note in the sequence; when it is a small note value, it forbids alteration (return false); and when it is a larger note value, it alters the note (and returns true). + if (penultDur == DURATION_semibrevis) { penultNote->SetDurQuality(DURQUALITY_mensural_altera); return true; + } else { + return false; } } else { return false; From bc342844128cbba256b5a8e9c4444c31e469f04a Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 20:22:03 +0200 Subject: [PATCH 31/88] Refine comments and conditions for the principles of imp. and alt. --- src/scoringupfunctor.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c926a1f4af..f6f11c35bd 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -189,6 +189,7 @@ bool imperfectionAPP(std::vector> sequen std::pair firstElementDurPair = sequence.at(0); LayerElement* firstElement = firstElementDurPair.first; data_DURATION firstDur = firstElementDurPair.second; + /// Evaluates if the first note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If it is a rest or a larger note, then it forbids imperfection (and returns false). if (firstElement->Is(NOTE) && firstDur == DURATION_brevis){ Note *firstNote = vrv_cast(firstElement); assert(firstNote); @@ -203,6 +204,7 @@ bool imperfectionAPA(std::vector> sequen std::pair lastElementDurPair = sequence.at(sequence.size()-1); LayerElement* lastElement = lastElementDurPair.first; data_DURATION lastDur = lastElementDurPair.second; + /// Evaluates if the last note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If it is a rest or a larger note, then it forbids imperfection (and returns false). if (lastElement->Is(NOTE) && lastDur == DURATION_brevis){ Note *lastNote = vrv_cast(lastElement); assert(lastNote); @@ -216,18 +218,13 @@ bool imperfectionAPA(std::vector> sequen bool alteration(std::vector> sequence){ std::pair penultElementDurPair = sequence.at(sequence.size()-2); LayerElement* penultElement = penultElementDurPair.first; - //Evaluates what is the type of the penultimate element in the sequence; when it is a rest, it forbids alteration (return false). - if (penultElement->Is(NOTE)) { + data_DURATION penultDur = penultElementDurPair.second; + ///Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids alteration (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). + if (penultElement->Is(NOTE) && penultDur == DURATION_semibrevis) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); - data_DURATION penultDur = penultNote->GetDur(); - //Evaluates the value of the penultimate note in the sequence; when it is a small note value, it forbids alteration (return false); and when it is a larger note value, it alters the note (and returns true). - if (penultDur == DURATION_semibrevis) { - penultNote->SetDurQuality(DURQUALITY_mensural_altera); - return true; - } else { - return false; - } + penultNote->SetDurQuality(DURQUALITY_mensural_altera); + return true; } else { return false; } From 34d660fb4168ae18e2a0c8ad0e02303daf50432e Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 20:38:00 +0200 Subject: [PATCH 32/88] get default values from mensuration not working yet --- src/scoringupfunctor.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index f6f11c35bd..037bc26c30 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -107,7 +107,7 @@ void findDurQuals(std::vector> sequence) for (std::pair elementDurPair : sequence){ data_DURATION dur = elementDurPair.second; sum += durNumberValue(dur); - } + } sum = sum/2; int remainder = (int)sum % 3; bool alterationFlag, impappFlag, impapaFlag; @@ -166,21 +166,43 @@ void findDurQuals(std::vector> sequence) double durNumberValue(data_DURATION dur) { double durnum = 0; + int prolatio = 2; + int tempus = 3; + int modusminor = 2; switch(dur) { + case DURATION_longa: + if (modusminor == 2 && tempus == 2 && prolatio == 2) {durnum = 8;} + else if (modusminor == 3 && tempus == 2 && prolatio == 2) {durnum = 12;} + else if (modusminor == 2 && tempus == 3 && prolatio == 2) {durnum = 12;} + else if (modusminor == 2 && tempus == 2 && prolatio == 3) {durnum = 12;} + else if (modusminor == 3 && tempus == 3 && prolatio == 2) {durnum = 18;} + else if (modusminor == 3 && tempus == 2 && prolatio == 3) {durnum = 18;} + else if (modusminor == 2 && tempus == 3 && prolatio == 3) {durnum = 18;} + else {durnum = 27;} + break; + case DURATION_brevis: + if (tempus == 2 && prolatio == 2) {durnum = 4;} + else if (tempus == 3 && prolatio == 2) {durnum = 6;} + else if (tempus == 2 && prolatio == 3) {durnum = 6;} + else {durnum = 9;} + break; case DURATION_semibrevis: - durnum = 1; + if (prolatio == 2) {durnum = 2;} + else {durnum = 3;} break; case DURATION_minima: - durnum = 0.5; + durnum = 1; break; case DURATION_semiminima: - durnum = 0.25; + durnum = 0.5; break; case DURATION_fusa: - durnum = 0.125; + durnum = 0.25; break; case DURATION_semifusa: - durnum = 0.0625; + durnum = 0.125; + break; + default: break; } return durnum; } From b84d38390c3c2bdd4feca707044c93925a3faa3c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 21:27:57 +0200 Subject: [PATCH 33/88] Fix: only consider middle notes of the sequence and also consider the qualities of notes --- src/scoringupfunctor.cpp | 62 ++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 037bc26c30..a79159e968 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -33,7 +33,7 @@ std::vector>> subdivideSeq(s void findDurQuals(std::vector>> listOfSequences); void findDurQuals(std::vector> sequence); -double durNumberValue(data_DURATION dur); +double durNumberValue(std::pair elementDurPair); bool imperfectionAPP(std::vector> sequence); bool imperfectionAPA(std::vector> sequence); bool alteration(std::vector> sequence); @@ -103,10 +103,13 @@ void findDurQuals(std::vector> sequence){ + std::vector> middleSeq = {}; + if (sequence.size() > 2) { + middleSeq = {sequence.begin() + 1, sequence.end() - 1}; + } double sum = 0; - for (std::pair elementDurPair : sequence){ - data_DURATION dur = elementDurPair.second; - sum += durNumberValue(dur); + for (std::pair elementDurPair : middleSeq){ + sum += durNumberValue(elementDurPair); } sum = sum/2; int remainder = (int)sum % 3; @@ -164,32 +167,41 @@ void findDurQuals(std::vector> sequence) } } -double durNumberValue(data_DURATION dur) { - double durnum = 0; - int prolatio = 2; - int tempus = 3; +double durNumberValue(std::pair elementDurPair) { + data_DURQUALITY_mensural durquality; + data_DURATION dur = elementDurPair.second; + LayerElement* element = elementDurPair.first; + if (element->Is(NOTE)){ + Note *note = vrv_cast(element); + assert(note); + durquality = note->GetDurQuality(); + } int modusminor = 2; + int tempus = 3; + int prolatio = 2; + int longaDefaultVal = modusminor * tempus * prolatio; + int brevisDefaultVal = tempus * prolatio; + int semibrevisDefaultVal = prolatio; + double durnum = 0; switch(dur) { case DURATION_longa: - if (modusminor == 2 && tempus == 2 && prolatio == 2) {durnum = 8;} - else if (modusminor == 3 && tempus == 2 && prolatio == 2) {durnum = 12;} - else if (modusminor == 2 && tempus == 3 && prolatio == 2) {durnum = 12;} - else if (modusminor == 2 && tempus == 2 && prolatio == 3) {durnum = 12;} - else if (modusminor == 3 && tempus == 3 && prolatio == 2) {durnum = 18;} - else if (modusminor == 3 && tempus == 2 && prolatio == 3) {durnum = 18;} - else if (modusminor == 2 && tempus == 3 && prolatio == 3) {durnum = 18;} - else {durnum = 27;} - break; + if (modusminor == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2 * brevisDefaultVal; + } else if (modusminor == 3 || durquality == DURQUALITY_mensural_perfecta) { + durnum = 3 * brevisDefaultVal; + } break; case DURATION_brevis: - if (tempus == 2 && prolatio == 2) {durnum = 4;} - else if (tempus == 3 && prolatio == 2) {durnum = 6;} - else if (tempus == 2 && prolatio == 3) {durnum = 6;} - else {durnum = 9;} - break; + if (tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2 * semibrevisDefaultVal; + } else if (tempus == 3 || durquality == DURQUALITY_mensural_perfecta) { + durnum = 3 * semibrevisDefaultVal; + } break; case DURATION_semibrevis: - if (prolatio == 2) {durnum = 2;} - else {durnum = 3;} - break; + if (prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2; + } else if (prolatio == 3 || durquality == DURQUALITY_mensural_perfecta) { + durnum = 3; + } break; case DURATION_minima: durnum = 1; break; From 6fd9316e9eb7fae0a10eb4d37c86da958d6e40ec Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 2 Sep 2024 22:15:48 +0200 Subject: [PATCH 34/88] Save mensuration values --- src/scoringupfunctor.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index a79159e968..87251e0bdd 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -26,6 +26,7 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- +std::map mensuration; std::vector> dursInVoiceSameMensur = {}; std::vector>> listOfSequences; @@ -75,7 +76,15 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) dur = rest->GetDur(); } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {element, dur}); } else if (element->Is(MENSUR)) { - this->m_currentMensur = vrv_cast(layerElement); + this->m_currentMensur = vrv_cast(element); + if (m_currentMensur->GetModusmaior() == MODUSMAIOR_3) {mensuration["modusmaior"] = 3;} + else {mensuration["modusmaior"] = 2;} + if (m_currentMensur->GetModusminor() == MODUSMINOR_3) {mensuration["modusminor"] = 3;} + else {mensuration["modusminor"] = 2;} + if (m_currentMensur->GetTempus() == TEMPUS_3) {mensuration["tempus"] = 3;} + else {mensuration["tempus"] = 2;} + if (m_currentMensur->GetProlatio() == PROLATIO_3) {mensuration["prolatio"] = 3;} + else {mensuration["prolatio"] = 2;} }return FUNCTOR_CONTINUE; } @@ -107,12 +116,15 @@ void findDurQuals(std::vector> sequence) if (sequence.size() > 2) { middleSeq = {sequence.begin() + 1, sequence.end() - 1}; } + + // Value in minims: double sum = 0; for (std::pair elementDurPair : middleSeq){ sum += durNumberValue(elementDurPair); } sum = sum/2; - int remainder = (int)sum % 3; + + // Flags: bool alterationFlag, impappFlag, impapaFlag; bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) @@ -131,8 +143,6 @@ void findDurQuals(std::vector> sequence) break; } break; case 2: - //smallNoteValue = isPenultimateValueShort(sequence); - //restValue = isPenultimateValueARest(sequence); alterationFlag = alteration(sequence); if (!alterationFlag || dotOfImperf) { imperfectionAPP(sequence); @@ -143,8 +153,6 @@ void findDurQuals(std::vector> sequence) } else { // For sum > 3 switch (remainder) { case 0: - //smallNoteValue = isPenultimateValueShort(sequence); - //restValue = isPenultimateValueARest(sequence); impappFlag = imperfectionAPP(sequence); alterationFlag = alteration(sequence); if (!alterationFlag || dotOfPerf) { @@ -176,9 +184,9 @@ double durNumberValue(std::pair elementDurPair) { assert(note); durquality = note->GetDurQuality(); } - int modusminor = 2; - int tempus = 3; - int prolatio = 2; + int modusminor = mensuration["modusminor"]; + int tempus = mensuration["tempus"]; + int prolatio = mensuration["prolatio"]; int longaDefaultVal = modusminor * tempus * prolatio; int brevisDefaultVal = tempus * prolatio; int semibrevisDefaultVal = prolatio; From 249c0d51de0ee2cdce51845195cb3a99315edac7 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 3 Sep 2024 16:31:43 +0200 Subject: [PATCH 35/88] Add the exception case for sum = 3 --- src/scoringupfunctor.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 87251e0bdd..2fcbbbb9ab 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -38,6 +38,7 @@ double durNumberValue(std::pair elementDurPair); bool imperfectionAPP(std::vector> sequence); bool imperfectionAPA(std::vector> sequence); bool alteration(std::vector> sequence); +bool leavePerfect(std::vector> sequence); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -132,7 +133,7 @@ void findDurQuals(std::vector> sequence) // Principles of imperfection and alteration (and their exceptions). // The implementation is based on the rules outlined by Willi Apel, with perfect groupings of notes and the remainder: - if (sum <= 3) { // For sum = 0, 1, 2, or 3 + if (sum < 3) { // For sum = 0, 1, 2, or 3 switch (remainder) { case 0: break; //No modifications @@ -150,6 +151,9 @@ void findDurQuals(std::vector> sequence) break; } break; } + } else if (sum == 3){ + bool leavePerfectFlag = leavePerfect(sequence); + if (!leavePerfectFlag || dotOfImperf) {} } else { // For sum > 3 switch (remainder) { case 0: @@ -167,7 +171,7 @@ void findDurQuals(std::vector> sequence) case 2: impappFlag = imperfectionAPP(sequence); impapaFlag = imperfectionAPA(sequence); - if (!impappFlag || !impapaFlag ||dotOfPerf || simileAnteSimile) { + if (!impappFlag || !impapaFlag || dotOfPerf || simileAnteSimile) { alteration(sequence); break; } break; @@ -187,7 +191,7 @@ double durNumberValue(std::pair elementDurPair) { int modusminor = mensuration["modusminor"]; int tempus = mensuration["tempus"]; int prolatio = mensuration["prolatio"]; - int longaDefaultVal = modusminor * tempus * prolatio; + //int longaDefaultVal = modusminor * tempus * prolatio; int brevisDefaultVal = tempus * prolatio; int semibrevisDefaultVal = prolatio; double durnum = 0; @@ -272,4 +276,8 @@ bool alteration(std::vector> sequence){ } } +bool leavePerfect(std::vector> sequence){ + return true; +} + } // namespace vrv From 035746e6d59a82f450ac23618d67a94ffecce9b3 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 3 Sep 2024 16:48:00 +0200 Subject: [PATCH 36/88] Add 'dot of perfection' condition within the evaluation of imperfection app --- src/scoringupfunctor.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 2fcbbbb9ab..8424379f10 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -139,7 +139,7 @@ void findDurQuals(std::vector> sequence) break; //No modifications case 1: impappFlag = imperfectionAPP(sequence); - if (!impappFlag || dotOfPerf) { + if (!impappFlag) { imperfectionAPA(sequence); break; } break; @@ -159,19 +159,19 @@ void findDurQuals(std::vector> sequence) case 0: impappFlag = imperfectionAPP(sequence); alterationFlag = alteration(sequence); - if (!alterationFlag || dotOfPerf) { + if (!alterationFlag || !impappFlag) { break; //No modifications } break; case 1: impappFlag = imperfectionAPP(sequence); - if (!impappFlag || dotOfPerf) { + if (!impappFlag) { imperfectionAPA(sequence); break; } break; case 2: impappFlag = imperfectionAPP(sequence); impapaFlag = imperfectionAPA(sequence); - if (!impappFlag || !impapaFlag || dotOfPerf || simileAnteSimile) { + if (!impappFlag || !impapaFlag || simileAnteSimile) { alteration(sequence); break; } break; @@ -235,12 +235,19 @@ bool imperfectionAPP(std::vector> sequen std::pair firstElementDurPair = sequence.at(0); LayerElement* firstElement = firstElementDurPair.first; data_DURATION firstDur = firstElementDurPair.second; + LayerElement* nextElement; /// Evaluates if the first note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If it is a rest or a larger note, then it forbids imperfection (and returns false). - if (firstElement->Is(NOTE) && firstDur == DURATION_brevis){ - Note *firstNote = vrv_cast(firstElement); - assert(firstNote); - firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - return true; + if (firstElement->Is(NOTE) && firstDur == DURATION_brevis) { + /// Before imperfecting the starting brevis, check if it is followed by a dot. If it is, this would be a dot of perfectio, i.e., a dot that forces perfection (forbidding the imperfection and returning false). Otherwise, if there is no dot following the starting brevis, proceed to perform the imperfection a.p.p. and return true. + nextElement = sequence.at(1).first; + if (nextElement->Is(DOT)) { + return false; + } else { + Note *firstNote = vrv_cast(firstElement); + assert(firstNote); + firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return true; + } } else { return false; } From 6182cc6c3b83e848061403e6ac5ca2443f22fcdd Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 3 Sep 2024 16:54:48 +0200 Subject: [PATCH 37/88] Remove the dotOfPerf flag --- src/scoringupfunctor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 8424379f10..0d56302890 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -127,7 +127,6 @@ void findDurQuals(std::vector> sequence) // Flags: bool alterationFlag, impappFlag, impapaFlag; - bool dotOfPerf = false; //When true, it forces a perfect value bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) From 734a5f533aae9d753a02f4fac46ca9629268f484 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 3 Sep 2024 17:14:47 +0200 Subject: [PATCH 38/88] Add 'form=div' for dot of perfection --- src/scoringupfunctor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 0d56302890..b499930880 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -9,6 +9,7 @@ //---------------------------------------------------------------------------- +#include "dot.h" #include "layer.h" #include "page.h" #include "note.h" @@ -240,8 +241,12 @@ bool imperfectionAPP(std::vector> sequen /// Before imperfecting the starting brevis, check if it is followed by a dot. If it is, this would be a dot of perfectio, i.e., a dot that forces perfection (forbidding the imperfection and returning false). Otherwise, if there is no dot following the starting brevis, proceed to perform the imperfection a.p.p. and return true. nextElement = sequence.at(1).first; if (nextElement->Is(DOT)) { + /// Dot of perfection (type of dot of division) + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_div); return false; } else { + /// Imperfection a.p.p. (i.e., imperfection by the following notes) Note *firstNote = vrv_cast(firstElement); assert(firstNote); firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); From d950a875ea4a3856d5a516778aedb1171087a3ea Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 6 Sep 2024 19:03:56 +0200 Subject: [PATCH 39/88] Change formatting according to coding guidelines --- src/scoringupfunctor.cpp | 77 +++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index b499930880..3ce5edb7c9 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -9,15 +9,18 @@ //---------------------------------------------------------------------------- +#include + +//---------------------------------------------------------------------------- + #include "dot.h" #include "layer.h" -#include "page.h" #include "note.h" +#include "page.h" #include "rest.h" #include "staff.h" #include "system.h" #include "vrv.h" -#include //---------------------------------------------------------------------------- @@ -31,15 +34,15 @@ std::map mensuration; std::vector> dursInVoiceSameMensur = {}; std::vector>> listOfSequences; -std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur); +std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur); -void findDurQuals(std::vector>> listOfSequences); -void findDurQuals(std::vector> sequence); -double durNumberValue(std::pair elementDurPair); -bool imperfectionAPP(std::vector> sequence); -bool imperfectionAPA(std::vector> sequence); -bool alteration(std::vector> sequence); -bool leavePerfect(std::vector> sequence); +void FindDurQuals(std::vector>> listOfSequences); +void FindDurQuals(std::vector> sequence); +double GetDurNumberValue(std::pair elementDurPair); +bool ImperfectionAPP(std::vector> sequence); +bool ImperfectionAPA(std::vector> sequence); +bool Alteration(std::vector> sequence); +bool LeavePerfect(std::vector> sequence); ScoringUpFunctor::ScoringUpFunctor() : Functor() { @@ -53,8 +56,8 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); if (!dursInVoiceSameMensur.empty()){ - listOfSequences = subdivideSeq(dursInVoiceSameMensur); - findDurQuals(listOfSequences); + listOfSequences = SubdivideSeq(dursInVoiceSameMensur); + FindDurQuals(listOfSequences); dursInVoiceSameMensur = {}; //restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -90,7 +93,7 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) }return FUNCTOR_CONTINUE; } -std::vector>> subdivideSeq(std::vector> dursInVoiceSameMensur) +std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur) { std::vector>> listOfSequences = {}; std::vector> sequence = {}; @@ -107,13 +110,13 @@ std::vector>> subdivideSeq(s return listOfSequences; } -void findDurQuals(std::vector>> listOfSequences){ +void FindDurQuals(std::vector>> listOfSequences){ for (std::vector> subseq: listOfSequences){ - findDurQuals(subseq); + FindDurQuals(subseq); } } -void findDurQuals(std::vector> sequence){ +void FindDurQuals(std::vector> sequence){ std::vector> middleSeq = {}; if (sequence.size() > 2) { middleSeq = {sequence.begin() + 1, sequence.end() - 1}; @@ -122,7 +125,7 @@ void findDurQuals(std::vector> sequence) // Value in minims: double sum = 0; for (std::pair elementDurPair : middleSeq){ - sum += durNumberValue(elementDurPair); + sum += GetDurNumberValue(elementDurPair); } sum = sum/2; int remainder = (int)sum % 3; @@ -131,55 +134,55 @@ void findDurQuals(std::vector> sequence) bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) bool simileAnteSimile = false; //Flag that evaluates the value of the note following the last note of the sequence, checking if it is greater or equal to the last note of the sequence. When true, it doesn't allow for Imperfection a parte ante (a.p.a.) - // Principles of imperfection and alteration (and their exceptions). + // Principles of imperfection and Alteration (and their exceptions). // The implementation is based on the rules outlined by Willi Apel, with perfect groupings of notes and the remainder: if (sum < 3) { // For sum = 0, 1, 2, or 3 switch (remainder) { case 0: break; //No modifications case 1: - impappFlag = imperfectionAPP(sequence); + impappFlag = ImperfectionAPP(sequence); if (!impappFlag) { - imperfectionAPA(sequence); + ImperfectionAPA(sequence); break; } break; case 2: - alterationFlag = alteration(sequence); + alterationFlag = Alteration(sequence); if (!alterationFlag || dotOfImperf) { - imperfectionAPP(sequence); - imperfectionAPA(sequence); + ImperfectionAPP(sequence); + ImperfectionAPA(sequence); break; } break; } } else if (sum == 3){ - bool leavePerfectFlag = leavePerfect(sequence); + bool leavePerfectFlag = LeavePerfect(sequence); if (!leavePerfectFlag || dotOfImperf) {} } else { // For sum > 3 switch (remainder) { case 0: - impappFlag = imperfectionAPP(sequence); - alterationFlag = alteration(sequence); + impappFlag = ImperfectionAPP(sequence); + alterationFlag = Alteration(sequence); if (!alterationFlag || !impappFlag) { break; //No modifications } break; case 1: - impappFlag = imperfectionAPP(sequence); + impappFlag = ImperfectionAPP(sequence); if (!impappFlag) { - imperfectionAPA(sequence); + ImperfectionAPA(sequence); break; } break; case 2: - impappFlag = imperfectionAPP(sequence); - impapaFlag = imperfectionAPA(sequence); + impappFlag = ImperfectionAPP(sequence); + impapaFlag = ImperfectionAPA(sequence); if (!impappFlag || !impapaFlag || simileAnteSimile) { - alteration(sequence); + Alteration(sequence); break; } break; } } } -double durNumberValue(std::pair elementDurPair) { +double GetDurNumberValue(std::pair elementDurPair) { data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; LayerElement* element = elementDurPair.first; @@ -231,7 +234,7 @@ double durNumberValue(std::pair elementDurPair) { } return durnum; } -bool imperfectionAPP(std::vector> sequence) { +bool ImperfectionAPP(std::vector> sequence) { std::pair firstElementDurPair = sequence.at(0); LayerElement* firstElement = firstElementDurPair.first; data_DURATION firstDur = firstElementDurPair.second; @@ -257,7 +260,7 @@ bool imperfectionAPP(std::vector> sequen } } -bool imperfectionAPA(std::vector> sequence) { +bool ImperfectionAPA(std::vector> sequence) { std::pair lastElementDurPair = sequence.at(sequence.size()-1); LayerElement* lastElement = lastElementDurPair.first; data_DURATION lastDur = lastElementDurPair.second; @@ -272,11 +275,11 @@ bool imperfectionAPA(std::vector> sequen } } -bool alteration(std::vector> sequence){ +bool Alteration(std::vector> sequence){ std::pair penultElementDurPair = sequence.at(sequence.size()-2); LayerElement* penultElement = penultElementDurPair.first; data_DURATION penultDur = penultElementDurPair.second; - ///Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids alteration (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). + ///Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids Alteration (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). if (penultElement->Is(NOTE) && penultDur == DURATION_semibrevis) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); @@ -287,7 +290,7 @@ bool alteration(std::vector> sequence){ } } -bool leavePerfect(std::vector> sequence){ +bool LeavePerfect(std::vector> sequence){ return true; } From 94db5eab9dcc1d101489ecf31a4eb1c462b0f738 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 6 Sep 2024 19:23:10 +0200 Subject: [PATCH 40/88] Adjust to coding guidelines, move methods and attributes to header file --- include/vrv/scoringupfunctor.h | 14 +++++++++++--- src/scoringupfunctor.cpp | 30 ++++++++---------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index a322133b1d..22620d0df5 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -34,10 +34,17 @@ class ScoringUpFunctor : public Functor { */ bool ImplementsEndInterface() const override { return true; } - /* * Other methods */ + std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur); + void FindDurQuals(std::vector>> listOfSequences); + void FindDurQuals(std::vector> sequence); + double GetDurNumberValue(std::pair elementDurPair); + bool ImperfectionAPP(std::vector> sequence); + bool ImperfectionAPA(std::vector> sequence); + bool Alteration(std::vector> sequence); + bool LeavePerfect(std::vector> sequence); /* * Functor interface @@ -53,8 +60,9 @@ class ScoringUpFunctor : public Functor { private: // public: - //std::vector dursInVoiceSameMensur = {}; - //void findQuals(std::vector dursInVoiceSameMensur); + std::map mensuration; + std::vector> dursInVoiceSameMensur = {}; + std::vector>> listOfSequences; private: // The current score time in the measure (incremented by each element) double m_currentScoreTime; diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 3ce5edb7c9..8445a9bdbb 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -30,20 +30,6 @@ namespace vrv { // ScoringUpFunctor //---------------------------------------------------------------------------- -std::map mensuration; -std::vector> dursInVoiceSameMensur = {}; - -std::vector>> listOfSequences; -std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur); - -void FindDurQuals(std::vector>> listOfSequences); -void FindDurQuals(std::vector> sequence); -double GetDurNumberValue(std::pair elementDurPair); -bool ImperfectionAPP(std::vector> sequence); -bool ImperfectionAPA(std::vector> sequence); -bool Alteration(std::vector> sequence); -bool LeavePerfect(std::vector> sequence); - ScoringUpFunctor::ScoringUpFunctor() : Functor() { m_currentScoreTime = 0.0; @@ -93,7 +79,7 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) }return FUNCTOR_CONTINUE; } -std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur) +std::vector>> ScoringUpFunctor::SubdivideSeq(std::vector> dursInVoiceSameMensur) { std::vector>> listOfSequences = {}; std::vector> sequence = {}; @@ -110,13 +96,13 @@ std::vector>> SubdivideSeq(s return listOfSequences; } -void FindDurQuals(std::vector>> listOfSequences){ +void ScoringUpFunctor::FindDurQuals(std::vector>> listOfSequences){ for (std::vector> subseq: listOfSequences){ FindDurQuals(subseq); } } -void FindDurQuals(std::vector> sequence){ +void ScoringUpFunctor::FindDurQuals(std::vector> sequence){ std::vector> middleSeq = {}; if (sequence.size() > 2) { middleSeq = {sequence.begin() + 1, sequence.end() - 1}; @@ -182,7 +168,7 @@ void FindDurQuals(std::vector> sequence) } } -double GetDurNumberValue(std::pair elementDurPair) { +double ScoringUpFunctor::GetDurNumberValue(std::pair elementDurPair) { data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; LayerElement* element = elementDurPair.first; @@ -234,7 +220,7 @@ double GetDurNumberValue(std::pair elementDurPair) } return durnum; } -bool ImperfectionAPP(std::vector> sequence) { +bool ScoringUpFunctor::ImperfectionAPP(std::vector> sequence) { std::pair firstElementDurPair = sequence.at(0); LayerElement* firstElement = firstElementDurPair.first; data_DURATION firstDur = firstElementDurPair.second; @@ -260,7 +246,7 @@ bool ImperfectionAPP(std::vector> sequen } } -bool ImperfectionAPA(std::vector> sequence) { +bool ScoringUpFunctor::ImperfectionAPA(std::vector> sequence) { std::pair lastElementDurPair = sequence.at(sequence.size()-1); LayerElement* lastElement = lastElementDurPair.first; data_DURATION lastDur = lastElementDurPair.second; @@ -275,7 +261,7 @@ bool ImperfectionAPA(std::vector> sequen } } -bool Alteration(std::vector> sequence){ +bool ScoringUpFunctor::Alteration(std::vector> sequence){ std::pair penultElementDurPair = sequence.at(sequence.size()-2); LayerElement* penultElement = penultElementDurPair.first; data_DURATION penultDur = penultElementDurPair.second; @@ -290,7 +276,7 @@ bool Alteration(std::vector> sequence){ } } -bool LeavePerfect(std::vector> sequence){ +bool ScoringUpFunctor::LeavePerfect(std::vector> sequence){ return true; } From d9f4574ea91e756bb853eada147ddcdfd0b96b8f Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 6 Sep 2024 19:34:38 +0200 Subject: [PATCH 41/88] Add comments for meethods --- include/vrv/scoringupfunctor.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 22620d0df5..143b4469c6 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -35,16 +35,36 @@ class ScoringUpFunctor : public Functor { bool ImplementsEndInterface() const override { return true; } /* - * Other methods + * Methods */ + /** + * @name: Divide the notes of a voice into sequences to be processed individualy + */ + ///@{ std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur); + ///@} + /** + * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) + */ + ///@{ void FindDurQuals(std::vector>> listOfSequences); void FindDurQuals(std::vector> sequence); + ///@} + /** + * @name: Find the duration value of the note in minims + */ + ///@{ double GetDurNumberValue(std::pair elementDurPair); + ///@} + /** + * @name Apply principles of imperfection and alteration + */ + ///@{ bool ImperfectionAPP(std::vector> sequence); bool ImperfectionAPA(std::vector> sequence); bool Alteration(std::vector> sequence); bool LeavePerfect(std::vector> sequence); + ///@} /* * Functor interface From e03bf0d7ff2f52534fb74ef83cf9eb896bccee8a Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 6 Sep 2024 20:13:20 +0200 Subject: [PATCH 42/88] Comment code to try to get mensuration values from staffDef --- src/scoringupfunctor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 8445a9bdbb..c196a7ff6f 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -41,6 +41,11 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) { m_currentScoreTime = 0.0; m_currentMensur = layer->GetCurrentMensur(); + /*data_MODUSMAIOR modusmaior = m_currentMensur->GetModusmaior(); + data_MODUSMINOR modusminor = m_currentMensur->GetModusminor(); + data_TEMPUS tempus = m_currentMensur->GetTempus(); + data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ + // Doesn't get it from the staffDef, right?// if (!dursInVoiceSameMensur.empty()){ listOfSequences = SubdivideSeq(dursInVoiceSameMensur); FindDurQuals(listOfSequences); From fbc48bcf5a41342978f3d469872f0607bd9cbb21 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Fri, 6 Sep 2024 23:53:58 +0200 Subject: [PATCH 43/88] Add support for the voice starting in a small note value --- src/scoringupfunctor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c196a7ff6f..19a7702757 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -109,8 +109,13 @@ void ScoringUpFunctor::FindDurQuals(std::vector> sequence){ std::vector> middleSeq = {}; - if (sequence.size() > 2) { - middleSeq = {sequence.begin() + 1, sequence.end() - 1}; + if (sequence.size() >= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { + middleSeq = {sequence.begin(), sequence.end() - 1}; + } else { + middleSeq = {sequence.begin() + 1, sequence.end() - 1}; + } } // Value in minims: From f0c29ff1dc99cba71d3f6ed8a4ce983cb3cf45c2 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 7 Sep 2024 00:08:14 +0200 Subject: [PATCH 44/88] Add another exception for imp.app Already having a dur.quality (probably from being imperfected a.p.a. (a parte ante) --- src/scoringupfunctor.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 19a7702757..cae89c445b 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -245,11 +245,17 @@ bool ScoringUpFunctor::ImperfectionAPP(std::vectorSetForm(dotLog_FORM_div); return false; } else { - /// Imperfection a.p.p. (i.e., imperfection by the following notes) + /// Imperfection a.p.p. (i.e., imperfection by the following notes), unless the note has already been modified by the previous sequence Note *firstNote = vrv_cast(firstElement); assert(firstNote); - firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - return true; + if (firstNote->HasDurQuality()){ + /// Already modified before + return false; + } else { + /// Imperfection a.p.p. + firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return true; + } } } else { return false; From 30544fca62755b9accd4616cc214ec144b059343 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 7 Sep 2024 02:21:42 +0200 Subject: [PATCH 45/88] Add support for dots of augmentation (still missing the distinction of dots of imperfection -or alteration) --- include/vrv/scoringupfunctor.h | 2 +- src/scoringupfunctor.cpp | 42 ++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 143b4469c6..98fa1e2da2 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -54,7 +54,7 @@ class ScoringUpFunctor : public Functor { * @name: Find the duration value of the note in minims */ ///@{ - double GetDurNumberValue(std::pair elementDurPair); + double GetDurNumberValue(std::pair elementDurPair, bool followedByDot); ///@} /** * @name Apply principles of imperfection and alteration diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index cae89c445b..b1fa162594 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -120,8 +120,17 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair : middleSeq){ - sum += GetDurNumberValue(elementDurPair); + bool followedByDot = false; + LayerElement* nextElement; + for (int i = 0; i < middleSeq.size(); i++) { + std::pair elementDurPair = middleSeq.at(i); + // Check if there is a dot after the element being evaluated + if (i + 1 < middleSeq.size()) { + nextElement = middleSeq.at(i+1).first; + followedByDot = nextElement->Is(DOT); + } else { + followedByDot = false; + } sum += GetDurNumberValue(elementDurPair, followedByDot); } sum = sum/2; int remainder = (int)sum % 3; @@ -178,7 +187,7 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair) { +double ScoringUpFunctor::GetDurNumberValue(std::pair elementDurPair, bool followedByDot) { data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; LayerElement* element = elementDurPair.first; @@ -198,30 +207,39 @@ double ScoringUpFunctor::GetDurNumberValue(std::pair Date: Sat, 7 Sep 2024 02:39:30 +0200 Subject: [PATCH 46/88] Add the correct quality to the dotted notes And the form=aug to the dot for the samll note values (minima, semiminima, and fusa) --- include/vrv/scoringupfunctor.h | 2 +- src/scoringupfunctor.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 98fa1e2da2..44d6357224 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -54,7 +54,7 @@ class ScoringUpFunctor : public Functor { * @name: Find the duration value of the note in minims */ ///@{ - double GetDurNumberValue(std::pair elementDurPair, bool followedByDot); + double GetDurNumberValue(std::pair elementDurPair, bool followedByDot, LayerElement* nextElement); ///@} /** * @name Apply principles of imperfection and alteration diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index b1fa162594..293987a1e4 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -121,7 +121,7 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair = middleSeq.at(i); // Check if there is a dot after the element being evaluated @@ -130,7 +130,7 @@ void ScoringUpFunctor::FindDurQuals(std::vectorIs(DOT); } else { followedByDot = false; - } sum += GetDurNumberValue(elementDurPair, followedByDot); + } sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); } sum = sum/2; int remainder = (int)sum % 3; @@ -187,12 +187,13 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair, bool followedByDot) { +double ScoringUpFunctor::GetDurNumberValue(std::pair elementDurPair, bool followedByDot, LayerElement* nextElement) { data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; LayerElement* element = elementDurPair.first; + Note *note; if (element->Is(NOTE)){ - Note *note = vrv_cast(element); + note = vrv_cast(element); assert(note); durquality = note->GetDurQuality(); } @@ -225,18 +226,27 @@ double ScoringUpFunctor::GetDurNumberValue(std::pairSetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); } else { durnum = 1; } break; case DURATION_semiminima: if (followedByDot) { durnum = 0.75; + note->SetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); } else { durnum = 0.5; } break; case DURATION_fusa: if (followedByDot) { durnum = 0.375; + note->SetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); } else { durnum = 0.25; } break; From 32e0c165a1b720429f67889beb71915f3ece8b57 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 9 Sep 2024 17:26:05 +0200 Subject: [PATCH 47/88] Exchange conditions to check for dots first --- src/scoringupfunctor.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 293987a1e4..c8ea411b35 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -134,6 +134,9 @@ void ScoringUpFunctor::FindDurQuals(std::vector IS IT INTEGER when dot of division??? + // CHECK REMAINDER + // Flags: bool alterationFlag, impappFlag, impapaFlag; bool dotOfImperf = false; //When true, it forces imperfection a parte post (a.p.p.) @@ -161,7 +164,9 @@ void ScoringUpFunctor::FindDurQuals(std::vector 3 switch (remainder) { case 0: @@ -206,22 +211,22 @@ double ScoringUpFunctor::GetDurNumberValue(std::pair Date: Mon, 9 Sep 2024 17:39:24 +0200 Subject: [PATCH 48/88] Add progress towardsimplementation of dots of division --- src/scoringupfunctor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c8ea411b35..5287f96f71 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -118,6 +118,18 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair : middleSeq) { + if (elementDurPair.first->Is(DOT)){ + numberOfDots=+1; + } + } if (numberOfDots >= 1) { + // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) + // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away from the end of the sequence, and if the rest of the sequence still sums an integer number) + // If neither, all dots are dots of augmentation + } + // Value in minims: double sum = 0; bool followedByDot = false; From c5e3887a9ce428e411f626a9ddd8da70579424b8 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 9 Sep 2024 17:54:29 +0200 Subject: [PATCH 49/88] Store the array of dots positions in middleSeq --- src/scoringupfunctor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 5287f96f71..596e8c7769 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -119,15 +119,23 @@ void ScoringUpFunctor::FindDurQuals(std::vector elementDurPair : middleSeq) { + std::vector indecesOfDots; + for (int i = 0; i < middleSeq.size(); i++) { + std::pair elementDurPair = middleSeq.at(i); if (elementDurPair.first->Is(DOT)){ - numberOfDots=+1; + indecesOfDots.insert(indecesOfDots.end(), i); } - } if (numberOfDots >= 1) { + } + int numberOfDots = (int)indecesOfDots.size(); + if (numberOfDots >= 1) { // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) + // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away from the end of the sequence, and if the rest of the sequence still sums an integer number) + // If neither, all dots are dots of augmentation + if (numberOfDots == 1){ + + } } // Value in minims: From fccc32f25429bd8af40f8ef3dcf2d400d80d8090 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 25 Sep 2024 23:46:30 +0200 Subject: [PATCH 50/88] Reformat --- include/vrv/scoringupfunctor.h | 31 ++-- src/scoringupfunctor.cpp | 276 +++++++++++++++++++++------------ 2 files changed, 190 insertions(+), 117 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 44d6357224..021a1c656c 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -28,7 +28,7 @@ class ScoringUpFunctor : public Functor { ScoringUpFunctor(); virtual ~ScoringUpFunctor() = default; ///@} - + /* * Abstract base implementation */ @@ -41,31 +41,33 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ - std::vector>> SubdivideSeq(std::vector> dursInVoiceSameMensur); + std::vector>> SubdivideSeq( + std::vector> dursInVoiceSameMensur); ///@} /** * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) */ ///@{ - void FindDurQuals(std::vector>> listOfSequences); - void FindDurQuals(std::vector> sequence); + void FindDurQuals(std::vector>> listOfSequences); + void FindDurQuals(std::vector> sequence); ///@} /** - * @name: Find the duration value of the note in minims - */ + * @name: Find the duration value of the note in minims + */ ///@{ - double GetDurNumberValue(std::pair elementDurPair, bool followedByDot, LayerElement* nextElement); + double GetDurNumberValue( + std::pair elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} /** * @name Apply principles of imperfection and alteration */ ///@{ - bool ImperfectionAPP(std::vector> sequence); - bool ImperfectionAPA(std::vector> sequence); - bool Alteration(std::vector> sequence); - bool LeavePerfect(std::vector> sequence); + bool ImperfectionAPP(std::vector> sequence); + bool ImperfectionAPA(std::vector> sequence); + bool Alteration(std::vector> sequence); + bool LeavePerfect(std::vector> sequence); ///@} - + /* * Functor interface */ @@ -81,8 +83,9 @@ class ScoringUpFunctor : public Functor { // public: std::map mensuration; - std::vector> dursInVoiceSameMensur = {}; - std::vector>> listOfSequences; + std::vector> dursInVoiceSameMensur = {}; + std::vector>> listOfSequences; + private: // The current score time in the measure (incremented by each element) double m_currentScoreTime; diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 596e8c7769..da7c6144e6 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -46,10 +46,10 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_TEMPUS tempus = m_currentMensur->GetTempus(); data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// - if (!dursInVoiceSameMensur.empty()){ + if (!dursInVoiceSameMensur.empty()) { listOfSequences = SubdivideSeq(dursInVoiceSameMensur); FindDurQuals(listOfSequences); - dursInVoiceSameMensur = {}; //restart for next voice (layer) + dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; } @@ -66,92 +66,126 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) Note *note = vrv_cast(element); assert(note); dur = note->GetDur(); - } else if (element->Is(REST)) { + } + else if (element->Is(REST)) { Rest *rest = vrv_cast(element); assert(rest); dur = rest->GetDur(); - } dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), {element, dur}); - } else if (element->Is(MENSUR)) { + } + dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), { element, dur }); + } + else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(element); - if (m_currentMensur->GetModusmaior() == MODUSMAIOR_3) {mensuration["modusmaior"] = 3;} - else {mensuration["modusmaior"] = 2;} - if (m_currentMensur->GetModusminor() == MODUSMINOR_3) {mensuration["modusminor"] = 3;} - else {mensuration["modusminor"] = 2;} - if (m_currentMensur->GetTempus() == TEMPUS_3) {mensuration["tempus"] = 3;} - else {mensuration["tempus"] = 2;} - if (m_currentMensur->GetProlatio() == PROLATIO_3) {mensuration["prolatio"] = 3;} - else {mensuration["prolatio"] = 2;} - }return FUNCTOR_CONTINUE; + if (m_currentMensur->GetModusmaior() == MODUSMAIOR_3) { + mensuration["modusmaior"] = 3; + } + else { + mensuration["modusmaior"] = 2; + } + if (m_currentMensur->GetModusminor() == MODUSMINOR_3) { + mensuration["modusminor"] = 3; + } + else { + mensuration["modusminor"] = 2; + } + if (m_currentMensur->GetTempus() == TEMPUS_3) { + mensuration["tempus"] = 3; + } + else { + mensuration["tempus"] = 2; + } + if (m_currentMensur->GetProlatio() == PROLATIO_3) { + mensuration["prolatio"] = 3; + } + else { + mensuration["prolatio"] = 2; + } + } + return FUNCTOR_CONTINUE; } -std::vector>> ScoringUpFunctor::SubdivideSeq(std::vector> dursInVoiceSameMensur) +std::vector>> ScoringUpFunctor::SubdivideSeq( + std::vector> dursInVoiceSameMensur) { - std::vector>> listOfSequences = {}; - std::vector> sequence = {}; - for(std::pair elementDurPair : dursInVoiceSameMensur){ + std::vector>> listOfSequences = {}; + std::vector> sequence = {}; + for (std::pair elementDurPair : dursInVoiceSameMensur) { data_DURATION dur = elementDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { sequence.insert(sequence.end(), elementDurPair); listOfSequences.insert(listOfSequences.end(), sequence); - sequence = {elementDurPair}; - } else { + sequence = { elementDurPair }; + } + else { sequence.insert(sequence.end(), elementDurPair); - }LogDebug("dur is:", dur); + } + LogDebug("dur is:", dur); } return listOfSequences; } -void ScoringUpFunctor::FindDurQuals(std::vector>> listOfSequences){ - for (std::vector> subseq: listOfSequences){ +void ScoringUpFunctor::FindDurQuals(std::vector>> listOfSequences) +{ + for (std::vector> subseq : listOfSequences) { FindDurQuals(subseq); } } -void ScoringUpFunctor::FindDurQuals(std::vector> sequence){ - std::vector> middleSeq = {}; +void ScoringUpFunctor::FindDurQuals(std::vector> sequence) +{ + std::vector> middleSeq = {}; if (sequence.size() >= 2) { data_DURATION firstNoteDur = sequence.at(0).second; - if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { - middleSeq = {sequence.begin(), sequence.end() - 1}; - } else { - middleSeq = {sequence.begin() + 1, sequence.end() - 1}; + if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima + || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa + || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; } } - // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the possibility of being a dot of imperfection (or alteration) or a dot of augmentation---the dots of perfection are not in the middleSeq. + // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the + // possibility of being a dot of imperfection (or alteration) or a dot of augmentation---the dots of perfection are + // not in the middleSeq. std::vector indecesOfDots; for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); - if (elementDurPair.first->Is(DOT)){ + std::pair elementDurPair = middleSeq.at(i); + if (elementDurPair.first->Is(DOT)) { indecesOfDots.insert(indecesOfDots.end(), i); } } int numberOfDots = (int)indecesOfDots.size(); if (numberOfDots >= 1) { - // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) - - // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away from the end of the sequence, and if the rest of the sequence still sums an integer number) - + // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" + // away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) + + // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away + // from the end of the sequence, and if the rest of the sequence still sums an integer number) + // If neither, all dots are dots of augmentation - if (numberOfDots == 1){ - + if (numberOfDots == 1) { } } // Value in minims: double sum = 0; bool followedByDot = false; - LayerElement* nextElement = NULL; + LayerElement *nextElement = NULL; for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); + std::pair elementDurPair = middleSeq.at(i); // Check if there is a dot after the element being evaluated if (i + 1 < middleSeq.size()) { - nextElement = middleSeq.at(i+1).first; + nextElement = middleSeq.at(i + 1).first; followedByDot = nextElement->Is(DOT); - } else { + } + else { followedByDot = false; - } sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); - } sum = sum/2; + } + sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); + } + sum = sum / 2; int remainder = (int)sum % 3; // CHECK SUM --> IS IT INTEGER when dot of division??? @@ -159,65 +193,75 @@ void ScoringUpFunctor::FindDurQuals(std::vector 3 + } + else { // For sum > 3 switch (remainder) { case 0: impappFlag = ImperfectionAPP(sequence); alterationFlag = Alteration(sequence); if (!alterationFlag || !impappFlag) { - break; //No modifications - } break; + break; // No modifications + } + break; case 1: impappFlag = ImperfectionAPP(sequence); if (!impappFlag) { ImperfectionAPA(sequence); break; - } break; + } + break; case 2: impappFlag = ImperfectionAPP(sequence); impapaFlag = ImperfectionAPA(sequence); if (!impappFlag || !impapaFlag || simileAnteSimile) { Alteration(sequence); break; - } break; + } + break; } } } -double ScoringUpFunctor::GetDurNumberValue(std::pair elementDurPair, bool followedByDot, LayerElement* nextElement) { +double ScoringUpFunctor::GetDurNumberValue( + std::pair elementDurPair, bool followedByDot, LayerElement *nextElement) +{ data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; - LayerElement* element = elementDurPair.first; + LayerElement *element = elementDurPair.first; Note *note; - if (element->Is(NOTE)){ + if (element->Is(NOTE)) { note = vrv_cast(element); assert(note); durquality = note->GetDurQuality(); @@ -225,127 +269,153 @@ double ScoringUpFunctor::GetDurNumberValue(std::pairSetDurQuality(DURQUALITY_mensural_perfecta); Dot *dot = vrv_cast(nextElement); dot->SetForm(dotLog_FORM_aug); - } else { + } + else { durnum = 1; - } break; + } + break; case DURATION_semiminima: if (followedByDot) { durnum = 0.75; note->SetDurQuality(DURQUALITY_mensural_perfecta); Dot *dot = vrv_cast(nextElement); dot->SetForm(dotLog_FORM_aug); - } else { + } + else { durnum = 0.5; - } break; + } + break; case DURATION_fusa: if (followedByDot) { durnum = 0.375; note->SetDurQuality(DURQUALITY_mensural_perfecta); Dot *dot = vrv_cast(nextElement); dot->SetForm(dotLog_FORM_aug); - } else { + } + else { durnum = 0.25; - } break; - case DURATION_semifusa: - durnum = 0.125; - break; - default: + } break; - } return durnum; + case DURATION_semifusa: durnum = 0.125; break; + default: break; + } + return durnum; } -bool ScoringUpFunctor::ImperfectionAPP(std::vector> sequence) { - std::pair firstElementDurPair = sequence.at(0); - LayerElement* firstElement = firstElementDurPair.first; +bool ScoringUpFunctor::ImperfectionAPP(std::vector> sequence) +{ + std::pair firstElementDurPair = sequence.at(0); + LayerElement *firstElement = firstElementDurPair.first; data_DURATION firstDur = firstElementDurPair.second; - LayerElement* nextElement; - /// Evaluates if the first note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If it is a rest or a larger note, then it forbids imperfection (and returns false). + LayerElement *nextElement; + /// Evaluates if the first note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If + /// it is a rest or a larger note, then it forbids imperfection (and returns false). if (firstElement->Is(NOTE) && firstDur == DURATION_brevis) { - /// Before imperfecting the starting brevis, check if it is followed by a dot. If it is, this would be a dot of perfectio, i.e., a dot that forces perfection (forbidding the imperfection and returning false). Otherwise, if there is no dot following the starting brevis, proceed to perform the imperfection a.p.p. and return true. + /// Before imperfecting the starting brevis, check if it is followed by a dot. If it is, this would be a dot of + /// perfectio, i.e., a dot that forces perfection (forbidding the imperfection and returning false). Otherwise, + /// if there is no dot following the starting brevis, proceed to perform the imperfection a.p.p. and return + /// true. nextElement = sequence.at(1).first; if (nextElement->Is(DOT)) { /// Dot of perfection (type of dot of division) Dot *dot = vrv_cast(nextElement); dot->SetForm(dotLog_FORM_div); return false; - } else { - /// Imperfection a.p.p. (i.e., imperfection by the following notes), unless the note has already been modified by the previous sequence + } + else { + /// Imperfection a.p.p. (i.e., imperfection by the following notes), unless the note has already been + /// modified by the previous sequence Note *firstNote = vrv_cast(firstElement); assert(firstNote); - if (firstNote->HasDurQuality()){ + if (firstNote->HasDurQuality()) { /// Already modified before return false; - } else { + } + else { /// Imperfection a.p.p. firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); return true; } } - } else { + } + else { return false; } } -bool ScoringUpFunctor::ImperfectionAPA(std::vector> sequence) { - std::pair lastElementDurPair = sequence.at(sequence.size()-1); - LayerElement* lastElement = lastElementDurPair.first; +bool ScoringUpFunctor::ImperfectionAPA(std::vector> sequence) +{ + std::pair lastElementDurPair = sequence.at(sequence.size() - 1); + LayerElement *lastElement = lastElementDurPair.first; data_DURATION lastDur = lastElementDurPair.second; - /// Evaluates if the last note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If it is a rest or a larger note, then it forbids imperfection (and returns false). - if (lastElement->Is(NOTE) && lastDur == DURATION_brevis){ + /// Evaluates if the last note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If + /// it is a rest or a larger note, then it forbids imperfection (and returns false). + if (lastElement->Is(NOTE) && lastDur == DURATION_brevis) { Note *lastNote = vrv_cast(lastElement); assert(lastNote); lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); return true; - } else { + } + else { return false; } } -bool ScoringUpFunctor::Alteration(std::vector> sequence){ - std::pair penultElementDurPair = sequence.at(sequence.size()-2); - LayerElement* penultElement = penultElementDurPair.first; +bool ScoringUpFunctor::Alteration(std::vector> sequence) +{ + std::pair penultElementDurPair = sequence.at(sequence.size() - 2); + LayerElement *penultElement = penultElementDurPair.first; data_DURATION penultDur = penultElementDurPair.second; - ///Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids Alteration (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). + /// Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids Alteration + /// (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). if (penultElement->Is(NOTE) && penultDur == DURATION_semibrevis) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); penultNote->SetDurQuality(DURQUALITY_mensural_altera); return true; - } else { + } + else { return false; } } -bool ScoringUpFunctor::LeavePerfect(std::vector> sequence){ +bool ScoringUpFunctor::LeavePerfect(std::vector> sequence) +{ return true; } From 6f91e0f6d7107ca79b37f1cc6c3ab7386111f4f3 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 25 Sep 2024 23:50:48 +0200 Subject: [PATCH 51/88] Reformat --- include/vrv/doc.h | 2 +- src/layer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 841fab1ca5..b875049d85 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -376,7 +376,7 @@ class Doc : public Object { * Calls the scoringUpFunctor and applies it. */ void ScoringUpDoc(); - + /** * Sync the coordinate provided trought to m_drawingFacsX/Y. * Call the SyncToFacsimile functor. diff --git a/src/layer.cpp b/src/layer.cpp index 38a2947d24..47da893f3f 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -525,7 +525,7 @@ Mensur *Layer::GetCurrentMensur() const Mensur *Layer::GetCurrentMensur() const { const Staff *staff = vrv_cast(this->GetFirstAncestor(STAFF)); - //assert(staff && staff->m_drawingStaffDef); + // assert(staff && staff->m_drawingStaffDef); return staff->m_drawingStaffDef->GetCurrentMensur(); } From 722c2333be7413f6c11a3ddeedee909b77eaf786 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 2 Oct 2024 22:21:50 +0200 Subject: [PATCH 52/88] Add blank lines in header file --- include/vrv/scoringupfunctor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 021a1c656c..135285c29a 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -44,6 +44,7 @@ class ScoringUpFunctor : public Functor { std::vector>> SubdivideSeq( std::vector> dursInVoiceSameMensur); ///@} + /** * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) */ @@ -51,6 +52,7 @@ class ScoringUpFunctor : public Functor { void FindDurQuals(std::vector>> listOfSequences); void FindDurQuals(std::vector> sequence); ///@} + /** * @name: Find the duration value of the note in minims */ @@ -58,6 +60,7 @@ class ScoringUpFunctor : public Functor { double GetDurNumberValue( std::pair elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} + /** * @name Apply principles of imperfection and alteration */ From bb92458c5bc058fc0c77ba1307c691759a8a2840 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 2 Oct 2024 22:41:31 +0200 Subject: [PATCH 53/88] Add typedef for ArrayOfElementDurPairs --- include/vrv/scoringupfunctor.h | 19 +++++++++---------- include/vrv/vrvdef.h | 2 ++ src/scoringupfunctor.cpp | 23 +++++++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 135285c29a..7b3620c445 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -41,16 +41,15 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ - std::vector>> SubdivideSeq( - std::vector> dursInVoiceSameMensur); + std::vector SubdivideSeq(ArrayOfElementDurPairs dursInVoiceSameMensur); ///@} /** * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) */ ///@{ - void FindDurQuals(std::vector>> listOfSequences); - void FindDurQuals(std::vector> sequence); + void FindDurQuals(std::vector listOfSequences); + void FindDurQuals(ArrayOfElementDurPairs sequence); ///@} /** @@ -65,10 +64,10 @@ class ScoringUpFunctor : public Functor { * @name Apply principles of imperfection and alteration */ ///@{ - bool ImperfectionAPP(std::vector> sequence); - bool ImperfectionAPA(std::vector> sequence); - bool Alteration(std::vector> sequence); - bool LeavePerfect(std::vector> sequence); + bool ImperfectionAPP(ArrayOfElementDurPairs sequence); + bool ImperfectionAPA(ArrayOfElementDurPairs sequence); + bool Alteration(ArrayOfElementDurPairs sequence); + bool LeavePerfect(ArrayOfElementDurPairs sequence); ///@} /* @@ -86,8 +85,8 @@ class ScoringUpFunctor : public Functor { // public: std::map mensuration; - std::vector> dursInVoiceSameMensur = {}; - std::vector>> listOfSequences; + ArrayOfElementDurPairs dursInVoiceSameMensur = {}; + std::vector listOfSequences; private: // The current score time in the measure (incremented by each element) diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 66c40feceb..d5a8ca028e 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -397,6 +397,8 @@ typedef std::vector> MeasureTieEndpoin typedef bool (*NotePredicate)(const Note *); +typedef std::vector> 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 diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index da7c6144e6..8adf116dc5 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -104,11 +104,10 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) return FUNCTOR_CONTINUE; } -std::vector>> ScoringUpFunctor::SubdivideSeq( - std::vector> dursInVoiceSameMensur) +std::vector ScoringUpFunctor::SubdivideSeq(ArrayOfElementDurPairs dursInVoiceSameMensur) { - std::vector>> listOfSequences = {}; - std::vector> sequence = {}; + std::vector listOfSequences = {}; + ArrayOfElementDurPairs sequence = {}; for (std::pair elementDurPair : dursInVoiceSameMensur) { data_DURATION dur = elementDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { @@ -124,16 +123,16 @@ std::vector>> ScoringUpFunc return listOfSequences; } -void ScoringUpFunctor::FindDurQuals(std::vector>> listOfSequences) +void ScoringUpFunctor::FindDurQuals(std::vector listOfSequences) { - for (std::vector> subseq : listOfSequences) { + for (ArrayOfElementDurPairs subseq : listOfSequences) { FindDurQuals(subseq); } } -void ScoringUpFunctor::FindDurQuals(std::vector> sequence) +void ScoringUpFunctor::FindDurQuals(ArrayOfElementDurPairs sequence) { - std::vector> middleSeq = {}; + ArrayOfElementDurPairs middleSeq = {}; if (sequence.size() >= 2) { data_DURATION firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima @@ -337,7 +336,7 @@ double ScoringUpFunctor::GetDurNumberValue( return durnum; } -bool ScoringUpFunctor::ImperfectionAPP(std::vector> sequence) +bool ScoringUpFunctor::ImperfectionAPP(ArrayOfElementDurPairs sequence) { std::pair firstElementDurPair = sequence.at(0); LayerElement *firstElement = firstElementDurPair.first; @@ -378,7 +377,7 @@ bool ScoringUpFunctor::ImperfectionAPP(std::vector> sequence) +bool ScoringUpFunctor::ImperfectionAPA(ArrayOfElementDurPairs sequence) { std::pair lastElementDurPair = sequence.at(sequence.size() - 1); LayerElement *lastElement = lastElementDurPair.first; @@ -396,7 +395,7 @@ bool ScoringUpFunctor::ImperfectionAPA(std::vector> sequence) +bool ScoringUpFunctor::Alteration(ArrayOfElementDurPairs sequence) { std::pair penultElementDurPair = sequence.at(sequence.size() - 2); LayerElement *penultElement = penultElementDurPair.first; @@ -414,7 +413,7 @@ bool ScoringUpFunctor::Alteration(std::vector> sequence) +bool ScoringUpFunctor::LeavePerfect(ArrayOfElementDurPairs sequence) { return true; } From 22e491de9ad686d1679f0b7a0416412b29b624cf Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Wed, 2 Oct 2024 23:47:22 +0200 Subject: [PATCH 54/88] Remove initialization --- include/vrv/scoringupfunctor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 7b3620c445..e9e3fa38b9 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -85,7 +85,7 @@ class ScoringUpFunctor : public Functor { // public: std::map mensuration; - ArrayOfElementDurPairs dursInVoiceSameMensur = {}; + ArrayOfElementDurPairs dursInVoiceSameMensur; std::vector listOfSequences; private: From 6834c9abbbf28197d0b48026206172bfab6c241c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 3 Oct 2024 00:07:21 +0200 Subject: [PATCH 55/88] Change vectors to be read-only parameters in functions --- include/vrv/scoringupfunctor.h | 14 +++++++------- src/scoringupfunctor.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index e9e3fa38b9..8752dd0054 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -41,15 +41,15 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ - std::vector SubdivideSeq(ArrayOfElementDurPairs dursInVoiceSameMensur); + std::vector SubdivideSeq(const ArrayOfElementDurPairs &dursInVoiceSameMensur); ///@} /** * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) */ ///@{ - void FindDurQuals(std::vector listOfSequences); - void FindDurQuals(ArrayOfElementDurPairs sequence); + void FindDurQuals(const std::vector &listOfSequences); + void FindDurQuals(const ArrayOfElementDurPairs &sequence); ///@} /** @@ -64,10 +64,10 @@ class ScoringUpFunctor : public Functor { * @name Apply principles of imperfection and alteration */ ///@{ - bool ImperfectionAPP(ArrayOfElementDurPairs sequence); - bool ImperfectionAPA(ArrayOfElementDurPairs sequence); - bool Alteration(ArrayOfElementDurPairs sequence); - bool LeavePerfect(ArrayOfElementDurPairs sequence); + bool ImperfectionAPP(const ArrayOfElementDurPairs &sequence); + bool ImperfectionAPA(const ArrayOfElementDurPairs &sequence); + bool Alteration(const ArrayOfElementDurPairs &sequence); + bool LeavePerfect(const ArrayOfElementDurPairs &sequence); ///@} /* diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 8adf116dc5..b190fff442 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -104,7 +104,7 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) return FUNCTOR_CONTINUE; } -std::vector ScoringUpFunctor::SubdivideSeq(ArrayOfElementDurPairs dursInVoiceSameMensur) +std::vector ScoringUpFunctor::SubdivideSeq(const ArrayOfElementDurPairs &dursInVoiceSameMensur) { std::vector listOfSequences = {}; ArrayOfElementDurPairs sequence = {}; @@ -123,14 +123,14 @@ std::vector ScoringUpFunctor::SubdivideSeq(ArrayOfElemen return listOfSequences; } -void ScoringUpFunctor::FindDurQuals(std::vector listOfSequences) +void ScoringUpFunctor::FindDurQuals(const std::vector &listOfSequences) { for (ArrayOfElementDurPairs subseq : listOfSequences) { FindDurQuals(subseq); } } -void ScoringUpFunctor::FindDurQuals(ArrayOfElementDurPairs sequence) +void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) { ArrayOfElementDurPairs middleSeq = {}; if (sequence.size() >= 2) { @@ -336,7 +336,7 @@ double ScoringUpFunctor::GetDurNumberValue( return durnum; } -bool ScoringUpFunctor::ImperfectionAPP(ArrayOfElementDurPairs sequence) +bool ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) { std::pair firstElementDurPair = sequence.at(0); LayerElement *firstElement = firstElementDurPair.first; @@ -377,7 +377,7 @@ bool ScoringUpFunctor::ImperfectionAPP(ArrayOfElementDurPairs sequence) } } -bool ScoringUpFunctor::ImperfectionAPA(ArrayOfElementDurPairs sequence) +bool ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) { std::pair lastElementDurPair = sequence.at(sequence.size() - 1); LayerElement *lastElement = lastElementDurPair.first; @@ -395,7 +395,7 @@ bool ScoringUpFunctor::ImperfectionAPA(ArrayOfElementDurPairs sequence) } } -bool ScoringUpFunctor::Alteration(ArrayOfElementDurPairs sequence) +bool ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) { std::pair penultElementDurPair = sequence.at(sequence.size() - 2); LayerElement *penultElement = penultElementDurPair.first; @@ -413,7 +413,7 @@ bool ScoringUpFunctor::Alteration(ArrayOfElementDurPairs sequence) } } -bool ScoringUpFunctor::LeavePerfect(ArrayOfElementDurPairs sequence) +bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence) { return true; } From ff5dbd6e38583a6575c8d00e4d693cb8524d92a6 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 3 Oct 2024 01:38:45 +0200 Subject: [PATCH 56/88] Add 'm_' to all member variables --- include/vrv/scoringupfunctor.h | 6 +++--- src/scoringupfunctor.cpp | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 8752dd0054..5f1627c66e 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -84,9 +84,9 @@ class ScoringUpFunctor : public Functor { private: // public: - std::map mensuration; - ArrayOfElementDurPairs dursInVoiceSameMensur; - std::vector listOfSequences; + std::map m_mensuration; + ArrayOfElementDurPairs m_dursInVoiceSameMensur; + std::vector m_listOfSequences; private: // The current score time in the measure (incremented by each element) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index b190fff442..0134992002 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -46,10 +46,10 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_TEMPUS tempus = m_currentMensur->GetTempus(); data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// - if (!dursInVoiceSameMensur.empty()) { - listOfSequences = SubdivideSeq(dursInVoiceSameMensur); - FindDurQuals(listOfSequences); - dursInVoiceSameMensur = {}; // restart for next voice (layer) + if (!m_dursInVoiceSameMensur.empty()) { + m_listOfSequences = SubdivideSeq(m_dursInVoiceSameMensur); + FindDurQuals(m_listOfSequences); + m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; } @@ -72,33 +72,33 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) assert(rest); dur = rest->GetDur(); } - dursInVoiceSameMensur.insert(dursInVoiceSameMensur.end(), { element, dur }); + m_dursInVoiceSameMensur.insert(m_dursInVoiceSameMensur.end(), { element, dur }); } else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(element); if (m_currentMensur->GetModusmaior() == MODUSMAIOR_3) { - mensuration["modusmaior"] = 3; + m_mensuration["modusmaior"] = 3; } else { - mensuration["modusmaior"] = 2; + m_mensuration["modusmaior"] = 2; } if (m_currentMensur->GetModusminor() == MODUSMINOR_3) { - mensuration["modusminor"] = 3; + m_mensuration["modusminor"] = 3; } else { - mensuration["modusminor"] = 2; + m_mensuration["modusminor"] = 2; } if (m_currentMensur->GetTempus() == TEMPUS_3) { - mensuration["tempus"] = 3; + m_mensuration["tempus"] = 3; } else { - mensuration["tempus"] = 2; + m_mensuration["tempus"] = 2; } if (m_currentMensur->GetProlatio() == PROLATIO_3) { - mensuration["prolatio"] = 3; + m_mensuration["prolatio"] = 3; } else { - mensuration["prolatio"] = 2; + m_mensuration["prolatio"] = 2; } } return FUNCTOR_CONTINUE; @@ -265,9 +265,9 @@ double ScoringUpFunctor::GetDurNumberValue( assert(note); durquality = note->GetDurQuality(); } - int modusminor = mensuration["modusminor"]; - int tempus = mensuration["tempus"]; - int prolatio = mensuration["prolatio"]; + int modusminor = m_mensuration["modusminor"]; + int tempus = m_mensuration["tempus"]; + int prolatio = m_mensuration["prolatio"]; // int longaDefaultVal = modusminor * tempus * prolatio; int brevisDefaultVal = tempus * prolatio; int semibrevisDefaultVal = prolatio; From 3a74f034efa58dc6917746eb7cecabde0af4b0f6 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 3 Oct 2024 07:21:03 +0200 Subject: [PATCH 57/88] Separate functionalities for modifications into evaluation of whether the modification is applicable and actually applying the modification. This fixed an issue for the cases where sum > 3 and either the remainder was 0 or 2. In these cases, part of the default modification and the full alternative modification were applied at the same time (which was wrong, as only the alternative modification was intended). --- include/vrv/scoringupfunctor.h | 6 +- src/scoringupfunctor.cpp | 117 +++++++++++++++++++++++---------- 2 files changed, 86 insertions(+), 37 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 5f1627c66e..61a78f79a0 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -64,9 +64,9 @@ class ScoringUpFunctor : public Functor { * @name Apply principles of imperfection and alteration */ ///@{ - bool ImperfectionAPP(const ArrayOfElementDurPairs &sequence); - bool ImperfectionAPA(const ArrayOfElementDurPairs &sequence); - bool Alteration(const ArrayOfElementDurPairs &sequence); + Note *ImperfectionAPP(const ArrayOfElementDurPairs &sequence); + Note *ImperfectionAPA(const ArrayOfElementDurPairs &sequence); + Note *Alteration(const ArrayOfElementDurPairs &sequence); bool LeavePerfect(const ArrayOfElementDurPairs &sequence); ///@} diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 0134992002..ce8c77d9e7 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -190,8 +190,16 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) // CHECK SUM --> IS IT INTEGER when dot of division??? // CHECK REMAINDER - // Flags: - bool alterationFlag, impappFlag, impapaFlag; + // Candidates and Flags: + /// The following 'candidate' variables are used to evaluate whether a note is a candidate for a given context-based + /// modification (i.e., imperfection app, imperfection apa, or alteration). When the 'candidate' variable is NULL, + /// then the note is not candidate for that given type of modification (e.g., when alterationCandidate is NULL, the + /// penultimate note of the sequence is not a candidate for alteration; when the impappCandidate is NULL, the first + /// note of the sequence is not candidate for an imperfection a parte post; and when the impapaCandidate is NULL, + /// the last note of the sequence is not candidate for an imperfection a parte ante). + Note *impappCandidate; + Note *impapaCandidate; + Note *alterationCandidate; bool dotOfImperf = false; // When true, it forces imperfection a parte post (a.p.p.) bool simileAnteSimile = false; // Flag that evaluates the value of the note following the last note of the sequence, // checking if it is greater or equal to the last note of the sequence. When true, it @@ -204,19 +212,38 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) switch (remainder) { case 0: break; // No modifications case 1: - impappFlag = ImperfectionAPP(sequence); - if (!impappFlag) { - ImperfectionAPA(sequence); + // Evaluate 'default' case: Imperfection APP + impappCandidate = ImperfectionAPP(sequence); + if (impappCandidate) { + impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } + // Evaluate 'alternative' case: Imperfection APA + impapaCandidate = ImperfectionAPA(sequence); + if (impapaCandidate) { + impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + break; + } + // No case + std::cout << "NO OPTION!" << std::endl; break; case 2: - alterationFlag = Alteration(sequence); - if (!alterationFlag || dotOfImperf) { - ImperfectionAPP(sequence); - ImperfectionAPA(sequence); + // Evaluate 'default' case: Alteration + alterationCandidate = Alteration(sequence); + if (alterationCandidate && !dotOfImperf) { + alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); + break; + } + // Evaluate 'alternative' case: Imperfection APP and Imperfection APA + impappCandidate = ImperfectionAPP(sequence); + impapaCandidate = ImperfectionAPA(sequence); + if (impappCandidate && impapaCandidate) { + impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } + // No case + std::cout << "NO OPTION!" << std::endl; break; } } @@ -228,26 +255,48 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) else { // For sum > 3 switch (remainder) { case 0: - impappFlag = ImperfectionAPP(sequence); - alterationFlag = Alteration(sequence); - if (!alterationFlag || !impappFlag) { - break; // No modifications + // Evaluate 'default' case: Imperfection APP and Alteration + impappCandidate = ImperfectionAPP(sequence); + alterationCandidate = Alteration(sequence); + if (impappCandidate && alterationCandidate) { + impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); + break; } + // Evaluate 'alternative' case: No modifications break; case 1: - impappFlag = ImperfectionAPP(sequence); - if (!impappFlag) { - ImperfectionAPA(sequence); + // Evaluate 'default' case: Imperfection APP + impappCandidate = ImperfectionAPP(sequence); + if (impappCandidate) { + impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } + // Evaluate 'alternative' case: Imperfection APA + impapaCandidate = ImperfectionAPA(sequence); + if (impapaCandidate) { + impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + break; + } // No case + std::cout << "NO OPTION!" << std::endl; break; case 2: - impappFlag = ImperfectionAPP(sequence); - impapaFlag = ImperfectionAPA(sequence); - if (!impappFlag || !impapaFlag || simileAnteSimile) { - Alteration(sequence); + // Evaluate 'default' case: Imperfection APP and Imperfection APA + impappCandidate = ImperfectionAPP(sequence); + impapaCandidate = ImperfectionAPA(sequence); + if (impappCandidate && impapaCandidate && !simileAnteSimile) { + impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); + break; + } + // Evaluate 'alternative' case: Alteration + alterationCandidate = Alteration(sequence); + if (alterationCandidate) { + alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); break; } + // No case + std::cout << "NO OPTION!" << std::endl; break; } } @@ -336,7 +385,7 @@ double ScoringUpFunctor::GetDurNumberValue( return durnum; } -bool ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) { std::pair firstElementDurPair = sequence.at(0); LayerElement *firstElement = firstElementDurPair.first; @@ -354,7 +403,7 @@ bool ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) /// Dot of perfection (type of dot of division) Dot *dot = vrv_cast(nextElement); dot->SetForm(dotLog_FORM_div); - return false; + return NULL; } else { /// Imperfection a.p.p. (i.e., imperfection by the following notes), unless the note has already been @@ -363,21 +412,21 @@ bool ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) assert(firstNote); if (firstNote->HasDurQuality()) { /// Already modified before - return false; + return NULL; } else { /// Imperfection a.p.p. - firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - return true; + // firstNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return firstNote; } } } else { - return false; + return NULL; } } -bool ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) { std::pair lastElementDurPair = sequence.at(sequence.size() - 1); LayerElement *lastElement = lastElementDurPair.first; @@ -387,15 +436,15 @@ bool ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) if (lastElement->Is(NOTE) && lastDur == DURATION_brevis) { Note *lastNote = vrv_cast(lastElement); assert(lastNote); - lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); - return true; + // lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); + return lastNote; } else { - return false; + return NULL; } } -bool ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) { std::pair penultElementDurPair = sequence.at(sequence.size() - 2); LayerElement *penultElement = penultElementDurPair.first; @@ -405,11 +454,11 @@ bool ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) if (penultElement->Is(NOTE) && penultDur == DURATION_semibrevis) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); - penultNote->SetDurQuality(DURQUALITY_mensural_altera); - return true; + // penultNote->SetDurQuality(DURQUALITY_mensural_altera); + return penultNote; } else { - return false; + return NULL; } } From 422a372df7de0fa4690868e3b78676085d5a61c0 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 14:26:38 -0300 Subject: [PATCH 58/88] Rename variables --- include/vrv/scoringupfunctor.h | 2 +- src/scoringupfunctor.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 61a78f79a0..387d06a375 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -41,7 +41,7 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ - std::vector SubdivideSeq(const ArrayOfElementDurPairs &dursInVoiceSameMensur); + std::vector SubdivideIntoBoundedSequences(const ArrayOfElementDurPairs &dursInVoiceSameMensur); ///@} /** diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index ce8c77d9e7..c1b697747e 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -47,7 +47,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { - m_listOfSequences = SubdivideSeq(m_dursInVoiceSameMensur); + m_listOfSequences = SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur); FindDurQuals(m_listOfSequences); m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } @@ -104,23 +104,23 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) return FUNCTOR_CONTINUE; } -std::vector ScoringUpFunctor::SubdivideSeq(const ArrayOfElementDurPairs &dursInVoiceSameMensur) +std::vector ScoringUpFunctor::SubdivideIntoBoundedSequences(const ArrayOfElementDurPairs &dursInVoiceSameMensur) { - std::vector listOfSequences = {}; - ArrayOfElementDurPairs sequence = {}; + std::vector listOfBoundedSequences = {}; + ArrayOfElementDurPairs boundedSequence = {}; for (std::pair elementDurPair : dursInVoiceSameMensur) { data_DURATION dur = elementDurPair.second; if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { - sequence.insert(sequence.end(), elementDurPair); - listOfSequences.insert(listOfSequences.end(), sequence); - sequence = { elementDurPair }; + boundedSequence.insert(boundedSequence.end(), elementDurPair); + listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); + boundedSequence = { elementDurPair }; } else { - sequence.insert(sequence.end(), elementDurPair); + boundedSequence.insert(boundedSequence.end(), elementDurPair); } LogDebug("dur is:", dur); } - return listOfSequences; + return listOfBoundedSequences; } void ScoringUpFunctor::FindDurQuals(const std::vector &listOfSequences) From 596f8f19121b8f960084bc98c98ce3ba3e6d08a1 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 14:32:07 -0300 Subject: [PATCH 59/88] Fix pair parameter in GetNumberValue to avoid copying the sequence and to avoid modification (using '&' and 'const') --- include/vrv/scoringupfunctor.h | 4 ++-- src/scoringupfunctor.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 387d06a375..47bc343e2d 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -56,8 +56,8 @@ class ScoringUpFunctor : public Functor { * @name: Find the duration value of the note in minims */ ///@{ - double GetDurNumberValue( - std::pair elementDurPair, bool followedByDot, LayerElement *nextElement); + double GetDurNumberValue(const + std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} /** diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index c1b697747e..d6d8a3c69f 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -303,7 +303,7 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) } double ScoringUpFunctor::GetDurNumberValue( - std::pair elementDurPair, bool followedByDot, LayerElement *nextElement) + const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement) { data_DURQUALITY_mensural durquality; data_DURATION dur = elementDurPair.second; From d90b0594b67d37781edf2c5ccc10ff4aa8154238 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 14:33:27 -0300 Subject: [PATCH 60/88] Reformat code --- include/vrv/scoringupfunctor.h | 7 ++++--- src/scoringupfunctor.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 47bc343e2d..5dc8a2d342 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -41,7 +41,8 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ - std::vector SubdivideIntoBoundedSequences(const ArrayOfElementDurPairs &dursInVoiceSameMensur); + std::vector SubdivideIntoBoundedSequences( + const ArrayOfElementDurPairs &dursInVoiceSameMensur); ///@} /** @@ -56,8 +57,8 @@ class ScoringUpFunctor : public Functor { * @name: Find the duration value of the note in minims */ ///@{ - double GetDurNumberValue(const - std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); + double GetDurNumberValue( + const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} /** diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index d6d8a3c69f..53cf62eaa0 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -104,7 +104,8 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) return FUNCTOR_CONTINUE; } -std::vector ScoringUpFunctor::SubdivideIntoBoundedSequences(const ArrayOfElementDurPairs &dursInVoiceSameMensur) +std::vector ScoringUpFunctor::SubdivideIntoBoundedSequences( + const ArrayOfElementDurPairs &dursInVoiceSameMensur) { std::vector listOfBoundedSequences = {}; ArrayOfElementDurPairs boundedSequence = {}; From 8abab6eafb18be5ec64843b5dba351869e2956db Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 16:43:58 -0300 Subject: [PATCH 61/88] Regroup code into smaller functions and deal with dots of perf --- include/vrv/scoringupfunctor.h | 7 ++- src/scoringupfunctor.cpp | 109 +++++++++++++++++++++++++-------- 2 files changed, 90 insertions(+), 26 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 5dc8a2d342..b563d9b21c 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -49,14 +49,17 @@ class ScoringUpFunctor : public Functor { * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) */ ///@{ - void FindDurQuals(const std::vector &listOfSequences); - void FindDurQuals(const ArrayOfElementDurPairs &sequence); + void ProcessBoundedSequences(const std::vector &listOfSequences); + void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); + void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); ///@} /** * @name: Find the duration value of the note in minims */ ///@{ + double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq); + double GetValueInUnit(double valueInMinims, data_DURATION unit); double GetDurNumberValue( const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 53cf62eaa0..bb173b842d 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -48,7 +48,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { m_listOfSequences = SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur); - FindDurQuals(m_listOfSequences); + ProcessBoundedSequences(m_listOfSequences); m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -124,16 +124,17 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen return listOfBoundedSequences; } -void ScoringUpFunctor::FindDurQuals(const std::vector &listOfSequences) +void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) { for (ArrayOfElementDurPairs subseq : listOfSequences) { - FindDurQuals(subseq); + ProcessBoundedSequences(subseq); } } -void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) +void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) { ArrayOfElementDurPairs middleSeq = {}; + if (sequence.size() >= 2) { data_DURATION firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima @@ -157,7 +158,42 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) } } int numberOfDots = (int)indecesOfDots.size(); - if (numberOfDots >= 1) { + // 0. No dots + double sum; + if (numberOfDots == 0) { + sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); + FindDurQuals(sequence, sum); + } + // 1. Single dot in middle sequence sequence + if (numberOfDots == 1) { + // If there is one dot, + int dotInd = indecesOfDots.at(0); + ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; + ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; + double sum1 = GetValueInUnit(GetValueInMinims(middleSeq1), DURATION_semibrevis); + double sum2 = GetValueInUnit(GetValueInMinims(middleSeq2), DURATION_semibrevis); + // This condition is to discard it being a dot of perfection + if (middleSeq1.size() != 0) { + // This other condition is to evaluate if it is a dot of division + if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { + // This is a dot of division + ArrayOfElementDurPairs seq1 ={sequence.begin(), sequence.begin() + dotInd }; + ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 1, sequence.end() }; + FindDurQuals(seq1, sum1); + FindDurQuals(seq2, sum2); + } else { + // This is a dot of augmentation + sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); + FindDurQuals(sequence, sum); + } + } + else { + sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); + FindDurQuals(sequence, sum); + } + } + // 3. More than one dot in middle sequence + else if (numberOfDots > 1) { // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" // away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) @@ -165,27 +201,11 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) // from the end of the sequence, and if the rest of the sequence still sums an integer number) // If neither, all dots are dots of augmentation - if (numberOfDots == 1) { - } } +} - // Value in minims: - double sum = 0; - bool followedByDot = false; - LayerElement *nextElement = NULL; - for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); - // Check if there is a dot after the element being evaluated - if (i + 1 < middleSeq.size()) { - nextElement = middleSeq.at(i + 1).first; - followedByDot = nextElement->Is(DOT); - } - else { - followedByDot = false; - } - sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); - } - sum = sum / 2; +void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit) { + double sum = valueInSmallerUnit; //JUST IN THIS CASE int remainder = (int)sum % 3; // CHECK SUM --> IS IT INTEGER when dot of division??? @@ -302,6 +322,47 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence) } } } +double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSeq){ + // Value in minims: + double sum = 0; + bool followedByDot = false; + LayerElement *nextElement = NULL; + for (int i = 0; i < middleSeq.size(); i++) { + std::pair elementDurPair = middleSeq.at(i); + // Check if there is a dot after the element being evaluated + if (i + 1 < middleSeq.size()) { + nextElement = middleSeq.at(i + 1).first; + followedByDot = nextElement->Is(DOT); + } + else { + followedByDot = false; + } + sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); + } + return sum; +} + +double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit){ + double valueInUnit = 0.0; + if (unit == DURATION_semibrevis){ + valueInUnit = valueInMinims / 2; + //imperfect mensur + //MISSING perfect mensur + } else if (unit == DURATION_brevis){ + valueInUnit = valueInMinims / 4; + //imperfect mensur + //MISSING perfect mensur + } else if (unit == DURATION_longa){ + valueInUnit = valueInMinims / 8; + //imperfect mensur + //MISSING perfect mensur + } else if (unit == DURATION_maxima){ + valueInUnit = valueInMinims / 16; + //imperfect mensur + //MISSING perfect mensur + } + return valueInUnit; +} double ScoringUpFunctor::GetDurNumberValue( const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement) From 6f7ce997cadb6dd6191e8deae2f0fe51f83a5024 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 17:02:32 -0300 Subject: [PATCH 62/88] Rearraging code into smaller functions --- include/vrv/scoringupfunctor.h | 1 + src/scoringupfunctor.cpp | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index b563d9b21c..3a0ecf0470 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -50,6 +50,7 @@ class ScoringUpFunctor : public Functor { */ ///@{ void ProcessBoundedSequences(const std::vector &listOfSequences); + ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); ///@} diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index bb173b842d..16e8a2924f 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -124,17 +124,8 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen return listOfBoundedSequences; } -void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) -{ - for (ArrayOfElementDurPairs subseq : listOfSequences) { - ProcessBoundedSequences(subseq); - } -} - -void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) -{ +ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDurPairs &sequence) { ArrayOfElementDurPairs middleSeq = {}; - if (sequence.size() >= 2) { data_DURATION firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima @@ -146,6 +137,19 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; } } + return middleSeq; +} + +void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) +{ + for (ArrayOfElementDurPairs subseq : listOfSequences) { + ProcessBoundedSequences(subseq); + } +} + +void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) +{ + ArrayOfElementDurPairs middleSeq = GetBoundedNotes(sequence); // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the // possibility of being a dot of imperfection (or alteration) or a dot of augmentation---the dots of perfection are From d8f6917d045f8721d8c908e04aac2c1a326dac15 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 17:03:13 -0300 Subject: [PATCH 63/88] Reformat --- src/scoringupfunctor.cpp | 46 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 16e8a2924f..a9a4f874e9 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -124,7 +124,8 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen return listOfBoundedSequences; } -ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDurPairs &sequence) { +ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDurPairs &sequence) +{ ArrayOfElementDurPairs middleSeq = {}; if (sequence.size() >= 2) { data_DURATION firstNoteDur = sequence.at(0).second; @@ -181,11 +182,12 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // This other condition is to evaluate if it is a dot of division if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { // This is a dot of division - ArrayOfElementDurPairs seq1 ={sequence.begin(), sequence.begin() + dotInd }; + ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd }; ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 1, sequence.end() }; FindDurQuals(seq1, sum1); FindDurQuals(seq2, sum2); - } else { + } + else { // This is a dot of augmentation sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); FindDurQuals(sequence, sum); @@ -208,8 +210,9 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq } } -void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit) { - double sum = valueInSmallerUnit; //JUST IN THIS CASE +void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit) +{ + double sum = valueInSmallerUnit; // JUST IN THIS CASE int remainder = (int)sum % 3; // CHECK SUM --> IS IT INTEGER when dot of division??? @@ -326,7 +329,8 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub } } } -double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSeq){ +double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSeq) +{ // Value in minims: double sum = 0; bool followedByDot = false; @@ -346,24 +350,28 @@ double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSe return sum; } -double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit){ +double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit) +{ double valueInUnit = 0.0; - if (unit == DURATION_semibrevis){ + if (unit == DURATION_semibrevis) { valueInUnit = valueInMinims / 2; - //imperfect mensur - //MISSING perfect mensur - } else if (unit == DURATION_brevis){ + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_brevis) { valueInUnit = valueInMinims / 4; - //imperfect mensur - //MISSING perfect mensur - } else if (unit == DURATION_longa){ + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_longa) { valueInUnit = valueInMinims / 8; - //imperfect mensur - //MISSING perfect mensur - } else if (unit == DURATION_maxima){ + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_maxima) { valueInUnit = valueInMinims / 16; - //imperfect mensur - //MISSING perfect mensur + // imperfect mensur + // MISSING perfect mensur } return valueInUnit; } From 7616ee12e204bd58a1ccfb4cd6071a89136bee7c Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 17:12:09 -0300 Subject: [PATCH 64/88] Minor changes --- include/vrv/scoringupfunctor.h | 4 ++-- src/scoringupfunctor.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 3a0ecf0470..5046fa25ed 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -50,8 +50,8 @@ class ScoringUpFunctor : public Functor { */ ///@{ void ProcessBoundedSequences(const std::vector &listOfSequences); - ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); + ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); ///@} @@ -59,8 +59,8 @@ class ScoringUpFunctor : public Functor { * @name: Find the duration value of the note in minims */ ///@{ - double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq); double GetValueInUnit(double valueInMinims, data_DURATION unit); + double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq); double GetDurNumberValue( const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); ///@} diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index a9a4f874e9..7d741493e7 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -143,13 +143,14 @@ ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDur void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) { - for (ArrayOfElementDurPairs subseq : listOfSequences) { - ProcessBoundedSequences(subseq); + for (ArrayOfElementDurPairs sequence : listOfSequences) { + ProcessBoundedSequences(sequence); } } void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) { + // Get the notes in the middle of the boundaries of the sequence ArrayOfElementDurPairs middleSeq = GetBoundedNotes(sequence); // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the From 0d1564625f61770a80b87ab09e26ff276bfca4f4 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 17:37:32 -0300 Subject: [PATCH 65/88] Fix support for dot of division (when only on dot in sequence) Still need to implement >1, and also the check the dot of aug --- src/scoringupfunctor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 7d741493e7..0ed7d73127 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -171,7 +171,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq FindDurQuals(sequence, sum); } // 1. Single dot in middle sequence sequence - if (numberOfDots == 1) { + else if (numberOfDots == 1) { // If there is one dot, int dotInd = indecesOfDots.at(0); ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; @@ -183,8 +183,8 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // This other condition is to evaluate if it is a dot of division if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { // This is a dot of division - ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd }; - ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 1, sequence.end() }; + ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; + ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; FindDurQuals(seq1, sum1); FindDurQuals(seq2, sum2); } From c78c42f68dbcede61a3dd7ae06fb2cdc64ea462b Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 21:41:29 -0300 Subject: [PATCH 66/88] Add 'form = div' --- src/scoringupfunctor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 0ed7d73127..932f1cd9b2 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -158,7 +158,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // not in the middleSeq. std::vector indecesOfDots; for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); + std::pair elementDurPair = middleSeq.at(i); if (elementDurPair.first->Is(DOT)) { indecesOfDots.insert(indecesOfDots.end(), i); } @@ -182,9 +182,14 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq if (middleSeq1.size() != 0) { // This other condition is to evaluate if it is a dot of division if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { - // This is a dot of division + // This is a "dot of division" that divides the sequence into the following two: ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; + // Encode the dot of division: + LayerElement* dotElement = sequence.at(dotInd + 1).first; + Dot *dot = vrv_cast(dotElement); + dot->SetForm(dotLog_FORM_div); + // Encode its effect on the notes preceding and following: FindDurQuals(seq1, sum1); FindDurQuals(seq2, sum2); } From 0246a333b54b1fa128d7e6cb2b063e779924b34f Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 21:42:08 -0300 Subject: [PATCH 67/88] Reformat --- src/scoringupfunctor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 932f1cd9b2..56024cffdc 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -158,7 +158,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // not in the middleSeq. std::vector indecesOfDots; for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); + std::pair elementDurPair = middleSeq.at(i); if (elementDurPair.first->Is(DOT)) { indecesOfDots.insert(indecesOfDots.end(), i); } @@ -186,7 +186,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; // Encode the dot of division: - LayerElement* dotElement = sequence.at(dotInd + 1).first; + LayerElement *dotElement = sequence.at(dotInd + 1).first; Dot *dot = vrv_cast(dotElement); dot->SetForm(dotLog_FORM_div); // Encode its effect on the notes preceding and following: From 126ee36ef080a98cf05dcee40df92abc9f8229a5 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 22:33:23 -0300 Subject: [PATCH 68/88] Move the dot of division evaluation into a function --- include/vrv/scoringupfunctor.h | 1 + src/scoringupfunctor.cpp | 60 +++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 5046fa25ed..4eef9cd6de 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -52,6 +52,7 @@ class ScoringUpFunctor : public Functor { void ProcessBoundedSequences(const std::vector &listOfSequences); void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); + bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd); void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); ///@} diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 56024cffdc..446f675cc4 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -141,6 +141,37 @@ ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDur return middleSeq; } +bool ScoringUpFunctor::EvalDotOfDiv( + const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd) +{ + // Initial assumption: the sequence doesn't have a dot of division + bool flagDotOfDiv = false; + // Evaluate if the dot passed to the method (by the dotInd) is behaving as a dot of division + ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; + ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; + double sum1 = GetValueInUnit(GetValueInMinims(middleSeq1), DURATION_semibrevis); + double sum2 = GetValueInUnit(GetValueInMinims(middleSeq2), DURATION_semibrevis); + // This condition is to discard it being a dot of perfection + if (middleSeq1.size() != 0) { + // This other condition is to evaluate if it is a dot of division + if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { + // This is a "dot of division" + flagDotOfDiv = true; + // Then it divides the sequence into the following two: + ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; + ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; + // Encode the dot of division: + LayerElement *dotElement = sequence.at(dotInd + 1).first; + Dot *dot = vrv_cast(dotElement); + dot->SetForm(dotLog_FORM_div); + // Encode its effect on the notes preceding and following: + FindDurQuals(seq1, sum1); + FindDurQuals(seq2, sum2); + } + } + return flagDotOfDiv; +} + void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) { for (ArrayOfElementDurPairs sequence : listOfSequences) { @@ -174,32 +205,9 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq else if (numberOfDots == 1) { // If there is one dot, int dotInd = indecesOfDots.at(0); - ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; - ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; - double sum1 = GetValueInUnit(GetValueInMinims(middleSeq1), DURATION_semibrevis); - double sum2 = GetValueInUnit(GetValueInMinims(middleSeq2), DURATION_semibrevis); - // This condition is to discard it being a dot of perfection - if (middleSeq1.size() != 0) { - // This other condition is to evaluate if it is a dot of division - if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { - // This is a "dot of division" that divides the sequence into the following two: - ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; - ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; - // Encode the dot of division: - LayerElement *dotElement = sequence.at(dotInd + 1).first; - Dot *dot = vrv_cast(dotElement); - dot->SetForm(dotLog_FORM_div); - // Encode its effect on the notes preceding and following: - FindDurQuals(seq1, sum1); - FindDurQuals(seq2, sum2); - } - else { - // This is a dot of augmentation - sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); - FindDurQuals(sequence, sum); - } - } - else { + bool isDotOfDiv = EvalDotOfDiv(middleSeq, sequence, dotInd); + if (not isDotOfDiv) { + // This is a dot of augmentation sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); FindDurQuals(sequence, sum); } From 41319caacd494a41dbe425f44bbcc48db4e5d5d3 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 12 Oct 2024 22:34:01 -0300 Subject: [PATCH 69/88] Add case numberOfDots > 1 still need to test it --- src/scoringupfunctor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 446f675cc4..39ead7e2c2 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -216,11 +216,20 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq else if (numberOfDots > 1) { // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" // away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) + int startDotInd = indecesOfDots.at(0); + bool isStartDotOfDiv = EvalDotOfDiv(middleSeq, sequence, startDotInd); // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away // from the end of the sequence, and if the rest of the sequence still sums an integer number) + int endDotInd = indecesOfDots.at(indecesOfDots.size() - 1); + bool isEndDotOfDiv = EvalDotOfDiv(middleSeq, sequence, endDotInd); // If neither, all dots are dots of augmentation + if (not isStartDotOfDiv and not isEndDotOfDiv) { + // This is a dot of augmentation + sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); + FindDurQuals(sequence, sum); + } } } From e3d9e0cf0ef661de01aaf40eb066f8a565d5e0d5 Mon Sep 17 00:00:00 2001 From: "Martha E. Thomae" Date: Thu, 17 Oct 2024 02:41:52 +0200 Subject: [PATCH 70/88] Update ImplementsEndInterface Co-authored-by: David Bauer <63608463+brdvd@users.noreply.github.com> --- include/vrv/scoringupfunctor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 4eef9cd6de..9890643957 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -32,7 +32,7 @@ class ScoringUpFunctor : public Functor { /* * Abstract base implementation */ - bool ImplementsEndInterface() const override { return true; } + bool ImplementsEndInterface() const override { return false; } /* * Methods From be9553cf00468177442847e6a9de969e11a8383b Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 17 Oct 2024 02:44:44 +0200 Subject: [PATCH 71/88] Make variables private --- include/vrv/scoringupfunctor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 9890643957..92afef92da 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -88,11 +88,11 @@ class ScoringUpFunctor : public Functor { protected: // private: - // -public: std::map m_mensuration; ArrayOfElementDurPairs m_dursInVoiceSameMensur; std::vector m_listOfSequences; +public: + // private: // The current score time in the measure (incremented by each element) From 4f3a424af275ecdeb47cfb99980a09dbe64c2288 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 17 Oct 2024 02:45:27 +0200 Subject: [PATCH 72/88] Reformatting --- include/vrv/scoringupfunctor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 92afef92da..341d884a00 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -91,6 +91,7 @@ class ScoringUpFunctor : public Functor { std::map m_mensuration; ArrayOfElementDurPairs m_dursInVoiceSameMensur; std::vector m_listOfSequences; + public: // From 47314b5ba17aded46816084fb69d04ae7720804f Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 17 Oct 2024 03:13:12 +0200 Subject: [PATCH 73/88] Change to use int members --- include/vrv/scoringupfunctor.h | 5 ++++- src/scoringupfunctor.cpp | 37 ++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 341d884a00..e8be589393 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -88,7 +88,10 @@ class ScoringUpFunctor : public Functor { protected: // private: - std::map m_mensuration; + int m_modusMaior; + int m_modusMinor; + int m_tempus; + int m_prolatio; ArrayOfElementDurPairs m_dursInVoiceSameMensur; std::vector m_listOfSequences; diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 39ead7e2c2..3dab113977 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -77,28 +77,28 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) else if (element->Is(MENSUR)) { this->m_currentMensur = vrv_cast(element); if (m_currentMensur->GetModusmaior() == MODUSMAIOR_3) { - m_mensuration["modusmaior"] = 3; + m_modusMaior = 3; } else { - m_mensuration["modusmaior"] = 2; + m_modusMaior = 2; } if (m_currentMensur->GetModusminor() == MODUSMINOR_3) { - m_mensuration["modusminor"] = 3; + m_modusMinor = 3; } else { - m_mensuration["modusminor"] = 2; + m_modusMinor = 2; } if (m_currentMensur->GetTempus() == TEMPUS_3) { - m_mensuration["tempus"] = 3; + m_tempus = 3; } else { - m_mensuration["tempus"] = 2; + m_tempus = 2; } if (m_currentMensur->GetProlatio() == PROLATIO_3) { - m_mensuration["prolatio"] = 3; + m_prolatio = 3; } else { - m_mensuration["prolatio"] = 2; + m_prolatio = 2; } } return FUNCTOR_CONTINUE; @@ -411,35 +411,32 @@ double ScoringUpFunctor::GetDurNumberValue( assert(note); durquality = note->GetDurQuality(); } - int modusminor = m_mensuration["modusminor"]; - int tempus = m_mensuration["tempus"]; - int prolatio = m_mensuration["prolatio"]; - // int longaDefaultVal = modusminor * tempus * prolatio; - int brevisDefaultVal = tempus * prolatio; - int semibrevisDefaultVal = prolatio; + // int longaDefaultVal = m_modusMinor * m_tempus * m_prolatio; + int brevisDefaultVal = m_tempus * m_prolatio; + int semibrevisDefaultVal = m_prolatio; double durnum = 0; switch (dur) { case DURATION_longa: - if (modusminor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * brevisDefaultVal; } - else if (modusminor == 2 || durquality == DURQUALITY_mensural_imperfecta) { + else if (m_modusMinor == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2 * brevisDefaultVal; } break; case DURATION_brevis: - if (tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * semibrevisDefaultVal; } - else if (tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { + else if (m_tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2 * semibrevisDefaultVal; } break; case DURATION_semibrevis: - if (prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3; } - else if (prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { + else if (m_prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2; } break; From 585804ad6515d7d64cf748a4213b01ff89905c54 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 17 Oct 2024 03:38:20 +0200 Subject: [PATCH 74/88] Add 'this->' for method calls --- src/scoringupfunctor.cpp | 62 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 3dab113977..a86d1a6bbb 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -47,8 +47,8 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { - m_listOfSequences = SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur); - ProcessBoundedSequences(m_listOfSequences); + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur); + this->ProcessBoundedSequences(m_listOfSequences); m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; @@ -149,8 +149,8 @@ bool ScoringUpFunctor::EvalDotOfDiv( // Evaluate if the dot passed to the method (by the dotInd) is behaving as a dot of division ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; - double sum1 = GetValueInUnit(GetValueInMinims(middleSeq1), DURATION_semibrevis); - double sum2 = GetValueInUnit(GetValueInMinims(middleSeq2), DURATION_semibrevis); + double sum1 = this->GetValueInUnit(this->GetValueInMinims(middleSeq1), DURATION_semibrevis); + double sum2 = this->GetValueInUnit(this->GetValueInMinims(middleSeq2), DURATION_semibrevis); // This condition is to discard it being a dot of perfection if (middleSeq1.size() != 0) { // This other condition is to evaluate if it is a dot of division @@ -165,8 +165,8 @@ bool ScoringUpFunctor::EvalDotOfDiv( Dot *dot = vrv_cast(dotElement); dot->SetForm(dotLog_FORM_div); // Encode its effect on the notes preceding and following: - FindDurQuals(seq1, sum1); - FindDurQuals(seq2, sum2); + this->FindDurQuals(seq1, sum1); + this->FindDurQuals(seq2, sum2); } } return flagDotOfDiv; @@ -175,14 +175,14 @@ bool ScoringUpFunctor::EvalDotOfDiv( void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) { for (ArrayOfElementDurPairs sequence : listOfSequences) { - ProcessBoundedSequences(sequence); + this->ProcessBoundedSequences(sequence); } } void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) { // Get the notes in the middle of the boundaries of the sequence - ArrayOfElementDurPairs middleSeq = GetBoundedNotes(sequence); + ArrayOfElementDurPairs middleSeq = this->GetBoundedNotes(sequence); // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the // possibility of being a dot of imperfection (or alteration) or a dot of augmentation---the dots of perfection are @@ -198,18 +198,18 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // 0. No dots double sum; if (numberOfDots == 0) { - sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); - FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); + this->FindDurQuals(sequence, sum); } // 1. Single dot in middle sequence sequence else if (numberOfDots == 1) { // If there is one dot, int dotInd = indecesOfDots.at(0); - bool isDotOfDiv = EvalDotOfDiv(middleSeq, sequence, dotInd); + bool isDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, dotInd); if (not isDotOfDiv) { // This is a dot of augmentation - sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); - FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); + this->FindDurQuals(sequence, sum); } } // 3. More than one dot in middle sequence @@ -217,18 +217,18 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" // away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) int startDotInd = indecesOfDots.at(0); - bool isStartDotOfDiv = EvalDotOfDiv(middleSeq, sequence, startDotInd); + bool isStartDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, startDotInd); // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away // from the end of the sequence, and if the rest of the sequence still sums an integer number) int endDotInd = indecesOfDots.at(indecesOfDots.size() - 1); - bool isEndDotOfDiv = EvalDotOfDiv(middleSeq, sequence, endDotInd); + bool isEndDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, endDotInd); // If neither, all dots are dots of augmentation if (not isStartDotOfDiv and not isEndDotOfDiv) { // This is a dot of augmentation - sum = GetValueInUnit(GetValueInMinims(middleSeq), DURATION_semibrevis); - FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); + this->FindDurQuals(sequence, sum); } } } @@ -264,13 +264,13 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub case 0: break; // No modifications case 1: // Evaluate 'default' case: Imperfection APP - impappCandidate = ImperfectionAPP(sequence); + impappCandidate = this->ImperfectionAPP(sequence); if (impappCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Imperfection APA - impapaCandidate = ImperfectionAPA(sequence); + impapaCandidate = this->ImperfectionAPA(sequence); if (impapaCandidate) { impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; @@ -280,14 +280,14 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 2: // Evaluate 'default' case: Alteration - alterationCandidate = Alteration(sequence); + alterationCandidate = this->Alteration(sequence); if (alterationCandidate && !dotOfImperf) { alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); break; } // Evaluate 'alternative' case: Imperfection APP and Imperfection APA - impappCandidate = ImperfectionAPP(sequence); - impapaCandidate = ImperfectionAPA(sequence); + impappCandidate = this->ImperfectionAPP(sequence); + impapaCandidate = this->ImperfectionAPA(sequence); if (impappCandidate && impapaCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); @@ -299,7 +299,7 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub } } else if (sum == 3) { - bool leavePerfectFlag = LeavePerfect(sequence); + bool leavePerfectFlag = this->LeavePerfect(sequence); if (!leavePerfectFlag || dotOfImperf) { } } @@ -307,8 +307,8 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub switch (remainder) { case 0: // Evaluate 'default' case: Imperfection APP and Alteration - impappCandidate = ImperfectionAPP(sequence); - alterationCandidate = Alteration(sequence); + impappCandidate = this->ImperfectionAPP(sequence); + alterationCandidate = this->Alteration(sequence); if (impappCandidate && alterationCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); @@ -318,13 +318,13 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 1: // Evaluate 'default' case: Imperfection APP - impappCandidate = ImperfectionAPP(sequence); + impappCandidate = this->ImperfectionAPP(sequence); if (impappCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Imperfection APA - impapaCandidate = ImperfectionAPA(sequence); + impapaCandidate = this->ImperfectionAPA(sequence); if (impapaCandidate) { impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; @@ -333,15 +333,15 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 2: // Evaluate 'default' case: Imperfection APP and Imperfection APA - impappCandidate = ImperfectionAPP(sequence); - impapaCandidate = ImperfectionAPA(sequence); + impappCandidate = this->ImperfectionAPP(sequence); + impapaCandidate = this->ImperfectionAPA(sequence); if (impappCandidate && impapaCandidate && !simileAnteSimile) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Alteration - alterationCandidate = Alteration(sequence); + alterationCandidate = this->Alteration(sequence); if (alterationCandidate) { alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); break; @@ -368,7 +368,7 @@ double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSe else { followedByDot = false; } - sum += GetDurNumberValue(elementDurPair, followedByDot, nextElement); + sum += this->GetDurNumberValue(elementDurPair, followedByDot, nextElement); } return sum; } From c19e5542b1f2b75dcea087d3d150168c66d4080a Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:05:34 +0200 Subject: [PATCH 75/88] Add a bit of documentation and reorder functions --- include/vrv/scoringupfunctor.h | 17 +- src/scoringupfunctor.cpp | 367 +++++++++++++++++---------------- 2 files changed, 202 insertions(+), 182 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index e8be589393..811ecfbd45 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -43,31 +43,32 @@ class ScoringUpFunctor : public Functor { ///@{ std::vector SubdivideIntoBoundedSequences( const ArrayOfElementDurPairs &dursInVoiceSameMensur); + void ProcessBoundedSequences(const std::vector &listOfSequences); + void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); + ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); ///@} /** - * @name: Find @dur.quality of notes (perfecta / imperfecta / altera) + * @name: Apply the principles of imperfection and alteration (find @dur.quality of notes, perfecta / imperfecta / + * altera) for sequences with or without dots of division */ ///@{ - void ProcessBoundedSequences(const std::vector &listOfSequences); - void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); - ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd); void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); ///@} /** - * @name: Find the duration value of the note in minims + * @name: Find the duration value of the note in minims or another given unit */ ///@{ - double GetValueInUnit(double valueInMinims, data_DURATION unit); - double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq); double GetDurNumberValue( const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement); + double GetValueInMinims(const ArrayOfElementDurPairs &middleSeq); + double GetValueInUnit(double valueInMinims, data_DURATION unit); ///@} /** - * @name Apply principles of imperfection and alteration + * @name Apply the modifications of imperfection and alteration or leaves the notes with their default perfect value */ ///@{ Note *ImperfectionAPP(const ArrayOfElementDurPairs &sequence); diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index a86d1a6bbb..ba55a03bcd 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -104,6 +104,9 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) return FUNCTOR_CONTINUE; } +// Functions to find and process the bounded sequences: +// 1. Find the bounded sequences by dividing all the notes in a given mensuration and voice into sequences bounded by +// "supposedly" perfect notes std::vector ScoringUpFunctor::SubdivideIntoBoundedSequences( const ArrayOfElementDurPairs &dursInVoiceSameMensur) { @@ -124,54 +127,7 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen return listOfBoundedSequences; } -ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDurPairs &sequence) -{ - ArrayOfElementDurPairs middleSeq = {}; - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; - if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima - || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa - || firstNoteDur == DURATION_semifusa) { - middleSeq = { sequence.begin(), sequence.end() - 1 }; - } - else { - middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; - } - } - return middleSeq; -} - -bool ScoringUpFunctor::EvalDotOfDiv( - const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd) -{ - // Initial assumption: the sequence doesn't have a dot of division - bool flagDotOfDiv = false; - // Evaluate if the dot passed to the method (by the dotInd) is behaving as a dot of division - ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; - ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; - double sum1 = this->GetValueInUnit(this->GetValueInMinims(middleSeq1), DURATION_semibrevis); - double sum2 = this->GetValueInUnit(this->GetValueInMinims(middleSeq2), DURATION_semibrevis); - // This condition is to discard it being a dot of perfection - if (middleSeq1.size() != 0) { - // This other condition is to evaluate if it is a dot of division - if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { - // This is a "dot of division" - flagDotOfDiv = true; - // Then it divides the sequence into the following two: - ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; - ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; - // Encode the dot of division: - LayerElement *dotElement = sequence.at(dotInd + 1).first; - Dot *dot = vrv_cast(dotElement); - dot->SetForm(dotLog_FORM_div); - // Encode its effect on the notes preceding and following: - this->FindDurQuals(seq1, sum1); - this->FindDurQuals(seq2, sum2); - } - } - return flagDotOfDiv; -} - +// 2. Process the bounded sequences, with the list of all bounded sequences as argument void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) { for (ArrayOfElementDurPairs sequence : listOfSequences) { @@ -179,6 +135,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const std::vector= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima + || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa + || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } + } + return middleSeq; +} + +// Get the value of a note or collection of consecutinve notes in a given unit (minims, semibreves, or breves): +// 1. Get value of the single note in minims +double ScoringUpFunctor::GetDurNumberValue( + const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement) +{ + data_DURQUALITY_mensural durquality; + data_DURATION dur = elementDurPair.second; + LayerElement *element = elementDurPair.first; + Note *note; + if (element->Is(NOTE)) { + note = vrv_cast(element); + assert(note); + durquality = note->GetDurQuality(); + } + // int longaDefaultVal = m_modusMinor * m_tempus * m_prolatio; + int brevisDefaultVal = m_tempus * m_prolatio; + int semibrevisDefaultVal = m_prolatio; + double durnum = 0; + switch (dur) { + case DURATION_longa: + if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + durnum = 3 * brevisDefaultVal; + } + else if (m_modusMinor == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2 * brevisDefaultVal; + } + break; + case DURATION_brevis: + if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + durnum = 3 * semibrevisDefaultVal; + } + else if (m_tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2 * semibrevisDefaultVal; + } + break; + case DURATION_semibrevis: + if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + durnum = 3; + } + else if (m_prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { + durnum = 2; + } + break; + case DURATION_minima: + if (followedByDot) { + durnum = 1.5; + note->SetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); + } + else { + durnum = 1; + } + break; + case DURATION_semiminima: + if (followedByDot) { + durnum = 0.75; + note->SetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); + } + else { + durnum = 0.5; + } + break; + case DURATION_fusa: + if (followedByDot) { + durnum = 0.375; + note->SetDurQuality(DURQUALITY_mensural_perfecta); + Dot *dot = vrv_cast(nextElement); + dot->SetForm(dotLog_FORM_aug); + } + else { + durnum = 0.25; + } + break; + case DURATION_semifusa: durnum = 0.125; break; + default: break; + } + return durnum; +} + +// 2. Get value of a collection of notes in minims +double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSeq) +{ + // Value in minims: + double sum = 0; + bool followedByDot = false; + LayerElement *nextElement = NULL; + for (int i = 0; i < middleSeq.size(); i++) { + std::pair elementDurPair = middleSeq.at(i); + // Check if there is a dot after the element being evaluated + if (i + 1 < middleSeq.size()) { + nextElement = middleSeq.at(i + 1).first; + followedByDot = nextElement->Is(DOT); + } + else { + followedByDot = false; + } + sum += this->GetDurNumberValue(elementDurPair, followedByDot, nextElement); + } + return sum; +} + +// 3. Get value of a collection of notes in a given note unit (e.g., in semibrevis or brevis) +double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit) +{ + double valueInUnit = 0.0; + if (unit == DURATION_semibrevis) { + valueInUnit = valueInMinims / 2; + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_brevis) { + valueInUnit = valueInMinims / 4; + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_longa) { + valueInUnit = valueInMinims / 8; + // imperfect mensur + // MISSING perfect mensur + } + else if (unit == DURATION_maxima) { + valueInUnit = valueInMinims / 16; + // imperfect mensur + // MISSING perfect mensur + } + return valueInUnit; +} + +// Find the quality of notes by applying the "principles of imperfection and alteration" based on the number of notes +// between a bounded sequence void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit) { double sum = valueInSmallerUnit; // JUST IN THIS CASE @@ -352,133 +460,9 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub } } } -double ScoringUpFunctor::GetValueInMinims(const ArrayOfElementDurPairs &middleSeq) -{ - // Value in minims: - double sum = 0; - bool followedByDot = false; - LayerElement *nextElement = NULL; - for (int i = 0; i < middleSeq.size(); i++) { - std::pair elementDurPair = middleSeq.at(i); - // Check if there is a dot after the element being evaluated - if (i + 1 < middleSeq.size()) { - nextElement = middleSeq.at(i + 1).first; - followedByDot = nextElement->Is(DOT); - } - else { - followedByDot = false; - } - sum += this->GetDurNumberValue(elementDurPair, followedByDot, nextElement); - } - return sum; -} - -double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit) -{ - double valueInUnit = 0.0; - if (unit == DURATION_semibrevis) { - valueInUnit = valueInMinims / 2; - // imperfect mensur - // MISSING perfect mensur - } - else if (unit == DURATION_brevis) { - valueInUnit = valueInMinims / 4; - // imperfect mensur - // MISSING perfect mensur - } - else if (unit == DURATION_longa) { - valueInUnit = valueInMinims / 8; - // imperfect mensur - // MISSING perfect mensur - } - else if (unit == DURATION_maxima) { - valueInUnit = valueInMinims / 16; - // imperfect mensur - // MISSING perfect mensur - } - return valueInUnit; -} - -double ScoringUpFunctor::GetDurNumberValue( - const std::pair &elementDurPair, bool followedByDot, LayerElement *nextElement) -{ - data_DURQUALITY_mensural durquality; - data_DURATION dur = elementDurPair.second; - LayerElement *element = elementDurPair.first; - Note *note; - if (element->Is(NOTE)) { - note = vrv_cast(element); - assert(note); - durquality = note->GetDurQuality(); - } - // int longaDefaultVal = m_modusMinor * m_tempus * m_prolatio; - int brevisDefaultVal = m_tempus * m_prolatio; - int semibrevisDefaultVal = m_prolatio; - double durnum = 0; - switch (dur) { - case DURATION_longa: - if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { - durnum = 3 * brevisDefaultVal; - } - else if (m_modusMinor == 2 || durquality == DURQUALITY_mensural_imperfecta) { - durnum = 2 * brevisDefaultVal; - } - break; - case DURATION_brevis: - if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { - durnum = 3 * semibrevisDefaultVal; - } - else if (m_tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { - durnum = 2 * semibrevisDefaultVal; - } - break; - case DURATION_semibrevis: - if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { - durnum = 3; - } - else if (m_prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { - durnum = 2; - } - break; - case DURATION_minima: - if (followedByDot) { - durnum = 1.5; - note->SetDurQuality(DURQUALITY_mensural_perfecta); - Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); - } - else { - durnum = 1; - } - break; - case DURATION_semiminima: - if (followedByDot) { - durnum = 0.75; - note->SetDurQuality(DURQUALITY_mensural_perfecta); - Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); - } - else { - durnum = 0.5; - } - break; - case DURATION_fusa: - if (followedByDot) { - durnum = 0.375; - note->SetDurQuality(DURQUALITY_mensural_perfecta); - Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); - } - else { - durnum = 0.25; - } - break; - case DURATION_semifusa: durnum = 0.125; break; - default: break; - } - return durnum; -} +// Context-dependent modifications: +// 1. Imperfection a parte post (imperfection by the notes that follow) Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) { std::pair firstElementDurPair = sequence.at(0); @@ -520,6 +504,7 @@ Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) } } +// 2. Imperfection a parte ante (imperfection by the notes preceding) Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) { std::pair lastElementDurPair = sequence.at(sequence.size() - 1); @@ -538,6 +523,7 @@ Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) } } +// 3. Alteration (making a note twice as long) Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) { std::pair penultElementDurPair = sequence.at(sequence.size() - 2); @@ -556,9 +542,42 @@ Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) } } +// 4. No modification bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence) { return true; } +// Evaluation of whether a dot in a given position (dotInd) is acting as a dot of division. If it is, apply the +// principles of imperfection and alteration to the sequence of notes preceding and following the dot, and return true. +bool ScoringUpFunctor::EvalDotOfDiv( + const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd) +{ + // Initial assumption: the sequence doesn't have a dot of division + bool flagDotOfDiv = false; + // Evaluate if the dot passed to the method (by the dotInd) is behaving as a dot of division + ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; + ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; + double sum1 = this->GetValueInUnit(this->GetValueInMinims(middleSeq1), DURATION_semibrevis); + double sum2 = this->GetValueInUnit(this->GetValueInMinims(middleSeq2), DURATION_semibrevis); + // This condition is to discard it being a dot of perfection + if (middleSeq1.size() != 0) { + // This other condition is to evaluate if it is a dot of division + if ((sum1 == (int)sum1) and (sum2 == (int)sum2)) { + // This is a "dot of division" + flagDotOfDiv = true; + // Then it divides the sequence into the following two: + ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; + ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; + // Encode the dot of division: + LayerElement *dotElement = sequence.at(dotInd + 1).first; + Dot *dot = vrv_cast(dotElement); + dot->SetForm(dotLog_FORM_div); + // Encode its effect on the notes preceding and following: + this->FindDurQuals(seq1, sum1); + this->FindDurQuals(seq2, sum2); + } + } + return flagDotOfDiv; +} } // namespace vrv From ecdc262d4afc67ef08dd1c9f88b5e495f2f5d4e0 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:07:17 +0200 Subject: [PATCH 76/88] Fix typo --- include/vrv/scoringupfunctor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 811ecfbd45..62efe889c0 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -49,7 +49,7 @@ class ScoringUpFunctor : public Functor { ///@} /** - * @name: Apply the principles of imperfection and alteration (find @dur.quality of notes, perfecta / imperfecta / + * @name: Apply the principles of imperfection and alteration (find @dur.quality of notes: perfecta / imperfecta / * altera) for sequences with or without dots of division */ ///@{ From b8a08bc7f4a87b26a2cc0e2dc4f76b13820865b9 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:20:12 +0200 Subject: [PATCH 77/88] Add support for perfect and imperfect mensur in GetValueInUnit --- src/scoringupfunctor.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index ba55a03bcd..32865dbc9a 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -317,24 +317,16 @@ double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit { double valueInUnit = 0.0; if (unit == DURATION_semibrevis) { - valueInUnit = valueInMinims / 2; - // imperfect mensur - // MISSING perfect mensur + valueInUnit = valueInMinims / m_prolatio; } else if (unit == DURATION_brevis) { - valueInUnit = valueInMinims / 4; - // imperfect mensur - // MISSING perfect mensur + valueInUnit = valueInMinims / (m_prolatio * m_tempus); } else if (unit == DURATION_longa) { - valueInUnit = valueInMinims / 8; - // imperfect mensur - // MISSING perfect mensur + valueInUnit = valueInMinims / (m_prolatio * m_tempus * m_modusMinor); } else if (unit == DURATION_maxima) { - valueInUnit = valueInMinims / 16; - // imperfect mensur - // MISSING perfect mensur + valueInUnit = valueInMinims / (m_prolatio * m_tempus * m_modusMinor * m_modusMaior); } return valueInUnit; } From 380c40501aa0b55870f75965928f286dc1348ef5 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:52:33 +0200 Subject: [PATCH 78/88] Add support to subdivide the sequences by different bounding units (semibreve, breve, longa, and maxima) --- include/vrv/scoringupfunctor.h | 2 +- src/scoringupfunctor.cpp | 68 ++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 62efe889c0..83e214cd4f 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -42,7 +42,7 @@ class ScoringUpFunctor : public Functor { */ ///@{ std::vector SubdivideIntoBoundedSequences( - const ArrayOfElementDurPairs &dursInVoiceSameMensur); + const ArrayOfElementDurPairs &dursInVoiceSameMensur, data_DURATION boundUnit); void ProcessBoundedSequences(const std::vector &listOfSequences); void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 32865dbc9a..6f0fe6e0da 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -47,7 +47,7 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur); + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_brevis); this->ProcessBoundedSequences(m_listOfSequences); m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } @@ -108,21 +108,67 @@ FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) // 1. Find the bounded sequences by dividing all the notes in a given mensuration and voice into sequences bounded by // "supposedly" perfect notes std::vector ScoringUpFunctor::SubdivideIntoBoundedSequences( - const ArrayOfElementDurPairs &dursInVoiceSameMensur) + const ArrayOfElementDurPairs &dursInVoiceSameMensur, data_DURATION boundUnit) { std::vector listOfBoundedSequences = {}; ArrayOfElementDurPairs boundedSequence = {}; - for (std::pair elementDurPair : dursInVoiceSameMensur) { - data_DURATION dur = elementDurPair.second; - if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { - boundedSequence.insert(boundedSequence.end(), elementDurPair); - listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); - boundedSequence = { elementDurPair }; + + // Depending on the boundUnit which could be a semibrevis (when in major prolation), a breve (when in perfect tempus), a longa (when in perfect modus minor), or a maxima (when in perfect modus major). The boundaries become the boundUnit note and any note of a higher value: + if (boundUnit == DURATION_semibrevis) { + for (std::pair elementDurPair : dursInVoiceSameMensur) { + data_DURATION dur = elementDurPair.second; + if (dur == DURATION_semibrevis || dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); + boundedSequence = { elementDurPair }; + } + else { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + } + LogDebug("dur is:", dur); } - else { - boundedSequence.insert(boundedSequence.end(), elementDurPair); + } + else if (boundUnit == DURATION_brevis) { + for (std::pair elementDurPair : dursInVoiceSameMensur) { + data_DURATION dur = elementDurPair.second; + if (dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); + boundedSequence = { elementDurPair }; + } + else { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + } + LogDebug("dur is:", dur); + } + } + else if (boundUnit == DURATION_longa) { + for (std::pair elementDurPair : dursInVoiceSameMensur) { + data_DURATION dur = elementDurPair.second; + if (dur == DURATION_longa || dur == DURATION_maxima) { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); + boundedSequence = { elementDurPair }; + } + else { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + } + LogDebug("dur is:", dur); + } + } + else if (boundUnit == DURATION_maxima) { + for (std::pair elementDurPair : dursInVoiceSameMensur) { + data_DURATION dur = elementDurPair.second; + if (dur == DURATION_maxima) { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); + boundedSequence = { elementDurPair }; + } + else { + boundedSequence.insert(boundedSequence.end(), elementDurPair); + } + LogDebug("dur is:", dur); } - LogDebug("dur is:", dur); } return listOfBoundedSequences; } From afac0a8303d050282a9aa39d86369369a516fd48 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:53:17 +0200 Subject: [PATCH 79/88] Reformat --- src/scoringupfunctor.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 6f0fe6e0da..9a60b10305 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -113,11 +113,14 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen std::vector listOfBoundedSequences = {}; ArrayOfElementDurPairs boundedSequence = {}; - // Depending on the boundUnit which could be a semibrevis (when in major prolation), a breve (when in perfect tempus), a longa (when in perfect modus minor), or a maxima (when in perfect modus major). The boundaries become the boundUnit note and any note of a higher value: + // Depending on the boundUnit which could be a semibrevis (when in major prolation), a breve (when in perfect + // tempus), a longa (when in perfect modus minor), or a maxima (when in perfect modus major). The boundaries become + // the boundUnit note and any note of a higher value: if (boundUnit == DURATION_semibrevis) { for (std::pair elementDurPair : dursInVoiceSameMensur) { data_DURATION dur = elementDurPair.second; - if (dur == DURATION_semibrevis || dur == DURATION_brevis || dur == DURATION_longa || dur == DURATION_maxima) { + if (dur == DURATION_semibrevis || dur == DURATION_brevis || dur == DURATION_longa + || dur == DURATION_maxima) { boundedSequence.insert(boundedSequence.end(), elementDurPair); listOfBoundedSequences.insert(listOfBoundedSequences.end(), boundedSequence); boundedSequence = { elementDurPair }; From 803c9fb080bf81e172007bda0fbcc710fd6cfbdd Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 22:57:57 +0200 Subject: [PATCH 80/88] Call SubdivideIntoBoundedSequences for all four note levels depending on where the 'perfect' mensuration is --- src/scoringupfunctor.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 9a60b10305..a48595aced 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -47,8 +47,22 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) data_PROLATIO prolatio = m_currentMensur->GetProlatio();*/ // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_brevis); - this->ProcessBoundedSequences(m_listOfSequences); + if (m_prolatio == 3) { + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_semibrevis); + this->ProcessBoundedSequences(m_listOfSequences); + } + if (m_tempus == 3) { + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_brevis); + this->ProcessBoundedSequences(m_listOfSequences); + } + if (m_modusMinor == 3) { + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_longa); + this->ProcessBoundedSequences(m_listOfSequences); + } + if (m_modusMaior == 3) { + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_maxima); + this->ProcessBoundedSequences(m_listOfSequences); + } m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; From 4f91a6a4ede1ed8f3bbcef31b9a9b564dc9cf804 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 23:09:27 +0200 Subject: [PATCH 81/88] Add support for getting the BoundedNotes for different perfect mensurations --- include/vrv/scoringupfunctor.h | 6 +-- src/scoringupfunctor.cpp | 77 ++++++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 83e214cd4f..59d25886de 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -43,9 +43,9 @@ class ScoringUpFunctor : public Functor { ///@{ std::vector SubdivideIntoBoundedSequences( const ArrayOfElementDurPairs &dursInVoiceSameMensur, data_DURATION boundUnit); - void ProcessBoundedSequences(const std::vector &listOfSequences); - void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence); - ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence); + void ProcessBoundedSequences(const std::vector &listOfSequences, data_DURATION boundUnit); + void ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit); + ArrayOfElementDurPairs GetBoundedNotes(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit); ///@} /** diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index a48595aced..8c3ffcf909 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -49,19 +49,19 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) if (!m_dursInVoiceSameMensur.empty()) { if (m_prolatio == 3) { m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_semibrevis); - this->ProcessBoundedSequences(m_listOfSequences); + this->ProcessBoundedSequences(m_listOfSequences, DURATION_semibrevis); } if (m_tempus == 3) { m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_brevis); - this->ProcessBoundedSequences(m_listOfSequences); + this->ProcessBoundedSequences(m_listOfSequences, DURATION_brevis); } if (m_modusMinor == 3) { m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_longa); - this->ProcessBoundedSequences(m_listOfSequences); + this->ProcessBoundedSequences(m_listOfSequences, DURATION_longa); } if (m_modusMaior == 3) { m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_maxima); - this->ProcessBoundedSequences(m_listOfSequences); + this->ProcessBoundedSequences(m_listOfSequences, DURATION_maxima); } m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } @@ -191,18 +191,19 @@ std::vector ScoringUpFunctor::SubdivideIntoBoundedSequen } // 2. Process the bounded sequences, with the list of all bounded sequences as argument -void ScoringUpFunctor::ProcessBoundedSequences(const std::vector &listOfSequences) +void ScoringUpFunctor::ProcessBoundedSequences( + const std::vector &listOfSequences, data_DURATION boundUnit) { for (ArrayOfElementDurPairs sequence : listOfSequences) { - this->ProcessBoundedSequences(sequence); + this->ProcessBoundedSequences(sequence, boundUnit); } } // 3. Process the bounded sequences, with the individual bounded sequences as argument -void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence) +void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { // Get the notes in the middle of the boundaries of the sequence - ArrayOfElementDurPairs middleSeq = this->GetBoundedNotes(sequence); + ArrayOfElementDurPairs middleSeq = this->GetBoundedNotes(sequence, boundUnit); // Check if there are dots in the middleSeq and how many. The dots in the middleSeq are the only ones that have the // possibility of being a dot of imperfection (or alteration) or a dot of augmentation---the dots of perfection are @@ -254,18 +255,60 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq } // 4. Get the notes bounded by the "supposedly" perfect notes (the 'middle note of the bounded sequence') -ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes(const ArrayOfElementDurPairs &sequence) +ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes( + const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { ArrayOfElementDurPairs middleSeq = {}; - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; - if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima - || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa - || firstNoteDur == DURATION_semifusa) { - middleSeq = { sequence.begin(), sequence.end() - 1 }; + + if (boundUnit == DURATION_semibrevis) { + if (sequence.size() >= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa + || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } } - else { - middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } + else if (boundUnit == DURATION_brevis) { + if (sequence.size() >= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima + || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa + || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } + } + } + else if (boundUnit == DURATION_longa) { + if (sequence.size() >= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_brevis || firstNoteDur == DURATION_semibrevis + || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima + || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } + } + } + else if (boundUnit == DURATION_maxima) { + if (sequence.size() >= 2) { + data_DURATION firstNoteDur = sequence.at(0).second; + if (firstNoteDur == DURATION_longa || firstNoteDur == DURATION_brevis || firstNoteDur == DURATION_semibrevis + || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima + || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { + middleSeq = { sequence.begin(), sequence.end() - 1 }; + } + else { + middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; + } } } return middleSeq; From 3837c00b7522b007fc8baab36a4f69ff3bc0281e Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 23:15:35 +0200 Subject: [PATCH 82/88] Add new method to avoid repetition --- include/vrv/scoringupfunctor.h | 1 + src/scoringupfunctor.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 59d25886de..b06dbf45b0 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -41,6 +41,7 @@ class ScoringUpFunctor : public Functor { * @name: Divide the notes of a voice into sequences to be processed individualy */ ///@{ + void workInMensur(const ArrayOfElementDurPairs &m_dursInVoiceSameMensur, data_DURATION noteLevel); std::vector SubdivideIntoBoundedSequences( const ArrayOfElementDurPairs &dursInVoiceSameMensur, data_DURATION boundUnit); void ProcessBoundedSequences(const std::vector &listOfSequences, data_DURATION boundUnit); diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 8c3ffcf909..6e8ff5dfef 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -48,26 +48,28 @@ FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer) // Doesn't get it from the staffDef, right?// if (!m_dursInVoiceSameMensur.empty()) { if (m_prolatio == 3) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_semibrevis); - this->ProcessBoundedSequences(m_listOfSequences, DURATION_semibrevis); + workInMensur(m_dursInVoiceSameMensur, DURATION_semibrevis); } if (m_tempus == 3) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_brevis); - this->ProcessBoundedSequences(m_listOfSequences, DURATION_brevis); + workInMensur(m_dursInVoiceSameMensur, DURATION_brevis); } if (m_modusMinor == 3) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_longa); - this->ProcessBoundedSequences(m_listOfSequences, DURATION_longa); + workInMensur(m_dursInVoiceSameMensur, DURATION_longa); } if (m_modusMaior == 3) { - m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, DURATION_maxima); - this->ProcessBoundedSequences(m_listOfSequences, DURATION_maxima); + workInMensur(m_dursInVoiceSameMensur, DURATION_maxima); } m_dursInVoiceSameMensur = {}; // restart for next voice (layer) } return FUNCTOR_CONTINUE; } +void ScoringUpFunctor::workInMensur(const ArrayOfElementDurPairs &m_dursInVoiceSameMensur, data_DURATION noteLevel) +{ + m_listOfSequences = this->SubdivideIntoBoundedSequences(m_dursInVoiceSameMensur, noteLevel); + this->ProcessBoundedSequences(m_listOfSequences, noteLevel); +} + FunctorCode ScoringUpFunctor::VisitLayerElement(LayerElement *layerElement) { if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; From ebbdcf965f01a0db5cb517ff4db252c4c33977a7 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sat, 19 Oct 2024 23:25:29 +0200 Subject: [PATCH 83/88] Clean the method and avoid repetition --- src/scoringupfunctor.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 6e8ff5dfef..2a79239c11 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -260,11 +260,11 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes( const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { + data_DURATION firstNoteDur; ArrayOfElementDurPairs middleSeq = {}; - - if (boundUnit == DURATION_semibrevis) { - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; + if (sequence.size() >= 2) { + if (boundUnit == DURATION_semibrevis) { + firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { middleSeq = { sequence.begin(), sequence.end() - 1 }; @@ -273,10 +273,8 @@ ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes( middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; } } - } - else if (boundUnit == DURATION_brevis) { - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; + else if (boundUnit == DURATION_brevis) { + firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { @@ -286,10 +284,8 @@ ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes( middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; } } - } - else if (boundUnit == DURATION_longa) { - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; + else if (boundUnit == DURATION_longa) { + firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_brevis || firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { @@ -299,10 +295,8 @@ ArrayOfElementDurPairs ScoringUpFunctor::GetBoundedNotes( middleSeq = { sequence.begin() + 1, sequence.end() - 1 }; } } - } - else if (boundUnit == DURATION_maxima) { - if (sequence.size() >= 2) { - data_DURATION firstNoteDur = sequence.at(0).second; + else if (boundUnit == DURATION_maxima) { + firstNoteDur = sequence.at(0).second; if (firstNoteDur == DURATION_longa || firstNoteDur == DURATION_brevis || firstNoteDur == DURATION_semibrevis || firstNoteDur == DURATION_minima || firstNoteDur == DURATION_semiminima || firstNoteDur == DURATION_fusa || firstNoteDur == DURATION_semifusa) { From ce06d28738c8cc4f06b8467ac4b51f2f0b322794 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sun, 20 Oct 2024 01:43:34 +0200 Subject: [PATCH 84/88] Add boundUnit to modification-related functions and fix GetValueInUnit function Regarding the first point, the modification-related functions are the four mperfectionAPP, ImperfectionAPA, Alteration, and LeavePerfect, plus the functions that call them (FindDurQuals and EvalDotOfDiv). Regarding the second point, the GetValueUnit was dividing by one more level thant it should (as it was supposed to divide the middleSeq total by the smallerNoteLevel -not the boundUnit level) --- include/vrv/scoringupfunctor.h | 12 ++--- src/scoringupfunctor.cpp | 80 +++++++++++++++++----------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index b06dbf45b0..d53bb0625f 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -54,8 +54,8 @@ class ScoringUpFunctor : public Functor { * altera) for sequences with or without dots of division */ ///@{ - bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd); - void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit); + bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd, data_DURATION unit); + void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit, data_DURATION boundUnit); ///@} /** @@ -72,10 +72,10 @@ class ScoringUpFunctor : public Functor { * @name Apply the modifications of imperfection and alteration or leaves the notes with their default perfect value */ ///@{ - Note *ImperfectionAPP(const ArrayOfElementDurPairs &sequence); - Note *ImperfectionAPA(const ArrayOfElementDurPairs &sequence); - Note *Alteration(const ArrayOfElementDurPairs &sequence); - bool LeavePerfect(const ArrayOfElementDurPairs &sequence); + 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); ///@} /* diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 2a79239c11..1b7dfefbda 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -221,18 +221,18 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // 0. No dots double sum; if (numberOfDots == 0) { - sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); - this->FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); + this->FindDurQuals(sequence, sum, boundUnit); } // 1. Single dot in middle sequence sequence else if (numberOfDots == 1) { // If there is one dot, int dotInd = indecesOfDots.at(0); - bool isDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, dotInd); + bool isDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, dotInd, boundUnit); if (not isDotOfDiv) { // This is a dot of augmentation - sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); - this->FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); + this->FindDurQuals(sequence, sum, boundUnit); } } // 3. More than one dot in middle sequence @@ -240,18 +240,18 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // Take first dot and evaluate if it is a dot of imperfection (check if it is "integer number of semibreves" // away from the beginning of the sequence, and if the rest of the sequence still sums an integer number) int startDotInd = indecesOfDots.at(0); - bool isStartDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, startDotInd); + bool isStartDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, startDotInd, boundUnit); // Take last dot and evaluate if it is a dot of division (check if it is "integer number of semibreves" away // from the end of the sequence, and if the rest of the sequence still sums an integer number) int endDotInd = indecesOfDots.at(indecesOfDots.size() - 1); - bool isEndDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, endDotInd); + bool isEndDotOfDiv = this->EvalDotOfDiv(middleSeq, sequence, endDotInd, boundUnit); // If neither, all dots are dots of augmentation if (not isStartDotOfDiv and not isEndDotOfDiv) { // This is a dot of augmentation - sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), DURATION_semibrevis); - this->FindDurQuals(sequence, sum); + sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); + this->FindDurQuals(sequence, sum, boundUnit); } } } @@ -419,23 +419,23 @@ double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit { double valueInUnit = 0.0; if (unit == DURATION_semibrevis) { - valueInUnit = valueInMinims / m_prolatio; + valueInUnit = valueInMinims; } else if (unit == DURATION_brevis) { - valueInUnit = valueInMinims / (m_prolatio * m_tempus); + valueInUnit = valueInMinims / (m_prolatio); } else if (unit == DURATION_longa) { - valueInUnit = valueInMinims / (m_prolatio * m_tempus * m_modusMinor); + valueInUnit = valueInMinims / (m_prolatio * m_tempus); } else if (unit == DURATION_maxima) { - valueInUnit = valueInMinims / (m_prolatio * m_tempus * m_modusMinor * m_modusMaior); + valueInUnit = valueInMinims / (m_prolatio * m_tempus * m_modusMinor); } return valueInUnit; } // Find the quality of notes by applying the "principles of imperfection and alteration" based on the number of notes // between a bounded sequence -void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit) +void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit, data_DURATION boundUnit) { double sum = valueInSmallerUnit; // JUST IN THIS CASE int remainder = (int)sum % 3; @@ -466,13 +466,13 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub case 0: break; // No modifications case 1: // Evaluate 'default' case: Imperfection APP - impappCandidate = this->ImperfectionAPP(sequence); + impappCandidate = this->ImperfectionAPP(sequence, boundUnit); if (impappCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Imperfection APA - impapaCandidate = this->ImperfectionAPA(sequence); + impapaCandidate = this->ImperfectionAPA(sequence, boundUnit); if (impapaCandidate) { impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; @@ -482,14 +482,14 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 2: // Evaluate 'default' case: Alteration - alterationCandidate = this->Alteration(sequence); + alterationCandidate = this->Alteration(sequence, boundUnit); if (alterationCandidate && !dotOfImperf) { alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); break; } // Evaluate 'alternative' case: Imperfection APP and Imperfection APA - impappCandidate = this->ImperfectionAPP(sequence); - impapaCandidate = this->ImperfectionAPA(sequence); + impappCandidate = this->ImperfectionAPP(sequence, boundUnit); + impapaCandidate = this->ImperfectionAPA(sequence, boundUnit); if (impappCandidate && impapaCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); @@ -501,7 +501,7 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub } } else if (sum == 3) { - bool leavePerfectFlag = this->LeavePerfect(sequence); + bool leavePerfectFlag = this->LeavePerfect(sequence, boundUnit); if (!leavePerfectFlag || dotOfImperf) { } } @@ -509,8 +509,8 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub switch (remainder) { case 0: // Evaluate 'default' case: Imperfection APP and Alteration - impappCandidate = this->ImperfectionAPP(sequence); - alterationCandidate = this->Alteration(sequence); + impappCandidate = this->ImperfectionAPP(sequence, boundUnit); + alterationCandidate = this->Alteration(sequence, boundUnit); if (impappCandidate && alterationCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); @@ -520,13 +520,13 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 1: // Evaluate 'default' case: Imperfection APP - impappCandidate = this->ImperfectionAPP(sequence); + impappCandidate = this->ImperfectionAPP(sequence, boundUnit); if (impappCandidate) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Imperfection APA - impapaCandidate = this->ImperfectionAPA(sequence); + impapaCandidate = this->ImperfectionAPA(sequence, boundUnit); if (impapaCandidate) { impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; @@ -535,15 +535,15 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub break; case 2: // Evaluate 'default' case: Imperfection APP and Imperfection APA - impappCandidate = this->ImperfectionAPP(sequence); - impapaCandidate = this->ImperfectionAPA(sequence); + impappCandidate = this->ImperfectionAPP(sequence, boundUnit); + impapaCandidate = this->ImperfectionAPA(sequence, boundUnit); if (impappCandidate && impapaCandidate && !simileAnteSimile) { impappCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); impapaCandidate->SetDurQuality(DURQUALITY_mensural_imperfecta); break; } // Evaluate 'alternative' case: Alteration - alterationCandidate = this->Alteration(sequence); + alterationCandidate = this->Alteration(sequence, boundUnit); if (alterationCandidate) { alterationCandidate->SetDurQuality(DURQUALITY_mensural_altera); break; @@ -557,7 +557,7 @@ void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, doub // Context-dependent modifications: // 1. Imperfection a parte post (imperfection by the notes that follow) -Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { std::pair firstElementDurPair = sequence.at(0); LayerElement *firstElement = firstElementDurPair.first; @@ -565,7 +565,7 @@ Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) LayerElement *nextElement; /// Evaluates if the first note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If /// it is a rest or a larger note, then it forbids imperfection (and returns false). - if (firstElement->Is(NOTE) && firstDur == DURATION_brevis) { + if (firstElement->Is(NOTE) && firstDur == boundUnit) { /// Before imperfecting the starting brevis, check if it is followed by a dot. If it is, this would be a dot of /// perfectio, i.e., a dot that forces perfection (forbidding the imperfection and returning false). Otherwise, /// if there is no dot following the starting brevis, proceed to perform the imperfection a.p.p. and return @@ -599,14 +599,14 @@ Note *ScoringUpFunctor::ImperfectionAPP(const ArrayOfElementDurPairs &sequence) } // 2. Imperfection a parte ante (imperfection by the notes preceding) -Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { std::pair lastElementDurPair = sequence.at(sequence.size() - 1); LayerElement *lastElement = lastElementDurPair.first; data_DURATION lastDur = lastElementDurPair.second; /// Evaluates if the last note in the sequence is a brevis. If it is, then it imperfects it (and returns true). If /// it is a rest or a larger note, then it forbids imperfection (and returns false). - if (lastElement->Is(NOTE) && lastDur == DURATION_brevis) { + if (lastElement->Is(NOTE) && lastDur == boundUnit) { Note *lastNote = vrv_cast(lastElement); assert(lastNote); // lastNote->SetDurQuality(DURQUALITY_mensural_imperfecta); @@ -618,14 +618,16 @@ Note *ScoringUpFunctor::ImperfectionAPA(const ArrayOfElementDurPairs &sequence) } // 3. Alteration (making a note twice as long) -Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) +Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { std::pair penultElementDurPair = sequence.at(sequence.size() - 2); LayerElement *penultElement = penultElementDurPair.first; data_DURATION penultDur = penultElementDurPair.second; /// Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids Alteration /// (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). - if (penultElement->Is(NOTE) && penultDur == DURATION_semibrevis) { + std::map nextSmallLevel = {{DURATION_maxima, DURATION_longa}, {DURATION_longa, DURATION_brevis}, {DURATION_brevis, DURATION_semibrevis}, {DURATION_semibrevis, DURATION_minima}}; + data_DURATION smallerValue = nextSmallLevel[boundUnit]; + if (penultElement->Is(NOTE) && penultDur == smallerValue) { Note *penultNote = vrv_cast(penultElement); assert(penultNote); // penultNote->SetDurQuality(DURQUALITY_mensural_altera); @@ -637,7 +639,7 @@ Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence) } // 4. No modification -bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence) +bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence, data_DURATION boundUnit) { return true; } @@ -645,15 +647,15 @@ bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence) // Evaluation of whether a dot in a given position (dotInd) is acting as a dot of division. If it is, apply the // principles of imperfection and alteration to the sequence of notes preceding and following the dot, and return true. bool ScoringUpFunctor::EvalDotOfDiv( - const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd) + const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd, data_DURATION unit) { // Initial assumption: the sequence doesn't have a dot of division bool flagDotOfDiv = false; // Evaluate if the dot passed to the method (by the dotInd) is behaving as a dot of division ArrayOfElementDurPairs middleSeq1 = { middleSeq.begin(), middleSeq.begin() + dotInd }; ArrayOfElementDurPairs middleSeq2 = { middleSeq.begin() + dotInd + 1, middleSeq.end() }; - double sum1 = this->GetValueInUnit(this->GetValueInMinims(middleSeq1), DURATION_semibrevis); - double sum2 = this->GetValueInUnit(this->GetValueInMinims(middleSeq2), DURATION_semibrevis); + double sum1 = this->GetValueInUnit(this->GetValueInMinims(middleSeq1), unit); + double sum2 = this->GetValueInUnit(this->GetValueInMinims(middleSeq2), unit); // This condition is to discard it being a dot of perfection if (middleSeq1.size() != 0) { // This other condition is to evaluate if it is a dot of division @@ -668,8 +670,8 @@ bool ScoringUpFunctor::EvalDotOfDiv( Dot *dot = vrv_cast(dotElement); dot->SetForm(dotLog_FORM_div); // Encode its effect on the notes preceding and following: - this->FindDurQuals(seq1, sum1); - this->FindDurQuals(seq2, sum2); + this->FindDurQuals(seq1, sum1, unit); + this->FindDurQuals(seq2, sum2, unit); } } return flagDotOfDiv; From 506f9496355034b0cace38ccd3c3bebaff2bd164 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sun, 20 Oct 2024 02:50:02 +0200 Subject: [PATCH 85/88] Separate calculating the value of perfect notes from encoding their quality and effect of the dot --- include/vrv/scoringupfunctor.h | 3 ++ src/scoringupfunctor.cpp | 59 ++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index d53bb0625f..441d87108d 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -76,6 +76,7 @@ class ScoringUpFunctor : public Functor { 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(); ///@} /* @@ -96,6 +97,8 @@ class ScoringUpFunctor : public Functor { int m_prolatio; ArrayOfElementDurPairs m_dursInVoiceSameMensur; std::vector m_listOfSequences; + std::list> m_listOfAugNotesDotsPairs; + std::list> m_listOfPerfNotesDotsPairs; public: // diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 1b7dfefbda..2810003b53 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -223,6 +223,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq if (numberOfDots == 0) { sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); this->FindDurQuals(sequence, sum, boundUnit); + ApplyAugmentationsAndPerfections(); } // 1. Single dot in middle sequence sequence else if (numberOfDots == 1) { @@ -233,6 +234,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // This is a dot of augmentation sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); this->FindDurQuals(sequence, sum, boundUnit); + ApplyAugmentationsAndPerfections(); } } // 3. More than one dot in middle sequence @@ -252,6 +254,7 @@ void ScoringUpFunctor::ProcessBoundedSequences(const ArrayOfElementDurPairs &seq // This is a dot of augmentation sum = this->GetValueInUnit(this->GetValueInMinims(middleSeq), boundUnit); this->FindDurQuals(sequence, sum, boundUnit); + ApplyAugmentationsAndPerfections(); } } } @@ -332,6 +335,15 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_longa: if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * brevisDefaultVal; + if (m_modusMinor == 2 && followedByDot) { + // Candidate for augmentation ( and @num="2", @numbase="3") + Dot *dot = vrv_cast(nextElement); + m_listOfAugNotesDotsPairs.push_back({note, dot}); + } else if (m_modusMinor == 3 && followedByDot) { + // Candidate for dot of perfection ( and @dur.quality="perfecta") + Dot *dot = vrv_cast(nextElement); + m_listOfPerfNotesDotsPairs.push_back({note, dot}); + } } else if (m_modusMinor == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2 * brevisDefaultVal; @@ -340,6 +352,15 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_brevis: if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * semibrevisDefaultVal; + if (m_tempus == 2 && followedByDot) { + // Candidate for augmentation ( and @num="2", @numbase="3") + Dot *dot = vrv_cast(nextElement); + m_listOfAugNotesDotsPairs.push_back({note, dot}); + } else if (m_tempus == 3 && followedByDot) { + // Candidate for dot of perfection ( and @dur.quality="perfecta") + Dot *dot = vrv_cast(nextElement); + m_listOfPerfNotesDotsPairs.push_back({note, dot}); + } } else if (m_tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2 * semibrevisDefaultVal; @@ -348,6 +369,15 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_semibrevis: if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3; + if (m_prolatio == 2 && followedByDot) { + // Candidate for augmentation ( and @num="2", @numbase="3") + Dot *dot = vrv_cast(nextElement); + m_listOfAugNotesDotsPairs.push_back({note, dot}); + } else if (m_prolatio == 3 && followedByDot) { + // Candidate for dot of perfection ( and @dur.quality="perfecta") + Dot *dot = vrv_cast(nextElement); + m_listOfPerfNotesDotsPairs.push_back({note, dot}); + } } else if (m_prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { durnum = 2; @@ -356,9 +386,9 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_minima: if (followedByDot) { durnum = 1.5; - note->SetDurQuality(DURQUALITY_mensural_perfecta); + // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); + m_listOfAugNotesDotsPairs.push_back({note, dot}); } else { durnum = 1; @@ -367,9 +397,9 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_semiminima: if (followedByDot) { durnum = 0.75; - note->SetDurQuality(DURQUALITY_mensural_perfecta); + // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); + m_listOfAugNotesDotsPairs.push_back({note, dot}); } else { durnum = 0.5; @@ -378,9 +408,9 @@ double ScoringUpFunctor::GetDurNumberValue( case DURATION_fusa: if (followedByDot) { durnum = 0.375; - note->SetDurQuality(DURQUALITY_mensural_perfecta); + // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - dot->SetForm(dotLog_FORM_aug); + m_listOfAugNotesDotsPairs.push_back({note, dot}); } else { durnum = 0.25; @@ -644,6 +674,19 @@ bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence, data return true; } +// 5. Apply augmentations (due to a dot of augmentation) and perfections (due to a dot of perfection) +void ScoringUpFunctor::ApplyAugmentationsAndPerfections(){ + for (std::pair pairNoteAndDot : m_listOfAugNotesDotsPairs) { + pairNoteAndDot.first->SetDurQuality(DURQUALITY_mensural_perfecta); + pairNoteAndDot.second->SetForm(dotLog_FORM_aug); + }for (std::pair pairNoteAndDot : m_listOfPerfNotesDotsPairs) { + pairNoteAndDot.first->SetDurQuality(DURQUALITY_mensural_perfecta); + pairNoteAndDot.second->SetForm(dotLog_FORM_div); + } + m_listOfAugNotesDotsPairs.clear(); + m_listOfPerfNotesDotsPairs.clear(); +} + // Evaluation of whether a dot in a given position (dotInd) is acting as a dot of division. If it is, apply the // principles of imperfection and alteration to the sequence of notes preceding and following the dot, and return true. bool ScoringUpFunctor::EvalDotOfDiv( @@ -672,6 +715,10 @@ bool ScoringUpFunctor::EvalDotOfDiv( // Encode its effect on the notes preceding and following: this->FindDurQuals(seq1, sum1, unit); this->FindDurQuals(seq2, sum2, unit); + ApplyAugmentationsAndPerfections(); + } else { + m_listOfAugNotesDotsPairs.clear(); + m_listOfPerfNotesDotsPairs.clear(); } } return flagDotOfDiv; From 7cf2803ab53b68f637eaea18daf2738d1386c092 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sun, 20 Oct 2024 02:56:04 +0200 Subject: [PATCH 86/88] Reformatting --- include/vrv/scoringupfunctor.h | 7 +++--- src/scoringupfunctor.cpp | 45 ++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 441d87108d..8f1cc944d9 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -54,7 +54,8 @@ class ScoringUpFunctor : public Functor { * altera) for sequences with or without dots of division */ ///@{ - bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd, data_DURATION unit); + bool EvalDotOfDiv(const ArrayOfElementDurPairs &middleSeq, const ArrayOfElementDurPairs &sequence, int dotInd, + data_DURATION unit); void FindDurQuals(const ArrayOfElementDurPairs &middleSeq, double valueInUnit, data_DURATION boundUnit); ///@} @@ -97,8 +98,8 @@ class ScoringUpFunctor : public Functor { int m_prolatio; ArrayOfElementDurPairs m_dursInVoiceSameMensur; std::vector m_listOfSequences; - std::list> m_listOfAugNotesDotsPairs; - std::list> m_listOfPerfNotesDotsPairs; + std::list> m_listOfAugNotesDotsPairs; + std::list> m_listOfPerfNotesDotsPairs; public: // diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 2810003b53..2f67010110 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -338,11 +338,12 @@ double ScoringUpFunctor::GetDurNumberValue( if (m_modusMinor == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); - } else if (m_modusMinor == 3 && followedByDot) { + m_listOfAugNotesDotsPairs.push_back({ note, dot }); + } + else if (m_modusMinor == 3 && followedByDot) { // Candidate for dot of perfection ( and @dur.quality="perfecta") Dot *dot = vrv_cast(nextElement); - m_listOfPerfNotesDotsPairs.push_back({note, dot}); + m_listOfPerfNotesDotsPairs.push_back({ note, dot }); } } else if (m_modusMinor == 2 || durquality == DURQUALITY_mensural_imperfecta) { @@ -355,11 +356,12 @@ double ScoringUpFunctor::GetDurNumberValue( if (m_tempus == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); - } else if (m_tempus == 3 && followedByDot) { + m_listOfAugNotesDotsPairs.push_back({ note, dot }); + } + else if (m_tempus == 3 && followedByDot) { // Candidate for dot of perfection ( and @dur.quality="perfecta") Dot *dot = vrv_cast(nextElement); - m_listOfPerfNotesDotsPairs.push_back({note, dot}); + m_listOfPerfNotesDotsPairs.push_back({ note, dot }); } } else if (m_tempus == 2 || durquality == DURQUALITY_mensural_imperfecta) { @@ -372,11 +374,12 @@ double ScoringUpFunctor::GetDurNumberValue( if (m_prolatio == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); - } else if (m_prolatio == 3 && followedByDot) { + m_listOfAugNotesDotsPairs.push_back({ note, dot }); + } + else if (m_prolatio == 3 && followedByDot) { // Candidate for dot of perfection ( and @dur.quality="perfecta") Dot *dot = vrv_cast(nextElement); - m_listOfPerfNotesDotsPairs.push_back({note, dot}); + m_listOfPerfNotesDotsPairs.push_back({ note, dot }); } } else if (m_prolatio == 2 || durquality == DURQUALITY_mensural_imperfecta) { @@ -388,7 +391,7 @@ double ScoringUpFunctor::GetDurNumberValue( durnum = 1.5; // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); + m_listOfAugNotesDotsPairs.push_back({ note, dot }); } else { durnum = 1; @@ -399,7 +402,7 @@ double ScoringUpFunctor::GetDurNumberValue( durnum = 0.75; // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); + m_listOfAugNotesDotsPairs.push_back({ note, dot }); } else { durnum = 0.5; @@ -410,7 +413,7 @@ double ScoringUpFunctor::GetDurNumberValue( durnum = 0.375; // Candidate for augmentation ( and @num="2", @numbase="3") Dot *dot = vrv_cast(nextElement); - m_listOfAugNotesDotsPairs.push_back({note, dot}); + m_listOfAugNotesDotsPairs.push_back({ note, dot }); } else { durnum = 0.25; @@ -465,7 +468,8 @@ double ScoringUpFunctor::GetValueInUnit(double valueInMinims, data_DURATION unit // Find the quality of notes by applying the "principles of imperfection and alteration" based on the number of notes // between a bounded sequence -void ScoringUpFunctor::FindDurQuals(const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit, data_DURATION boundUnit) +void ScoringUpFunctor::FindDurQuals( + const ArrayOfElementDurPairs &sequence, double valueInSmallerUnit, data_DURATION boundUnit) { double sum = valueInSmallerUnit; // JUST IN THIS CASE int remainder = (int)sum % 3; @@ -655,7 +659,9 @@ Note *ScoringUpFunctor::Alteration(const ArrayOfElementDurPairs &sequence, data_ data_DURATION penultDur = penultElementDurPair.second; /// Evaluates what is the type of the penultimate element in the sequence. If it is a rest, it forbids Alteration /// (returns false). If it is a note, and the note is a 'semibrevis', it alters the note (and returns true). - std::map nextSmallLevel = {{DURATION_maxima, DURATION_longa}, {DURATION_longa, DURATION_brevis}, {DURATION_brevis, DURATION_semibrevis}, {DURATION_semibrevis, DURATION_minima}}; + std::map nextSmallLevel + = { { DURATION_maxima, DURATION_longa }, { DURATION_longa, DURATION_brevis }, + { DURATION_brevis, DURATION_semibrevis }, { DURATION_semibrevis, DURATION_minima } }; data_DURATION smallerValue = nextSmallLevel[boundUnit]; if (penultElement->Is(NOTE) && penultDur == smallerValue) { Note *penultNote = vrv_cast(penultElement); @@ -675,11 +681,13 @@ bool ScoringUpFunctor::LeavePerfect(const ArrayOfElementDurPairs &sequence, data } // 5. Apply augmentations (due to a dot of augmentation) and perfections (due to a dot of perfection) -void ScoringUpFunctor::ApplyAugmentationsAndPerfections(){ - for (std::pair pairNoteAndDot : m_listOfAugNotesDotsPairs) { +void ScoringUpFunctor::ApplyAugmentationsAndPerfections() +{ + for (std::pair pairNoteAndDot : m_listOfAugNotesDotsPairs) { pairNoteAndDot.first->SetDurQuality(DURQUALITY_mensural_perfecta); pairNoteAndDot.second->SetForm(dotLog_FORM_aug); - }for (std::pair pairNoteAndDot : m_listOfPerfNotesDotsPairs) { + } + for (std::pair pairNoteAndDot : m_listOfPerfNotesDotsPairs) { pairNoteAndDot.first->SetDurQuality(DURQUALITY_mensural_perfecta); pairNoteAndDot.second->SetForm(dotLog_FORM_div); } @@ -716,7 +724,8 @@ bool ScoringUpFunctor::EvalDotOfDiv( this->FindDurQuals(seq1, sum1, unit); this->FindDurQuals(seq2, sum2, unit); ApplyAugmentationsAndPerfections(); - } else { + } + else { m_listOfAugNotesDotsPairs.clear(); m_listOfPerfNotesDotsPairs.clear(); } From 70b75de7481e65c13cd69d0e9eead7c7e5546a58 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sun, 20 Oct 2024 04:36:48 +0200 Subject: [PATCH 87/88] Fix alteration case for multiple perfect mensurations when there is a dot of division --- src/scoringupfunctor.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 2f67010110..4fe0c7a41c 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -327,13 +327,16 @@ double ScoringUpFunctor::GetDurNumberValue( assert(note); durquality = note->GetDurQuality(); } - // int longaDefaultVal = m_modusMinor * m_tempus * m_prolatio; + int longaDefaultVal = m_modusMinor * m_tempus * m_prolatio; int brevisDefaultVal = m_tempus * m_prolatio; int semibrevisDefaultVal = m_prolatio; double durnum = 0; switch (dur) { case DURATION_longa: - if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (durquality == DURQUALITY_mensural_altera) { + durnum = 2 * longaDefaultVal; + } + else if (m_modusMinor == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * brevisDefaultVal; if (m_modusMinor == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") @@ -351,7 +354,10 @@ double ScoringUpFunctor::GetDurNumberValue( } break; case DURATION_brevis: - if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (durquality == DURQUALITY_mensural_altera) { + durnum = 2 * brevisDefaultVal; + } + else if (m_tempus == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3 * semibrevisDefaultVal; if (m_tempus == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") @@ -369,7 +375,10 @@ double ScoringUpFunctor::GetDurNumberValue( } break; case DURATION_semibrevis: - if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { + if (durquality == DURQUALITY_mensural_altera) { + durnum = 2 * semibrevisDefaultVal; + } + else if (m_prolatio == 3 || durquality == DURQUALITY_mensural_perfecta || followedByDot) { durnum = 3; if (m_prolatio == 2 && followedByDot) { // Candidate for augmentation ( and @num="2", @numbase="3") @@ -393,6 +402,9 @@ double ScoringUpFunctor::GetDurNumberValue( Dot *dot = vrv_cast(nextElement); m_listOfAugNotesDotsPairs.push_back({ note, dot }); } + else if (durquality == DURQUALITY_mensural_altera) { + durnum = 2; + } else { durnum = 1; } @@ -714,7 +726,7 @@ bool ScoringUpFunctor::EvalDotOfDiv( // This is a "dot of division" flagDotOfDiv = true; // Then it divides the sequence into the following two: - ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 1 }; + ArrayOfElementDurPairs seq1 = { sequence.begin(), sequence.begin() + dotInd + 2 }; ArrayOfElementDurPairs seq2 = { sequence.begin() + dotInd + 2, sequence.end() }; // Encode the dot of division: LayerElement *dotElement = sequence.at(dotInd + 1).first; From 1da089fe38478e3c1eeb9d25c1d108aa96413dcf Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Tue, 22 Oct 2024 21:50:39 +0200 Subject: [PATCH 88/88] Add private variable initialization in the constructor --- include/vrv/scoringupfunctor.h | 25 +++++++++++++++---------- src/scoringupfunctor.cpp | 10 +++++++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/vrv/scoringupfunctor.h b/include/vrv/scoringupfunctor.h index 8f1cc944d9..c5b58fe98c 100644 --- a/include/vrv/scoringupfunctor.h +++ b/include/vrv/scoringupfunctor.h @@ -92,14 +92,7 @@ class ScoringUpFunctor : public Functor { protected: // private: - int m_modusMaior; - int m_modusMinor; - int m_tempus; - int m_prolatio; - ArrayOfElementDurPairs m_dursInVoiceSameMensur; - std::vector m_listOfSequences; - std::list> m_listOfAugNotesDotsPairs; - std::list> m_listOfPerfNotesDotsPairs; + // public: // @@ -107,10 +100,22 @@ class ScoringUpFunctor : public Functor { private: // The current score time in the measure (incremented by each element) double m_currentScoreTime; - // The current Mensur - Mensur *m_currentMensur; // The current notation type data_NOTATIONTYPE m_notationType; + // The current Mensur + Mensur *m_currentMensur; + int m_modusMaior; + int m_modusMinor; + int m_tempus; + int m_prolatio; + // Vector of pairs of elements (that are notes, rests, or dots) and their durations + ArrayOfElementDurPairs m_dursInVoiceSameMensur; + // Vector of vectors of pairs of elements (that are notes, rests, or dots) and their durations + std::vector m_listOfSequences; + // List of pairs made of the form {note, following_dot} for notes followed by dots of augmentation + std::list> m_listOfAugNotesDotsPairs; + // List of pairs made of the form {note, following_dot} for notes followed by dots of perfection + std::list> m_listOfPerfNotesDotsPairs; }; } // namespace vrv diff --git a/src/scoringupfunctor.cpp b/src/scoringupfunctor.cpp index 4fe0c7a41c..5000aac93b 100644 --- a/src/scoringupfunctor.cpp +++ b/src/scoringupfunctor.cpp @@ -33,8 +33,16 @@ namespace vrv { ScoringUpFunctor::ScoringUpFunctor() : Functor() { m_currentScoreTime = 0.0; - m_currentMensur = NULL; m_notationType = NOTATIONTYPE_cmn; + m_currentMensur = NULL; + m_modusMaior = 2; + m_modusMinor = 2; + m_tempus = 2; + m_prolatio = 2; + ArrayOfElementDurPairs m_dursInVoiceSameMensur = {}; + std::vector m_listOfSequences = {}; + std::list> m_listOfAugNotesDotsPairs = {}; + std::list> m_listOfPerfNotesDotsPairs = {}; } FunctorCode ScoringUpFunctor::VisitLayer(Layer *layer)