Section Symbols
Symbols (notes, rests...) utility functions
- See
- Symbol
Summary
Return type | Function and summary |
---|---|
int, int | CopyOrnaments(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() . | |
int | SMApplyToAllSelectedSymbols(Score score, function processFunc) Apply a function to all selected symbols, individually selected or continous selection. |
int | 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. |
string, int | SMPitchToString(int pitch, int preferredAccidental, int compatible, string preferredNote) Extension and bugfix for builtin PitchToString function. |
int, int | SMStringToPitch(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. | |
int | TheoryStemsDirection(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.
Parameter | Type | Default | Description |
---|---|---|---|
score | Score | score | |
processFunc | function | 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.
Parameter | Type | Default | Description |
---|---|---|---|
score | Score | score | |
staff | Staff | nil | nil menas all staves. |
firstBar | int | 1 | First bar to start applying the function. |
lastBar | int | score.NumberOfBars | Last bar to stop applying the function. |
processFunc | function | 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.
Parameter | Type | Default | Description |
---|---|---|---|
symbol | Symbol | (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
Parameter | Type | Default | Description |
---|---|---|---|
pitch | int | pitch | |
preferredAccidental | int | AUTO | Preferred 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. |
compatible | int | ffalse | If true return value that HA can handle, 11 instead of B-1, a value in bounds. |
preferredNote | string | "" | 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)
Parameter | Type | Default | Description |
---|---|---|---|
name | string | 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.
- 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.
Parameter | Type | Default | Description |
---|---|---|---|
score | Score | score | |
grdm | int |
|
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.
Parameter | Type | Default | Description |
---|---|---|---|
case | string | "chord" or "beam" | |
notes | table | table of Symbol, only notes are considered (Symbol.IsNote == true ) |
- Return
- int: STEM_UP or STEM_DOWN, nil if no symbol args are notes.