Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,662 changes: 2,622 additions & 40 deletions Sourcecode/mx/api/Smufl.cpp

Large diffs are not rendered by default.

28 changes: 5 additions & 23 deletions Sourcecode/mx/api/Smufl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
#include "mx/api/ApiCommon.h"

#include <string>
#include <map>
#include <unordered_map>

namespace mx
{
namespace api
{
using SmuflPair = std::pair<const std::string, const char16_t>;
using SmuflMap = std::map<const std::string, const char16_t>;
using SmuflIter = SmuflMap::const_iterator;


{
struct SmuflGlyphname
{
SmuflGlyphname( std::string inNameAbove,
Expand All @@ -38,31 +33,18 @@ namespace mx

public:

static Smufl& getInstance();

// returns the SMuFL codepoint value for the given name
// returns 0 (i.e. '\0';) if not found
static char16_t findCodepoint(const std::string& inName);

// finds the SMuFL glyphname for the given codepoint
// returns empty string if codepoint is not found
static const std::string& findName( char16_t codepoint );

// returns 'true' if the given name is found in the table
static bool isNameValid(const std::string& inName);

// returns 'true' if the given codepoint is found
// in the table. ignores alternateCodepoint values
static bool isCodepointValid( char16_t codepoint );

// returns an immutable ref to the map
static const SmuflMap& getMap();

// returns cbegin() / cend()
static SmuflIter begin();
static SmuflIter end();


private:
Smufl();
static std::map<const std::string, const char16_t> ourMap;
};
}
}
17 changes: 12 additions & 5 deletions Sourcecode/mx/impl/MeasureWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ namespace mx
} // foreach voice

std::vector<api::NoteData> fakeEmptyNoteVector;
writeDirections( directionIter, directionEnd, std::cend(fakeEmptyNoteVector), std::cbegin(fakeEmptyNoteVector), std::cend(fakeEmptyNoteVector) );
const auto iterBegin = std::cbegin(fakeEmptyNoteVector);
const auto iterEnd = std::cend(fakeEmptyNoteVector);
writeDirections( directionIter, directionEnd, iterEnd, iterBegin, iterEnd );

bool areClefsRemaining = clefIter != clefEnd;
bool areMeasureKeysRemaining = myMeasureKeysIter != myMeasureKeysEnd;
Expand Down Expand Up @@ -571,19 +573,24 @@ namespace mx
}


void MeasureWriter::writeDirections( dIter& directionIter, const dIter& directionEnd, const NoteIter& inNoteIter, const NoteIter& inNotesBegin, const NoteIter& inNotesEnd )
void MeasureWriter::writeDirections(dIter& directionIter,
const dIter& directionEnd,
const NoteIter& inNoteIter,
const NoteIter& inNotesBegin,
const NoteIter& inNotesEnd )
{
if( directionIter == directionEnd )
{
return;
}

const bool isNotesEnd = inNoteIter == inNotesEnd;
const bool isLastNote = !isNotesEnd && ( inNoteIter + 1 == inNotesEnd );
const bool isLastNote = isNotesEnd || ( inNoteIter + 1 == inNotesEnd );
const bool isFirstNote = !isLastNote && !isNotesEnd && ( inNoteIter == inNotesBegin );
const auto previousNote = isFirstNote ? inNotesEnd : ( inNoteIter - 1 );
const bool isOnlyNote = inNoteIter == inNotesBegin && isLastNote;
const auto previousNote = ( isFirstNote || isOnlyNote ) ? inNotesEnd : ( inNoteIter - 1 );
const auto nextNote = ( isLastNote || isNotesEnd ) ? inNotesEnd : ( inNoteIter + 1 );
const bool isTickTimeSameAsPreviousNote = ( isFirstNote || isNotesEnd ) ? false : ( inNoteIter->tickTimePosition == previousNote->tickTimePosition );
const bool isTickTimeSameAsPreviousNote = ( isFirstNote || isOnlyNote || isNotesEnd ) ? false : ( inNoteIter->tickTimePosition == previousNote->tickTimePosition );
const bool isIndependentNote = !isTickTimeSameAsPreviousNote;

if( isFirstNote )
Expand Down
6 changes: 2 additions & 4 deletions Sourcecode/mx/impl/SmuflGlyphMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
#pragma once

#include <string>
#include <map>
#include <unordered_map>

namespace mx
{
namespace impl
{
inline std::map<const std::string, const char16_t> createSmuflMap()
inline void createSmuflMap(std::map<const std::string, const char16_t>& outMap)
{
std::map<const std::string, const char16_t> outMap;
outMap.emplace(std::make_pair<const std::string, const char16_t>( "4stringTabClef", 0xE06E )); // glyphnumber: 0, 4-string tab clef
outMap.emplace(std::make_pair<const std::string, const char16_t>( "6stringTabClef", 0xE06D )); // glyphnumber: 1, 6-string tab clef
outMap.emplace(std::make_pair<const std::string, const char16_t>( "accSagittal11LargeDiesisDown", 0xE30D )); // glyphnumber: 2, 11 large diesis down, 3° down [46 EDO]
Expand Down Expand Up @@ -2608,7 +2607,6 @@ namespace mx
outMap.emplace(std::make_pair<const std::string, const char16_t>( "windTrillKey", 0xE5FA )); // glyphnumber: 2591, Trill key
outMap.emplace(std::make_pair<const std::string, const char16_t>( "windVeryTightEmbouchure", 0xE601 )); // glyphnumber: 2592, Very tight embouchure
outMap.emplace(std::make_pair<const std::string, const char16_t>( "windWeakAirPressure", 0xE602 )); // glyphnumber: 2593, Very relaxed embouchure / weak air-pressure
return outMap;
}
}
}
Loading