Section Symbols

Symbols (notes, rests...) utility functions

See
Symbol

Summary

Return typeFunction and summary
int, intCopyOrnaments(Symbol from, Symbol to)
Copy all ornaments from a Symbol to another one.
 PlayNote(Symbol symbol)
Plays a note, shortcut and fix for Staff.PlayNotes().
intSMApplyToAllSelectedSymbols(Score score, function processFunc)
Apply a function to all selected symbols, individually selected or continous selection.
intSMApplyToAllSymbols(Score score, Staff staff, int firstBar, int lastBar, function processFunc)
Apply a function to all symbols in the score, or staff, or in a rang eof bars.
string, intSMPitchToString(int pitch, int preferredAccidental, int compatible, string preferredNote)
Extension and bugfix for builtin PitchToString function.
int, intSMStringToPitch(string name)
Extension and bugfix for builtin StringToPitch function.
 SetGhostRestDisplayMode(Score score, int grdm)
Set the ghost rest display mode for all staves in all views.
intTheoryStemsDirection(string case, table notes)
Get the stem direction a group of beamed notes, or a chord, would have in normal conditions.

Functions

SMApplyToAllSelectedSymbols(Score score, function processFunc)

Apply a function to all selected symbols, individually selected or continous selection.

MSLibrary's ApplyToAllSelectedSymbols(...) function doesn't handle individually selected symbols, and browse from last to first, which is safe for symbol deletion. This customized browse selected notes on all staves from first to last.

ParameterTypeDefaultDescription
scoreScore score
processFuncfunction Function with a singl Symbol argument, and returns true if symbol has been processed.
Return
int: Number of processed symbols
Error
if score is not a Score or processFunc is not a function.
See
SMApplyToAllSymbols

SMApplyToAllSymbols(Score score, Staff staff, int firstBar, int lastBar, function processFunc)

Apply a function to all symbols in the score, or staff, or in a rang eof bars.

ParameterTypeDefaultDescription
scoreScore score
staffStaffnilnil menas all staves.
firstBarint1First bar to start applying the function.
lastBarintscore.NumberOfBarsLast bar to stop applying the function.
processFuncfunction Function with a singl Symbol argument, and returns true if symbol has been processed.
Return
int: Number of processed symbols
Error
if arguments have wrong types.
See
SMApplyToAllSelectedSymbols

PlayNote(Symbol symbol)

Plays a note, shortcut and fix for Staff.PlayNotes().

Play only one note (the symbol parameter), in its context (tempo at its Time position), duration, velocity and pitch. Fix the no-sound bug when pitch==0 on grid drum staves.

ParameterTypeDefaultDescription
symbolSymbol (note) to play

SMPitchToString(int pitch, int preferredAccidental, int compatible, string preferredNote)

Extension and bugfix for builtin PitchToString function.

  • Allow pitches out of 0..127 bounds, but keep in mind that HA can't handle them!
  • PitchToString(11) gives 11, SMPitchToString(11) returns B-1

ParameterTypeDefaultDescription
pitchint pitch
preferredAccidentalintAUTOPreferred accidental in MSDefine. HA can handle A## and Bbb as note names. If a string is provided, then if it contains a "b" or a "#", it's interpreted as FLAT or SHARP constants.
compatibleintffalseIf true return value that HA can handle, 11 instead of B-1, a value in bounds.
preferredNotestring""English note "A" to "G", if no preferred accidental or AUTO, select the enharmonic from the preferred note. If result is "A" and preferred note is "G" then result will be "G##", unless allowDoubleAccidental is false.
Returns
string: Anglo-saxon note name followed by octave, e.g. "Ab5".
int: Accidental for the note, one of MSDefine NATURAL,FLAT,SHARP,DOUBLE_FLAT,DOUBLE_SHARP constants.

SMStringToPitch(string name)

Extension and bugfix for builtin StringToPitch function.

  • Allow pitches out of 0..127 bounds
  • StringToPitch("B-1") gives the strange 71 result, SMStringToPitch("B-1") returns 11
  • Handles double-sharp (## or x) and double-flat (bb)

ParameterTypeDefaultDescription
namestring English not name followed by octave. If octave is missing, considers it's the 4th octave.
Returns
int: May be out of 0..127 range.
int: Preferred accidental, one of AUTO, SHARP, FLAT... constants from MSDefine

CopyOrnaments(Symbol from, Symbol to)

Copy all ornaments from a Symbol to another one.

ParameterTypeDefaultDescription
fromSymbol The source symbol
toSymbol The destination symbol
Returns
int: Number of copied ornaments
int: Number of copy errors

SetGhostRestDisplayMode(Score score, int grdm)

Set the ghost rest display mode for all staves in all views.

ParameterTypeDefaultDescription
scoreScore score
grdmint 
  • 0 = don't display
  • 1 = display with a mark
  • 2 = display whole rest in empty bars
  • 3 = display with real rests

TheoryStemsDirection(string case, table notes)

Get the stem direction a group of beamed notes, or a chord, would have in normal conditions.

Stem direction is determinated by the note that is far than the middle line. In case of equal distance between the far top and far bottom, chord has stems up, beamed notes have stems down.

ParameterTypeDefaultDescription
casestring "chord" or "beam"
notestable table of Symbol, only notes are considered (Symbol.IsNote == true)
Return
int: STEM_UP or STEM_DOWN, nil if no symbol args are notes.