Skip to content

Commit

Permalink
support microtonal notes and improve documentation #41 #42 #43 (#50)
Browse files Browse the repository at this point in the history
* release v0.3.0

* frz fix placement of directions in chords

* frz round trip musicxml version

* frz fix tuplet issues

* frz branch progress

* gene noteheads and lyrics

* fix errant comments in cmake build

* better error message and project update

* gitignore

* merge mxapi into develop

* probably ok

* sublime

* merge mxapi branch (#20)

* mxapi komp-build stuff

* mxapi bombe test

* the latest crap

* mxapi handle divisions changes

* mxapi use voice 1 in bombe

* mx-version-0.2.0.2

* mx-version-0.2.0.3

* mx-version-0.2.0.4

* mxapi adjust -0 to say 0 instead when stringing decimals

* mx-version-0.2.0.5

* mx-version-0.2.0.6

* mxapi save ornaments

* mx-version-0.2.0.7

* mxapi working on direction offset problems

* mxapi direction mark time bug fixed

* mxapi reenable some tests

* mxapi pedal start stop working

* mxapi disable the core tests

* mx-version-0.2.0.8

* mxapi working on order of directions and notes

* mxapi directions are now written in a relatively sane order with respect to notes

* mxapi tests passing

* mx-version-0.2.0.9

* mxapi fix direction position data import and export

* mx-version-0.2.0.10

* mxapi compile visual studio

* mx-version-0.2.0.11

* mxapi doesnt compile add tremolos

* better support for tremolo glyphs

* mxapi words are exporting

* mxapi finish with words for now

* mx-version-0.2.0.12

* mxapi save and load technical marks

* mx-version-0.2.0.13

* mxapi turn off cout

* mxapi fix bug with other articulation

* mx-version-0.2.0.14

* mxapi merge decimal

* mxapi score data and tests

* mxapi tests

* mxapi sort score data before writing

* mx-version-0.2.0.17

* mxapi progress on directions robustness

* more work on cursor and direction

* mxapi directions seem more bulletproof now

* mx-version-0.2.0.18

* mxapi fix chord bug

* mxapi fix xcode project groups - add enum macros

* mxapi add musicxml instrument sound strings

* mxapi sound id

* mxapi restore compile control

* mx-version-0.2.0.20

* sound and general midi work

* mxapi begin adding chord support

* mxapi chord test simple

* mxapi middle of something does not compile

* mxapi chord progress

* mxapi chord saving works but round trip does not work

* mxapi still cannot fix the round trip test

* mxapi basic chord support complete

* mx-version-0.2.0.21

* mxapi add chord symbol features

* mx-version-0.2.0.22

* mxapi add processing instructions

* mx-version-0.2.0.23

* more chord symbol work

* mx-version-0.2.0.24

* mxapi not much

* mxapi Barlines (#12)

* mxapi fix broken test

* mx-version-0.2.0.25

* Feature/mxapi (#14)

mxapi barlines and endings

* Feature/repeats (#15)

mxapi repeats

* mx-version-0.2.0.26

* mxapi add chord positioning

* mx-version-0.2.0.27

* mxapi read and write note position data

* mx-version-0.2.0.28

* mxapi barline work

* mx-version-0.2.0.29

* mxapi fix measure rest writing

* mx-version-0.2.0.30

* mxapi fix another measure rest issue

* mx-version-0.2.0.31

* mx-version-0.2.0.32

* mxapi add failing freezing pieces test viola measure 7

* mxapi freezing tests

* mxapi more freezing tests

* mxapi freezing tests

* Feature/mxapi (#17)

* Smufl flailing

* Fat framework

* Add missing architectures

* Clean up projects

* Remove scheme and add stub post-archive script

* Track down a memory smasher

* Add an additional check

* use sparsepp to avoid smufl crash (#18)

* Use frozen map

* User sparse map for unordered list

* Return ref not copy of string

* smufl map carnage

* version

* mx-version-0.3.1.37

* nothing

* gitignore

* remove sublime workspace

* ignore sublime workspace

* ci and gcc work

* pesky sublime workspace

* sublime workspace ignore

* ci

* ci work

* ci work and gcc

* circleci

* circleci

* circleci

* test stuff

* work on test options (#27)

work on test options #24 #23

* readme and examples #22 #26 (#28)

* work on test options

* work on examples

* work on examples

* build examples on circleci

* run examples on circleci

* use include directory as public api #21 (#29)

* work on test options

* work on examples

* work on examples

* build examples on circleci

* run examples on circleci

* readme

* readme

* readme

* big shuffle

* hide stuff

* readme work for 1.0 #25 #26 #30 (#31)

* work on test options

* work on examples

* work on examples

* build examples on circleci

* run examples on circleci

* readme

* readme

* readme

* big shuffle

* hide stuff

* readme work

* done enough

* xcode

* merge with ezxml library (#38)

* bring in latest ezxml

* use ezxml library cmake works xcode does not

* incorporate ezxml into xcode project - does not build

* xcode mx library compiles

* xcode project stuff

* xcode tests run

* fix circleci warning

* delete circleci comments

* fix xcode project for komp (#39)

* fix-build

* xcode

* further explain tick time position #43 (#47)

* further explain tick time position

* improve tick time position comment

* support microtonal notes with cents #42 (#48)

* document and add cents

* documentation

* documentation

* implementation

* pitch data test

* run only my new test

* cents bug

* working

* good

* restore compile control

* clean up

* Update Sourcecode/private/mxtest/api/NoteDataTest.cpp

* Update Sourcecode/private/mxtest/api/NoteDataTest.cpp

* Update Sourcecode/private/mxtest/api/PitchDataTest.cpp

* Update Sourcecode/private/mx/impl/NoteReader.cpp

* Update Sourcecode/include/mx/api/PitchData.h

* note msvc compiler is tested in the readme #41 (#49)

* readme

* Update README.md

* badges

* Update README.md
  • Loading branch information
webern committed Feb 3, 2020
1 parent 38f38fc commit 65545b4
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
steps:
- checkout

- run:
name: Toolchain Versions
command: |
c++ --version && cmake --version && git --version && cat /etc/os-release
- run:
name: Cmake
command: |
Expand Down
4 changes: 1 addition & 3 deletions .circleci/dockerfile-test-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ sep() {

sep
echo "version info"
g++ --version
cmake --version
cat /etc/os-release
c++ --version && cmake --version && git --version && cat /etc/os-release

sep
cmake \
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ MusicXML Class Library

-----------------------------------------

![CircleCI](https://circleci.com/gh/webern/mx.svg?style=svg&circle-token=2f4d1a33a0825d9634b458a2306ed22482314661)

Badges seem to be [broken](https://github.com/github/markup/issues/224), go to the [CircleCI project](https://circleci.com/gh/webern/mx) for build status.

[![CircleCI](https://circleci.com/gh/webern/mx.svg?style=svg)](https://circleci.com/gh/webern/mx)

## Introduction

Expand All @@ -21,9 +18,10 @@ This project is a C++ library for working with MusicXML files. MusicXML files a
## Compiling

The project is tested with the following:
* Xcode 10.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5)
* Clang (Xcode 10 and higher)
* g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
* cmake version 3.7.2
* MSVC2019

Visual Studio should be very close to working. A good first pull request would be to compile with VS and add the version to the list above.

Expand Down
11 changes: 8 additions & 3 deletions Sourcecode/include/mx/api/NoteData.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ namespace mx
PitchData pitchData; // step, alter, octave, accidental, etc
int userRequestedVoiceNumber;
Stem stem;

// the location of the note, timewise, within the measure
// denominated in ticksPerQuarter as defined by ScoreData

// the time location of the note, within the measure, denominated in ticksPerQuarter which
// is defined in ScoreData. in each measure, the note with tickTimePosition 0 is located at
// the start of the measure. if ScoreData defines ticksPerQuarter as N, then the note
// located at tickTimePosition N will be located one quarter note after the start of the
// measure. MusicXML's <forward> and <backup> tags will be automatically placed into the
// MusicXML as required to facilitate the correct timing of notes based on their
// tickTimePosition values.
int tickTimePosition;
DurationData durationData;

Expand Down
34 changes: 30 additions & 4 deletions Sourcecode/include/mx/api/PitchData.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,55 @@ namespace mx

struct PitchData
{
// default construction is middle c (c4)
PitchData();

// the note name. i.e. c, d, e, f, g, a, b
Step step;

// the alteration (number of semitones of pitch distance) from the step. for example, if step is 'c' and
// alter is 1, then the sounding pitch is c#. if step is 'd' and alter is -2, then the sounding pitch is
// 'c' (i.e. d double flat). alter only affects the sounding pitch of the note. accidentals are applied
// independently. alter is always required to produce the correct sounding pitch, regardless of key
// signature or accidentals.
int alter;

// additional alteration to the sounding pitch (in hundredths of a semitone). the MusicXML alter value is
// a floating point number to facilitate microtonal music. however for mx::api we wanted the simplicity of
// dealing with integrals for the more common case on non-microtonal music. in order to still support
// microtones without resording to a floating-point alter value, we break out microtonal adjustments to a
// separate 'cents' field, which will be addeded to the alter integral:
// <alter> = (double)alter + (cents / 100.0)
double cents;

// in MusicXML, the accidental is completely independent of the sounding pitch and is only present when you
// actually want to show the accidental in the notated music. i.e. accidental is purely visual. for example,
// if you have a measure consisting of repeated c# notes, you would typically notate this with an accidental
// on the first note only. the rest of the notes of the measure would be 'sharped' by virtue of the first
// note's sharp. in MusicXML, the first note should have an accidental of 'sharp' and an alter of '1', and
// the remaining notes of the measure should have an accidental of 'none' and an alter of '1'.
Accidental accidental;
bool isAccidentalParenthetical;
bool isAccidentalCautionary;
bool isAccidentalEditorial;
bool isAccidentalBracketed;

// which octave the note is located in. middle c is in octave 4.
int octave;

// automatically set the Accidental enum value by
// parsing the alter value
// automatically set the Accidental enum value by parsing the alter value (does not consider the value of
// cents). this is a convenience function that simply adds the correct accidental given the current value
// of alter. for example, if alter is 1, then showAccidental will set the accidental field to 'sharp'.
void showAccidental();

// set the accidental value to 'none' and clear out the
// other accidental-related values
// set the accidental value to 'none' and clear out the other accidental-related values
void hideAccidental();
};

MXAPI_EQUALS_BEGIN( PitchData )
MXAPI_EQUALS_MEMBER( step )
MXAPI_EQUALS_MEMBER( alter )
MXAPI_DOUBLES_EQUALS_MEMBER( cents )
MXAPI_EQUALS_MEMBER( accidental )
MXAPI_EQUALS_MEMBER( isAccidentalParenthetical )
MXAPI_EQUALS_MEMBER( isAccidentalCautionary )
Expand Down
1 change: 1 addition & 0 deletions Sourcecode/private/mx/api/PitchData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace mx
PitchData::PitchData()
: step{ Step::c }
, alter{ 0 }
, cents{ 0.0 }
, accidental{Accidental::none}
, isAccidentalParenthetical{ false }
, isAccidentalCautionary{ false }
Expand Down
1 change: 1 addition & 0 deletions Sourcecode/private/mx/impl/NoteFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace mx
auto converter = Converter{};
myOutNoteData.pitchData.step = converter.convert( reader.getStep() );
myOutNoteData.pitchData.alter = reader.getAlter();
myOutNoteData.pitchData.cents = reader.getCents();

myOutNoteData.pitchData.accidental = api::Accidental::none;

Expand Down
14 changes: 13 additions & 1 deletion Sourcecode/private/mx/impl/NoteReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "mx/utility/StringToInt.h"

#include <map>
#include "mx/api/PitchData.h"

namespace mx
{
Expand All @@ -64,6 +65,7 @@ namespace mx
, myDurationValue( 0.0L )
, myStep( core::StepEnum::c )
, myAlter( 0 )
, myCents( 0.0 )
, myOctave( 4 )
, myStaffNumber( 0 )
, myVoiceNumber( 0 )
Expand Down Expand Up @@ -212,7 +214,17 @@ namespace mx
const auto& pitch = *fullNoteTypeChoice.getPitch();
myStep = pitch.getStep()->getValue();
myOctave = pitch.getOctave()->getValue().getValue();
myAlter = static_cast<int>( std::ceil( pitch.getAlter()->getValue().getValue() - 0.5 ) );
const auto xmlAlter = pitch.getAlter()->getValue().getValue();
const auto intAlter = static_cast<int>( xmlAlter );
myAlter = intAlter;
const auto micro = xmlAlter - static_cast<mx::core::DecimalType> ( intAlter );
const auto microDistance = std::abs( micro );
if( microDistance >= 0.000000000001 )
{
const auto theCents = micro * 100.0;
const auto theNarrowCents = static_cast<decltype(mx::api::PitchData::cents)>( theCents );
myCents = theNarrowCents;
}
break;
}

Expand Down
2 changes: 2 additions & 0 deletions Sourcecode/private/mx/impl/NoteReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace mx
inline long double getDurationValue() const { return myDurationValue; }
inline core::StepEnum getStep() const { return myStep; }
inline int getAlter() const { return myAlter; }
inline double getCents() const { return myCents; }
inline int getOctave() const { return myOctave; }
inline int getStaffNumber() const { return myStaffNumber; }
inline int getVoiceNumber() const { return myVoiceNumber; }
Expand Down Expand Up @@ -89,6 +90,7 @@ namespace mx
long double myDurationValue;
core::StepEnum myStep;
int myAlter;
double myCents;
int myOctave;
int myStaffNumber;
int myVoiceNumber;
Expand Down
7 changes: 6 additions & 1 deletion Sourcecode/private/mx/impl/NoteWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,13 @@ namespace mx
pitch->getStep()->setValue( myConverter.convert( myNoteData.pitchData.step ) );
if( myNoteData.pitchData.alter != 0 )
{
core::DecimalType microtones = 0.0;
if( myNoteData.pitchData.cents != 0.0 ) {
microtones = static_cast<core::DecimalType>( myNoteData.pitchData.cents / 100.0 );
}
const auto alter = static_cast<core::DecimalType>( myNoteData.pitchData.alter ) + microtones;
pitch->setHasAlter( true );
pitch->getAlter()->setValue( core::Semitones{ static_cast<core::DecimalType>( myNoteData.pitchData.alter ) } );
pitch->getAlter()->setValue( core::Semitones{ alter } );
}
pitch->getOctave()->setValue( core::OctaveValue{ myNoteData.pitchData.octave } );
}
Expand Down

0 comments on commit 65545b4

Please sign in to comment.