-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3734 from rism-digital/develop-volpiano
Basic implementation for Volpiano
- Loading branch information
Showing
6 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ enum FileFormat { | |
PAE, | ||
ABC, | ||
DARMS, | ||
VOLPIANO, | ||
MUSICXML, | ||
MUSICXMLHUM, | ||
MEIHUM, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters