Skip to content

Commit

Permalink
rehearsal segno and coda support
Browse files Browse the repository at this point in the history
  • Loading branch information
SemitoneGene authored and webern committed Jan 18, 2023
1 parent 816b0c5 commit 570c373
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 16 deletions.
37 changes: 37 additions & 0 deletions Sourcecode/include/mx/api/CodaData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/PositionData.h"

namespace mx
{
namespace api
{
class CodaData
{
public:
PositionData positionData;
bool isColorSpecified;
ColorData colorData;

CodaData()
: positionData{}
, isColorSpecified{ false }
, colorData{}
{
}
};

MXAPI_EQUALS_BEGIN( CodaData )
MXAPI_EQUALS_MEMBER( positionData )
MXAPI_EQUALS_MEMBER( isColorSpecified )
MXAPI_EQUALS_MEMBER( colorData )
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS( CodaData );
}
}
19 changes: 15 additions & 4 deletions Sourcecode/include/mx/api/DirectionData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/WedgeData.h"
#include "mx/api/ChordData.h"
#include "mx/api/CodaData.h"
#include "mx/api/MarkData.h"
#include "mx/api/TempoData.h"
#include "mx/api/OttavaData.h"
#include "mx/api/RehearsalData.h"
#include "mx/api/SegnoData.h"
#include "mx/api/TempoData.h"
#include "mx/api/WedgeData.h"
#include "mx/api/WordsData.h"
#include "mx/api/ChordData.h"

namespace mx
{
Expand Down Expand Up @@ -62,6 +65,9 @@ namespace mx
std::vector<SpannerStop> bracketStops;
std::vector<WordsData> words;
std::vector<ChordData> chords;
std::vector<SegnoData> segnos;
std::vector<CodaData> codas;
std::vector<RehearsalData> rehearsals;

DirectionData()
: tickTimePosition{ 0 }
Expand All @@ -77,6 +83,7 @@ namespace mx
, bracketStops{}
, words{}
, chords{}
, segnos{}
{

}
Expand All @@ -93,7 +100,9 @@ namespace mx
directionData.tempos.size() == 0 &&
directionData.ottavaStarts.size() == 0 &&
directionData.ottavaStops.size() == 0 &&
directionData.words.size() == 0;
directionData.words.size() == 0 &&
directionData.segnos.size() == 0 &&
directionData.codas.size() == 0;
}

MXAPI_EQUALS_BEGIN( DirectionData )
Expand All @@ -111,6 +120,8 @@ namespace mx
MXAPI_EQUALS_MEMBER( bracketStops )
MXAPI_EQUALS_MEMBER( words )
MXAPI_EQUALS_MEMBER( chords )
MXAPI_EQUALS_MEMBER( segnos )
MXAPI_EQUALS_MEMBER( codas )
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS( DirectionData );
}
Expand Down
46 changes: 46 additions & 0 deletions Sourcecode/include/mx/api/RehearsalData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/PositionData.h"

namespace mx
{
namespace api
{
class RehearsalData
{
public:
std::string text;
PositionData positionData;
bool isColorSpecified;
ColorData colorData;
FontData fontData;

// Additional data about enclosing shape is available
// but not supported at this time.

RehearsalData()
: text{}
, positionData{}
, isColorSpecified{ false }
, colorData{}
, fontData{}
{
}
};

MXAPI_EQUALS_BEGIN( RehearsalData )
MXAPI_EQUALS_MEMBER( text )
MXAPI_EQUALS_MEMBER( positionData )
MXAPI_EQUALS_MEMBER( isColorSpecified )
MXAPI_EQUALS_MEMBER( colorData )
MXAPI_EQUALS_MEMBER( fontData )
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS( RehearsalData );
}
}
37 changes: 37 additions & 0 deletions Sourcecode/include/mx/api/SegnoData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/PositionData.h"

namespace mx
{
namespace api
{
class SegnoData
{
public:
PositionData positionData;
bool isColorSpecified;
ColorData colorData;

SegnoData()
: positionData{}
, isColorSpecified{ false }
, colorData{}
{
}
};

MXAPI_EQUALS_BEGIN( SegnoData )
MXAPI_EQUALS_MEMBER( positionData )
MXAPI_EQUALS_MEMBER( isColorSpecified )
MXAPI_EQUALS_MEMBER( colorData )
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS( SegnoData );
}
}
6 changes: 5 additions & 1 deletion Sourcecode/private/cpul/catch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8642,7 +8642,11 @@ namespace Catch {

#ifdef CATCH_PLATFORM_MAC

#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#endif

#elif defined(CATCH_PLATFORM_IPHONE)

Expand Down
34 changes: 32 additions & 2 deletions Sourcecode/private/mx/impl/DirectionReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,34 @@ namespace mx

void DirectionReader::parseRehearsal( const core::DirectionType& directionType)
{
const auto& rehearsalSet = directionType.getRehearsalSet();

for( const auto& rehearsalPtr : rehearsalSet )
{
api::RehearsalData outRehearsal;
const auto& attr = *rehearsalPtr->getAttributes();
outRehearsal.text = rehearsalPtr->getValue().getValue();
outRehearsal.positionData = getPositionData( attr );
outRehearsal.colorData = getColor( attr );
myOutDirectionData.rehearsals.emplace_back( std::move( outRehearsal ) );
}

MX_UNUSED( directionType );
}


void DirectionReader::parseSegno( const core::DirectionType& directionType)
{
MX_UNUSED( directionType );
const auto& segnoSet = directionType.getSegnoSet();

for( const auto& segnoPtr : segnoSet )
{
api::SegnoData outSegno;
const auto& attr = *segnoPtr->getAttributes();
outSegno.positionData = getPositionData( attr );
outSegno.colorData = getColor( attr );
myOutDirectionData.segnos.emplace_back( std::move( outSegno ) );
}
}


Expand All @@ -347,7 +368,16 @@ namespace mx

void DirectionReader::parseCoda( const core::DirectionType& directionType)
{
MX_UNUSED( directionType );
const auto& codaSet = directionType.getCodaSet();

for( const auto& codaPtr : codaSet )
{
api::CodaData outCoda;
const auto& attr = *codaPtr->getAttributes();
outCoda.positionData = getPositionData( attr );
outCoda.colorData = getColor( attr );
myOutDirectionData.codas.emplace_back( std::move( outCoda ) );
}
}


Expand Down
27 changes: 27 additions & 0 deletions Sourcecode/private/mx/impl/DirectionWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,33 @@ namespace mx
addDirectionType( outDirType, directionPtr );
}
}

if( myDirectionData.segnos.size() > 0 ) {

for( const auto& rehearsal : myDirectionData.segnos ) {
auto outDirType = core::makeDirectionType();
outDirType->setChoice( core::DirectionType::Choice::segno );
this->addDirectionType( outDirType, directionPtr );
}
}

if( myDirectionData.codas.size() > 0 ) {

for( const auto& rehearsal : myDirectionData.codas ) {
auto outDirType = core::makeDirectionType();
outDirType->setChoice( core::DirectionType::Choice::coda );
this->addDirectionType( outDirType, directionPtr );
}
}

if( myDirectionData.rehearsals.size() > 0 ) {

for( const auto& rehearsal : myDirectionData.rehearsals ) {
auto outDirType = core::makeDirectionType();
outDirType->setChoice( core::DirectionType::Choice::rehearsal );
this->addDirectionType( outDirType, directionPtr );
}
}

if( myIsFirstDirectionTypeAdded )
{
Expand Down
Loading

0 comments on commit 570c373

Please sign in to comment.