Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support microtonal notes and improve documentation #41 #42 #43 #50

Merged
merged 31 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
58dd9d7
release v0.3.0
webern Nov 20, 2017
ac01ee3
develop backmerge master
webern Nov 20, 2017
7c879b5
frz fix placement of directions in chords
webern Nov 24, 2017
0db2e8f
frz round trip musicxml version
webern Nov 25, 2017
454de95
frz fix tuplet issues
webern Nov 27, 2017
dc40ce4
frz branch progress
webern Mar 18, 2018
181b924
gene noteheads and lyrics
webern Mar 18, 2018
53c61de
fix errant comments in cmake build
webern Apr 22, 2018
c8d62b2
better error message and project update
webern May 29, 2018
df9035a
gitignore
webern Jun 25, 2018
1376ec9
Merge branch 'develop' of https://github.com/Webern/MusicXML-Class-Li…
webern Jun 25, 2018
fe5ebfb
merge mxapi into develop
webern Jun 25, 2018
1174443
probably ok
webern Jun 25, 2018
9c18d8a
sublime
webern Apr 7, 2019
d0e94e4
Merge branch 'master' into develop
webern Apr 7, 2019
8f792e7
Merge branch 'master' into develop
webern Apr 7, 2019
952715e
merge mxapi branch (#20)
Apr 7, 2019
bf248af
Merge branch 'develop' of https://github.com/Webern/MusicXML-Class-Li…
webern Apr 7, 2019
7d0ced7
work on test options (#27)
Apr 8, 2019
4d8123c
readme and examples #22 #26 (#28)
Apr 8, 2019
18660e2
use include directory as public api #21 (#29)
Apr 8, 2019
64f99b6
readme work for 1.0 #25 #26 #30 (#31)
Apr 8, 2019
23bf12a
xcode
webern Apr 8, 2019
9c540ff
Merge branch 'master' into develop
webern Apr 9, 2019
69856d6
merge with ezxml library (#38)
webern Sep 29, 2019
a3db8e9
Merge branch 'master' into develop
Nov 24, 2019
7fb62a7
fix xcode project for komp (#39)
webern Nov 24, 2019
a5884ce
Merge branch 'master' into develop
Nov 24, 2019
b68c5df
further explain tick time position #43 (#47)
webern Feb 2, 2020
73aa012
support microtonal notes with cents #42 (#48)
webern Feb 2, 2020
2187360
note msvc compiler is tested in the readme #41 (#49)
webern Feb 2, 2020
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
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
Loading