Skip to content

Commit

Permalink
Merge pull request #145 from rism-digital/develop-neon
Browse files Browse the repository at this point in the history
Update with RISM
  • Loading branch information
yinanazhou authored Jun 26, 2024
2 parents a8bd0d4 + d2bc82e commit 71e2b67
Show file tree
Hide file tree
Showing 24 changed files with 317 additions and 234 deletions.
48 changes: 32 additions & 16 deletions Verovio.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/iOS/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#import <VerovioFramework/calcchordnoteheadsfunctor.h>
#import <VerovioFramework/calcdotsfunctor.h>
#import <VerovioFramework/calcledgerlinesfunctor.h>
#import <VerovioFramework/calcligaturenoteposfunctor.h>
#import <VerovioFramework/calcligatureorneumeposfunctor.h>
#import <VerovioFramework/calcslurdirectionfunctor.h>
#import <VerovioFramework/calcspanningbeamspansfunctor.h>
#import <VerovioFramework/calcstemfunctor.h>
Expand Down
56 changes: 56 additions & 0 deletions include/vrv/adjustneumexfunctor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: adjustneumexfunctor.h
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_ADJUSTNEUMEXFUNCTOR_H__
#define __VRV_ADJUSTNEUMEXFUNCTOR_H__

#include "functor.h"

namespace vrv {

//----------------------------------------------------------------------------
// AdjustNeumeXFunctor
//----------------------------------------------------------------------------

/**
* This class adjusts the X position of accidentals.
*/
class AdjustNeumeXFunctor : public DocFunctor {
public:
/**
* @name Constructors, destructors
*/
///@{
AdjustNeumeXFunctor(Doc *doc);
virtual ~AdjustNeumeXFunctor() = default;
///@}

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

/*
* Functor interface
*/
///@{
FunctorCode VisitNeume(Neume *neume) override;
///@}

protected:
//
private:
//
public:
//
private:
//
};

} // namespace vrv

#endif // __VRV_ADJUSTNEUMEXFUNCTOR_H__
2 changes: 2 additions & 0 deletions include/vrv/adjustxposfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class AdjustXPosFunctor : public DocFunctor {
AdjustXPosAlignmentOffset m_currentAlignment;
// The preceeding alignment
AdjustXPosAlignmentOffset m_previousAlignment;
// The current measure
Measure *m_measure;
};

} // namespace vrv
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: calcligaturenoteposfunctor.h
// Name: calcligatureorneumeposfunctor.h
// Author: David Bauer
// Created: 2023
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_CALCLIGATURENOTEPOSFUNCTOR_H__
#define __VRV_CALCLIGATURENOTEPOSFUNCTOR_H__
#ifndef __VRV_CALCLIGATUREORNEUMEPOSFUNCTOR_H__
#define __VRV_CALCLIGATUREORNEUMEPOSFUNCTOR_H__

#include "functor.h"

namespace vrv {

//----------------------------------------------------------------------------
// CalcLigatureNotePosFunctor
// CalcLigatureOrNeumePosFunctor
//----------------------------------------------------------------------------

/**
* This class sets the note position for each note in ligature.
*/
class CalcLigatureNotePosFunctor : public DocFunctor {
class CalcLigatureOrNeumePosFunctor : public DocFunctor {
public:
/**
* @name Constructors, destructors
*/
///@{
CalcLigatureNotePosFunctor(Doc *doc);
virtual ~CalcLigatureNotePosFunctor() = default;
CalcLigatureOrNeumePosFunctor(Doc *doc);
virtual ~CalcLigatureOrNeumePosFunctor() = default;
///@}

/*
Expand All @@ -53,4 +53,4 @@ class CalcLigatureNotePosFunctor : public DocFunctor {

} // namespace vrv

#endif // __VRV_CALCLIGATURENOTEPOSFUNCTOR_H__
#endif // __VRV_CALCLIGATUREORNEUMEPOSFUNCTOR_H__
2 changes: 1 addition & 1 deletion include/vrv/clef.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Clef : public LayerElement,
/**
* Return the offset of the clef
*/
int GetClefLocOffset() const;
int GetClefLocOffset(data_NOTATIONTYPE notationType) const;

//----------------//
// Static methods //
Expand Down
6 changes: 6 additions & 0 deletions include/vrv/horizontalaligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "atts_shared.h"
#include "object.h"
#include "vrv.h"

namespace vrv {

Expand Down Expand Up @@ -184,6 +185,11 @@ class Alignment : public Object {
*/
bool HasTimestampOnly() const;

/**
* Debug message
*/
std::string LogDebugTreeMsg() override { return StringFormat("%d %f", this->GetXRel(), this->GetTime()); }

//----------------//
// Static methods //
//----------------//
Expand Down
8 changes: 8 additions & 0 deletions include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ class Object : public BoundingBox {
virtual FunctorCode AcceptEnd(ConstFunctor &functor) const;
///@}

/**
* Output the class name of the object (or a custom msg) and of its children recursively
*/
///@{
void LogDebugTree(int maxDepth = UNLIMITED_DEPTH, int level = 0);
virtual std::string LogDebugTreeMsg() { return this->GetClassName(); }
///@}

//----------------//
// Static methods //
//----------------//
Expand Down
2 changes: 1 addition & 1 deletion include/vrv/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class View {

/**
* @name Methods for drawing parts of neume LayerElement child classes.
* Defined in view_neumes.cpp
* Defined in view_neume.cpp
*/
///@{
void DrawNcAsNotehead(DeviceContext *dc, Nc *nc, Layer *layer, Staff *staff, Measure *measure);
Expand Down
30 changes: 30 additions & 0 deletions src/adjustneumexfunctor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/////////////////////////////////////////////////////////////////////////////
// Name: adjustneumexfunctor.cpp
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#include "adjustneumexfunctor.h"

//----------------------------------------------------------------------------

#include "doc.h"
#include "score.h"

//----------------------------------------------------------------------------

namespace vrv {

//----------------------------------------------------------------------------
// AdjustNeumeXFunctor
//----------------------------------------------------------------------------

AdjustNeumeXFunctor::AdjustNeumeXFunctor(Doc *doc) : DocFunctor(doc) {}

FunctorCode AdjustNeumeXFunctor::VisitNeume(Neume *neume)
{
return FUNCTOR_CONTINUE;
}

} // namespace vrv
11 changes: 9 additions & 2 deletions src/adjustxposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AdjustXPosFunctor::AdjustXPosFunctor(Doc *doc, const std::vector<int> &staffNs)
m_staffNs = staffNs;
m_staffSize = 100;
m_rightBarLinesOnly = false;
m_measure = NULL;
}

FunctorCode AdjustXPosFunctor::VisitAlignment(Alignment *alignment)
Expand Down Expand Up @@ -145,8 +146,9 @@ FunctorCode AdjustXPosFunctor::VisitLayerElement(LayerElement *layerElement)
int selfRight = layerElement->GetAlignment()->GetXRel();
if (!layerElement->HasSelfBB() || layerElement->HasEmptyBB()) {
selfRight = layerElement->GetAlignment()->GetXRel();
// Still add the right margin for the barlines
if (layerElement->Is(BARLINE)) selfRight += m_doc->GetRightMargin(layerElement) * drawingUnit;
// Still add the right margin for the barlines but not with non measure music
if (layerElement->Is(BARLINE) && m_measure->IsMeasuredMusic())
selfRight += m_doc->GetRightMargin(layerElement) * drawingUnit;
}
else {
selfRight = layerElement->GetSelfRight() + m_doc->GetRightMargin(layerElement) * drawingUnit;
Expand Down Expand Up @@ -210,6 +212,8 @@ FunctorCode AdjustXPosFunctor::VisitMeasure(Measure *measure)
m_upcomingMinPos = VRV_UNSET;
m_cumulatedXShift = 0;

m_measure = measure;

System *system = vrv_cast<System *>(measure->GetFirstAncestor(SYSTEM));
assert(system);

Expand Down Expand Up @@ -250,6 +254,9 @@ FunctorCode AdjustXPosFunctor::VisitMeasure(Measure *measure)

this->SetFilters(previousFilters);

// There is no reason to adjust a minimum width with mensural music
if (!measure->IsMeasuredMusic()) return FUNCTOR_SIBLINGS;

int minMeasureWidth = m_doc->GetOptions()->m_unit.GetValue() * m_doc->GetOptions()->m_measureMinWidth.GetValue();
// First try to see if we have a double measure length element
MeasureAlignerTypeComparison alignmentComparison(ALIGNMENT_FULLMEASURE2);
Expand Down
34 changes: 30 additions & 4 deletions src/alignfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
#include "fig.h"
#include "layer.h"
#include "ligature.h"
#include "nc.h"
#include "neume.h"
#include "page.h"
#include "rend.h"
#include "rest.h"
#include "runningelement.h"
#include "section.h"
#include "staff.h"
#include "svg.h"
#include "syllable.h"
#include "system.h"
#include "tabgrp.h"
#include "verse.h"
Expand Down Expand Up @@ -140,6 +143,7 @@ FunctorCode AlignHorizontallyFunctor::VisitLayerElement(LayerElement *layerEleme
Rest *restParent = vrv_cast<Rest *>(layerElement->GetFirstAncestor(REST, MAX_NOTE_DEPTH));
TabGrp *tabGrpParent = vrv_cast<TabGrp *>(layerElement->GetFirstAncestor(TABGRP, MAX_TABGRP_DEPTH));
const bool ligatureAsBracket = m_doc->GetOptions()->m_ligatureAsBracket.GetValue();
const bool neumeAsNote = m_doc->GetOptions()->m_neumeAsNote.GetValue();

if (chordParent) {
layerElement->SetAlignment(chordParent->GetAlignment());
Expand Down Expand Up @@ -263,21 +267,41 @@ FunctorCode AlignHorizontallyFunctor::VisitLayerElement(LayerElement *layerEleme
layerElement->SetAlignment(note->GetAlignment());
}
else if (layerElement->Is(SYL)) {
Staff *staff = layerElement->GetAncestorStaff();
Note *note = vrv_cast<Note *>(layerElement->GetFirstAncestor(NOTE));
if (!note || (staff->m_drawingNotationType == NOTATIONTYPE_neume)) {
type = ALIGNMENT_DEFAULT;
if (note) {
layerElement->SetAlignment(note->GetAlignment());
}
else {
layerElement->SetAlignment(note->GetAlignment());
Syllable *syllable = vrv_cast<Syllable *>(layerElement->GetFirstAncestor(SYLLABLE));
if (syllable) layerElement->SetAlignment(syllable->GetAlignment());
}
// Else add a default
}
else if (layerElement->Is(VERSE)) {
// Idem
Note *note = vrv_cast<Note *>(layerElement->GetFirstAncestor(NOTE));
assert(note);
layerElement->SetAlignment(note->GetAlignment());
}
else if (layerElement->Is(NC)) {
// Align with the neume
if (!neumeAsNote) {
Neume *neume = vrv_cast<Neume *>(layerElement->GetFirstAncestor(NEUME));
assert(neume);
layerElement->SetAlignment(neume->GetAlignment());
}
// Otherwise each nc has its own aligner
}
else if (layerElement->Is(NEUME)) {
// Align with the syllable
if (neumeAsNote) {
Syllable *syllable = vrv_cast<Syllable *>(layerElement->GetFirstAncestor(SYLLABLE));
assert(syllable);
layerElement->SetAlignment(syllable->GetAlignment());
return FUNCTOR_CONTINUE;
}
// Otherwise each neume has its own aligner
}
else if (layerElement->Is(GRACEGRP)) {
return FUNCTOR_CONTINUE;
}
Expand Down Expand Up @@ -370,6 +394,8 @@ FunctorCode AlignHorizontallyFunctor::VisitMeasureEnd(Measure *measure)

if (m_hasMultipleLayer) measure->HasAlignmentRefWithMultipleLayers(true);

measure->m_measureAligner.LogDebugTree(3);

return FUNCTOR_CONTINUE;
}

Expand Down
5 changes: 3 additions & 2 deletions src/calcalignmentpitchposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ FunctorCode CalcAlignmentPitchPosFunctor::VisitLayerElement(LayerElement *layerE
if (layerElement->Is(ACCID)) {
Accid *accid = vrv_cast<Accid *>(layerElement);
assert(accid);
if (!accid->GetFirstAncestor(NOTE) && !accid->GetFirstAncestor(CUSTOS)) {
if (!accid->GetFirstAncestor(NOTE) && !accid->GetFirstAncestor(CUSTOS) && !m_doc->IsNeumeLines()) {
// do something for accid that are not children of a note - e.g., mensural?
// skip for neume-lines mode as accid doesn't have a pitch in this case
accid->SetDrawingYRel(staffY->CalcPitchPosYRel(m_doc, accid->CalcDrawingLoc(layerY, layerElementY)));
}
// override if staff position is set explicitly
Expand Down Expand Up @@ -311,7 +312,7 @@ FunctorCode CalcAlignmentPitchPosFunctor::VisitLayerElement(LayerElement *layerE
}
layerElement->SetDrawingYRel(yRel);
}
else if (layerElement->Is(NC) && m_doc->GetOptions()->m_neumeAsNote.GetValue()) {
else if (layerElement->Is(NC)) {
Nc *nc = vrv_cast<Nc *>(layerElement);
assert(nc);
int loc = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/calcalignmentxposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,20 @@ FunctorCode CalcAlignmentXPosFunctor::VisitAlignment(Alignment *alignment)

FunctorCode CalcAlignmentXPosFunctor::VisitMeasure(Measure *measure)
{
// We start a new Measure
// Reset the previous time position and x_rel to 0;
m_previousTime = 0.0;
// We un-measured music we never have a left barline, so do not add a default space
m_previousXRel = (measure->IsMeasuredMusic()) ? m_doc->GetDrawingUnit(100) : 0;

measure->m_measureAligner.Process(*this);

return FUNCTOR_SIBLINGS;
}

FunctorCode CalcAlignmentXPosFunctor::VisitMeasureAligner(MeasureAligner *measureAligner)
{
// We start a new MeasureAligner
// Reset the previous time position and x_rel to 0;
m_previousTime = 0.0;
m_previousXRel = m_doc->GetDrawingUnit(100);

m_lastNonTimestamp = measureAligner->GetLeftBarLineAlignment();
m_measureAligner = measureAligner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////
// Name: calcligaturenoteposfunctor.cpp
// Name: calcligaturorneumeposfunctor.cpp
// Author: David Bauer
// Created: 2023
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#include "calcligaturenoteposfunctor.h"
#include "calcligatureorneumeposfunctor.h"

//----------------------------------------------------------------------------

Expand All @@ -18,12 +18,12 @@
namespace vrv {

//----------------------------------------------------------------------------
// CalcLigatureNotePosFunctor
// CalcLigatureOrNeumePosFunctor
//----------------------------------------------------------------------------

CalcLigatureNotePosFunctor::CalcLigatureNotePosFunctor(Doc *doc) : DocFunctor(doc) {}
CalcLigatureOrNeumePosFunctor::CalcLigatureOrNeumePosFunctor(Doc *doc) : DocFunctor(doc) {}

FunctorCode CalcLigatureNotePosFunctor::VisitLigature(Ligature *ligature)
FunctorCode CalcLigatureOrNeumePosFunctor::VisitLigature(Ligature *ligature)
{
if (m_doc->GetOptions()->m_ligatureAsBracket.GetValue()) return FUNCTOR_CONTINUE;

Expand Down
Loading

0 comments on commit 71e2b67

Please sign in to comment.