Skip to content

Commit

Permalink
Merge pull request #3734 from rism-digital/develop-volpiano
Browse files Browse the repository at this point in the history
Basic implementation for Volpiano
  • Loading branch information
ahankinson authored Jul 22, 2024
2 parents ff9cde3 + 8a03a2a commit 7b5abaa
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,12 @@
4DDBBB5E1C7AE45900054AFF /* hairpin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBB5A1C7AE45900054AFF /* hairpin.cpp */; };
4DDBBCC51C2EBAE7001AB50A /* view_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */; };
4DDBBCC61C2EBAE7001AB50A /* view_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */; };
4DE0198C2C495DB800B5B6BF /* iovolpiano.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */; };
4DE0198D2C495E6300B5B6BF /* iovolpiano.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DE0198A2C495D1F00B5B6BF /* iovolpiano.h */; };
4DE0198E2C495E6500B5B6BF /* iovolpiano.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DE0198A2C495D1F00B5B6BF /* iovolpiano.h */; settings = {ATTRIBUTES = (Public, ); }; };
4DE0198F2C495E7400B5B6BF /* iovolpiano.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */; };
4DE019902C495E7600B5B6BF /* iovolpiano.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */; };
4DE019912C495E7700B5B6BF /* iovolpiano.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */; };
4DE0B9A12988070C00D4C939 /* interface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DE0B9A02988070C00D4C939 /* interface.h */; };
4DE0B9A22988070C00D4C939 /* interface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DE0B9A02988070C00D4C939 /* interface.h */; settings = {ATTRIBUTES = (Public, ); }; };
4DE644F51EDBEA01002FBE6C /* breath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE644F41EDBEA01002FBE6C /* breath.cpp */; };
Expand Down Expand Up @@ -2051,6 +2057,8 @@
4DDBBB591C7AE45900054AFF /* dynam.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dynam.cpp; path = src/dynam.cpp; sourceTree = "<group>"; };
4DDBBB5A1C7AE45900054AFF /* hairpin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = hairpin.cpp; path = src/hairpin.cpp; sourceTree = "<group>"; };
4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_text.cpp; path = src/view_text.cpp; sourceTree = "<group>"; };
4DE0198A2C495D1F00B5B6BF /* iovolpiano.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iovolpiano.h; path = include/vrv/iovolpiano.h; sourceTree = "<group>"; };
4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = iovolpiano.cpp; path = src/iovolpiano.cpp; sourceTree = "<group>"; };
4DE0B9A02988070C00D4C939 /* interface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = interface.h; path = include/vrv/interface.h; sourceTree = "<group>"; };
4DE644F31EDBE9F8002FBE6C /* breath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = breath.h; path = include/vrv/breath.h; sourceTree = "<group>"; };
4DE644F41EDBEA01002FBE6C /* breath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = breath.cpp; path = src/breath.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2879,6 +2887,8 @@
8F59291A18854BF800FE51AD /* iomusxml.h */,
8F086EC4188539540037FD8E /* iopae.cpp */,
8F59291B18854BF800FE51AD /* iopae.h */,
4DE0198B2C495DB800B5B6BF /* iovolpiano.cpp */,
4DE0198A2C495D1F00B5B6BF /* iovolpiano.h */,
);
name = io;
sourceTree = "<group>";
Expand Down Expand Up @@ -3378,6 +3388,7 @@
4DEC4DD821C8295700D1D273 /* unclear.h in Headers */,
4DDBBB581C7AE43E00054AFF /* dynam.h in Headers */,
8F59295118854BF800FE51AD /* slur.h in Headers */,
4DE0198D2C495E6300B5B6BF /* iovolpiano.h in Headers */,
E78833652995007700D44B01 /* calcspanningbeamspansfunctor.h in Headers */,
E75EA9FA29CC3A6B003A97A7 /* calcarticfunctor.h in Headers */,
8F59295218854BF800FE51AD /* staff.h in Headers */,
Expand Down Expand Up @@ -3612,6 +3623,7 @@
BB4C4ABE22A932B6001F6AF0 /* label.h in Headers */,
E71EF3C42975E4DC00D36264 /* resetfunctor.h in Headers */,
403B0515244F3E4D00EE4F71 /* gliss.h in Headers */,
4DE0198E2C495E6500B5B6BF /* iovolpiano.h in Headers */,
BB4C4B0A22A932C3001F6AF0 /* pghead.h in Headers */,
4DFB3E8B23ABDFDA00D688C7 /* pitchinflection.h in Headers */,
E7C3AED729550190002DE5AB /* preparedatafunctor.h in Headers */,
Expand Down Expand Up @@ -3933,6 +3945,7 @@
4D1693F61E3A44F300569BF4 /* barline.cpp in Sources */,
E7901661298BCB2C008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
400FEDD6206FA74D000D3233 /* gracegrp.cpp in Sources */,
4DE0198F2C495E7400B5B6BF /* iovolpiano.cpp in Sources */,
4D1AC9782B6A9BB200434023 /* filereader.cpp in Sources */,
4D89F90F201771AE00A4D336 /* num.cpp in Sources */,
4D1693F71E3A44F300569BF4 /* bboxdevicecontext.cpp in Sources */,
Expand Down Expand Up @@ -4307,6 +4320,7 @@
4DACC9902990F29A00B55913 /* atts_critapp.cpp in Sources */,
406916DC23833770009E6B04 /* mspace.cpp in Sources */,
E7A1640C29AF34750099BD6A /* adjustharmgrpsspacingfunctor.cpp in Sources */,
4DE0198C2C495DB800B5B6BF /* iovolpiano.cpp in Sources */,
4D95D4F91D718D4A00B2B856 /* systemelement.cpp in Sources */,
4D1EB6A92A2A7C5100AF2F98 /* div.cpp in Sources */,
4DDBBB5B1C7AE45900054AFF /* dynam.cpp in Sources */,
Expand Down Expand Up @@ -4508,6 +4522,7 @@
4DB3D8F01F83D1A700B5FC2B /* fig.cpp in Sources */,
E790165F298BCB27008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
8F3DD36718854B410051330C /* verticalaligner.cpp in Sources */,
4DE019902C495E7600B5B6BF /* iovolpiano.cpp in Sources */,
4D1AC9792B6A9BB200434023 /* filereader.cpp in Sources */,
4D766F0220ACAD6E006875D8 /* nc.cpp in Sources */,
4DEC4D9821C81E3B00D1D273 /* expan.cpp in Sources */,
Expand Down Expand Up @@ -4796,6 +4811,7 @@
BB4C4B9322A932E5001F6AF0 /* areaposinterface.cpp in Sources */,
E7901660298BCB27008FDB4E /* calcalignmentxposfunctor.cpp in Sources */,
BB4C4AA122A9328F001F6AF0 /* verticalaligner.cpp in Sources */,
4DE019912C495E7700B5B6BF /* iovolpiano.cpp in Sources */,
4D1AC97A2B6A9BB200434023 /* filereader.cpp in Sources */,
BB4C4B2F22A932CF001F6AF0 /* pedal.cpp in Sources */,
4D2E759222BC2B80004C51F0 /* tuning.cpp in Sources */,
Expand Down
44 changes: 44 additions & 0 deletions include/vrv/iovolpiano.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: iovolpiano.h
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_IOVOLPIANO_H__
#define __VRV_IOVOLPIANO_H__

#include <string>
#include <vector>

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

#include "iobase.h"
#include "pugixml.hpp"
#include "vrvdef.h"

namespace vrv {

//----------------------------------------------------------------------------
// VolpianoInput
//----------------------------------------------------------------------------

class VolpianoInput : public Input {
public:
// constructors and destructors
VolpianoInput(Doc *doc);
virtual ~VolpianoInput();

bool Import(const std::string &volpiano) override;

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

} // namespace vrv

#endif
1 change: 1 addition & 0 deletions include/vrv/toolkitdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum FileFormat {
PAE,
ABC,
DARMS,
VOLPIANO,
MUSICXML,
MUSICXMLHUM,
MEIHUM,
Expand Down
134 changes: 134 additions & 0 deletions src/iovolpiano.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: iovolpiano.cpp
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#include "iovolpiano.h"

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

#include <cassert>
#include <fstream>
#include <sstream>
#include <string>

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

#include "clef.h"
#include "doc.h"
#include "layer.h"
#include "mdiv.h"
#include "measure.h"
#include "note.h"
#include "score.h"
#include "section.h"
#include "staff.h"
#include "staffdef.h"
#include "staffgrp.h"
#include "vrv.h"

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

namespace vrv {

//----------------------------------------------------------------------------
// VolpianoInput
//----------------------------------------------------------------------------

VolpianoInput::VolpianoInput(Doc *doc) : Input(doc) {}

VolpianoInput::~VolpianoInput() {}

//////////////////////////////////////////////////////////////////////////

bool VolpianoInput::Import(const std::string &volpiano)
{
m_doc->Reset();
m_doc->SetType(Raw);
// The mDiv
Mdiv *mdiv = new Mdiv();
mdiv->m_visibility = Visible;
m_doc->AddChild(mdiv);
// The score
Score *score = new Score();
mdiv->AddChild(score);
// the section
Section *section = new Section();
score->AddChild(section);

Staff *staff = new Staff(1);
Measure *measure = new Measure(UNMEASURED, 1);
Layer *layer = new Layer();
layer->SetN(1);

staff->AddChild(layer);
measure->AddChild(staff);
section->AddChild(measure);

data_ACCIDENTAL_WRITTEN accidVal = ACCIDENTAL_WRITTEN_NONE;

static std::map<char, std::pair<data_PITCHNAME, int>> notes
= { { '8', { PITCHNAME_a, 3 } }, { '9', { PITCHNAME_g, 3 } }, { 'a', { PITCHNAME_a, 3 } },
{ 'b', { PITCHNAME_b, 3 } }, { 'c', { PITCHNAME_c, 4 } }, { 'd', { PITCHNAME_d, 4 } },
{ 'e', { PITCHNAME_e, 4 } }, { 'f', { PITCHNAME_f, 4 } }, { 'g', { PITCHNAME_g, 4 } },
{ 'h', { PITCHNAME_a, 4 } }, { 'j', { PITCHNAME_b, 4 } }, { 'k', { PITCHNAME_c, 5 } },
{ 'l', { PITCHNAME_d, 5 } }, { 'm', { PITCHNAME_e, 5 } }, { 'n', { PITCHNAME_f, 5 } },
{ 'o', { PITCHNAME_g, 5 } }, { 'p', { PITCHNAME_a, 5 } }, { 'q', { PITCHNAME_b, 5 } },
{ 'r', { PITCHNAME_c, 6 } }, { 's', { PITCHNAME_d, 6 } } };

static std::map<char, char> liquescents = { { '(', '8' }, { ')', '9' }, { 'A', 'a' }, { 'B', 'b' }, { 'C', 'c' },
{ 'D', 'd' }, { 'E', 'e' }, { 'F', 'f' }, { 'G', 'g' }, { 'H', 'h' }, { 'J', 'j' }, { 'K', 'k' }, { 'L', 'l' },
{ 'M', 'm' }, { 'N', 'n' }, { 'O', 'o' }, { 'P', 'p' }, { 'Q', 'q' }, { 'R', 'r' }, { 'S', 's' } };

for (char ch : volpiano) {
if (notes.contains(ch) || liquescents.contains(ch)) {
const bool liquescent = liquescents.contains(ch);
if (liquescent) {
ch = liquescents.at(ch);
}
Note *note = new Note();
auto [pname, oct] = notes.at(ch);
note->SetPname(pname);
note->SetOct(oct);
if (accidVal != ACCIDENTAL_WRITTEN_NONE) {
Accid *accid = new Accid();
accid->SetAccid(accidVal);
accid->IsAttribute(true);
note->AddChild(accid);
accidVal = ACCIDENTAL_WRITTEN_NONE;
}
if (liquescent) {
note->SetCue(BOOLEAN_true);
}
layer->AddChild(note);
}
else if (ch == 'i' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z') {
accidVal = ACCIDENTAL_WRITTEN_f;
}
else if (ch == 'I' || ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z') {
accidVal = ACCIDENTAL_WRITTEN_n;
}
}

// add minimal scoreDef
StaffGrp *staffGrp = new StaffGrp();
StaffDef *staffDef = new StaffDef();
staffDef->SetN(1);
staffDef->SetLines(5);
// Arbitrary clef
Clef *clef = new Clef();
clef->IsAttribute(true);
clef->SetLine(2);
clef->SetShape(CLEFSHAPE_G);
staffDef->AddChild(clef);
staffGrp->AddChild(staffDef);
m_doc->GetFirstScoreDef()->AddChild(staffGrp);

m_doc->ConvertToPageBasedDoc();

return true;
}

} // namespace vrv
3 changes: 2 additions & 1 deletion src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ Options::Options()
m_baseOptions.AddOption(&m_allPages);

m_inputFrom.SetInfo("Input from",
"Select input format from: \"abc\", \"darms\", \"humdrum\", \"mei\", \"pae\", \"xml\" (musicxml)");
"Select input format from: \"abc\", \"darms\", \"humdrum\", \"mei\", \"pae\", \"volpiano\", \"xml\" "
"(musicxml)");
m_inputFrom.Init("mei");
m_inputFrom.SetKey("inputFrom");
m_inputFrom.SetShortOption('f', false);
Expand Down
7 changes: 7 additions & 0 deletions src/toolkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "iomei.h"
#include "iomusxml.h"
#include "iopae.h"
#include "iovolpiano.h"
#include "layer.h"
#include "measure.h"
#include "nc.h"
Expand Down Expand Up @@ -200,6 +201,9 @@ bool Toolkit::SetInputFrom(std::string const &inputFrom)
else if (inputFrom == "darms") {
m_inputFrom = DARMS;
}
else if (inputFrom == "volpiano") {
m_inputFrom = VOLPIANO;
}
else if ((inputFrom == "humdrum") || (inputFrom == "hum")) {
m_inputFrom = HUMDRUM;
}
Expand Down Expand Up @@ -521,6 +525,9 @@ bool Toolkit::LoadData(const std::string &data)
return false;
#endif
}
else if (inputFormat == VOLPIANO) {
input = new VolpianoInput(&m_doc);
}
#ifndef NO_HUMDRUM_SUPPORT
else if (inputFormat == HUMDRUM) {
// LogInfo("Importing Humdrum data");
Expand Down

0 comments on commit 7b5abaa

Please sign in to comment.