an array of clefs and the xml information they map to
A note array (sans octave) in key-signature order
The purpose of this table is to keep consistent enharmonic spelling when transposing instruments in different keys. It is not theoritically complete, e.g. there is no reason to distinguish between #5 used as a leading tone for vi- or as an augmented chord, the spelling is the same. It does not show a preference for notes that don't have an obvious purpose in the key, e.g. it does not try to compute the equivalent to 'e#' in the key of 'c'. The computation of the 'intended key area' is beyond the scope of a music program to interpret.
return a map of enharmonics for choosing or cycling. notes are in vexKey form.
Ported from vex, used to convert pitches to numerical values
convert from SMO to VEX format so we can use the VexFlow tables and methods
example:
{letter,octave,accidental}
object to vexKey string 'f#'
gives the index into circle-of-fifths array for a pitch, considering enharmonics.
Find the harmonic role for the given pitch
break the duration up into an array of durations, to split a long note up between bars when pasting.
return the next note from the cycle in getEnharmonics
Get enharmonic equivalent of given notes for cycle/choose
fix the enharmonic to match the key, if possible
// given a letter pitch (a,b,c etc.), and a key signature, return the actual note
// that you get without accidentals
// SmoMusic.getKeySignatureKey('F','G'); // returns f#
Indicate if a change from letter note 'one' to 'two' needs us to adjust the
octave due to the SmoMusic.letterPitchIndex
(b0 is higher than c0)
filled in from the midi routines borrowed from // https://github.com/grimmdude/MidiWriterJS
pitch from MIDIwrite
SMO pitch
Convenience function to create SmoNote[] from letters, with the correct accidental for the key signature, given duration, etc
the pitch used to calculate the octave of the new note
vex duration
string of PitchLetter
convert smo pitch to easy score (vex) format. Mostly used for debugging and generating Vex test cases
Convert a number to a SMO pitch
number of 1/2 steps from c0
convert a pitch to an integer value, used for transpositions, intervals, etc.
convert a pitch to a format expected by the MIDI writer
pitch to convert
pitch in MIDI string format.
convert pitches to integer pitch representations by calling smoPitchToInt
Smo pitches
Convert array of smo pitches to vex keys, with adjustment for transpose and notehead
Return array of valid note-lengths from an odd number of ticks, so we can come as close as possible to representing the ticks with notes
Consider instrument transpose when setting key - e.g. Eb for Bb instruments is F. Note: return value is not a valid VEX key signature. Use vexKeySignatureTranspose for that.
return the key signature, transposed a number of 1/2 steps in Vex key format
start key
number of 1/2 steps
return Vex canonical note enharmonic - e.g. Bb to A#
Convert to smo pitch, without octave
['f#'] => [{letter:'f',accidental:'#'}]
Turns vex pitch string into smo pitch, e.g.
cn/4 => {'c','n',4}
SmoPitch
Generated using TypeDoc
Helper functions that build on the VX music theory routines, and other utilities I wish were in VF.Music but aren't
Note on pitch and duration format
We use some VEX music theory routines and frequently need to convert formats from SMO format. We also use the same 'ticks' abstraction for durations.
Smo
uses pitch JSON:Vex
usually uses a canonical string:Depending on the operation, the octave might be omitted
Smo
uses a JSON for duration always:Vex
uses a letter duration ('4'
or'q'
for 1/4 note) and'd'
for dot.I try to indicate whether I am using vex or smo notation in the function name. Duration methods start around line 1100