File SMUtils.mys

Utility functions.

Author
Sylvain Machefert

Sections

SectionSummary
ChordsChord class and other chords utility functions, like extracting chords from the chord line of a staff.
DrumsDrums grids, play and other utility function.
DurationsDurations utility functions
  • Conversions from/to milliseconds, note duration, percentage of note duration, 256th of quarter
DynamicsDynamics utility functions
FXProcessorsFXProcessor handling utility functions.
InstrumentsInstruments utility functions
NotesNotes (Symbol) utility functions
NumbersNumbers utility functions.
PlayPlay utility functions: play the score, play a sound...
PreferencesPreferences functions: workaround for bogus or missing function that read global preferences.
StavesStaves utility function
SyntaxExtend Lua language.
TargetsTarget utility functions.
TempoTempo utility functions

Summary

Return typeFunction and summary
stringCompareMyrScriptVersion(string version)
Is MyrScript =, < or > version x.y.z?
stringCompareVersions(string a, string b)
Compare two version numbers in x.y.z string format.
 CopyFXProcessor(FXProcessor source, FXProcessor dest)
Copy all parameters from a FXProcessor to another one.
 DeleteAllTargets(Score score, bool preserveScore)
Delete all targets from a score.
boolDynamicIsOttava(Dynamic dynamic)
Is dynamic an ottava (8va, 8vb, 15va or 15vb)?
boolDynamicIsPedal(Dynamic dynamic)
Is dynamic an pedal (Ped.
boolDynamicIsTempo(Dynamic dynamic)
Is dynamic a Tempo?
boolDynamicIsVelocity(Dynamic dynamic)
Is dynamic a velocity (power) change?
tableGetChordsFromStaff(Score score, Staff staff, bool held)
Get the chords of a staff from the chord line and return detailed informations.
CollectionGetDynamicsThatApplyToStaff(Score score, Staff staff)
Get all Dynamic that apply to the specified staff.
StavesGroupGetStavesGroup(Score score, Staff staff)
Get the StavesGroup of a Staff, or nil if staff is not grouped.
number, int, DynamicGetTempoAtTime(Score score, int time)
Get tempo value and its Dynamic object (if applicable) at specified time of the score
 IncludeOnce(string file)
Include file only and only if it hasn't been included before.
 PlayFromBar(Score score, int barNumber, bool showKaraoke, bool scrollMusic, bool followMusic, int metronomeBars)
Start playing music from specified bar.
 PlayNote(Symbol symbol)
Plays a note, shortcut and fix for Staff.PlayNotes().
stringRGBSelectColor()
Workaround for Application.RGBSelectColor which returns "000000" (black) instead of choosen color in global preferences.
string, intSMPitchToString(int pitch, int preferredAccidental, int compatible, string preferredNote)
Extension and bugfix for builtin PitchToString function.
intSMStringToPitch(string name)
Extension and bugfix for builtin StringToPitch function.
 SetDrumGridsDivision(Score score, int numberOfDivisions)
Set the Staff.DefaultDrumDivision to all drum grid-staves.
 SetInstrumentFXProcessor(Instrument instr, FXProcessor fxproc)
Set the default FX Processor for an instrument.
boolSortTargets(Score score)
Sort the targets by bar number.
 assertDialog(dialog, string errorMessage)
Assert dialog is a Dialog, else throw errorMessage.
 assertEquals(expr, expected, string Text)
Assertion an expression or function call equals an expected result.
 assertExpression(expr, string errorMessage)
Assert an expression result is true.
 assertFalse(b, string errorMessage)
Assert b is false, else throw errorMessage.
 assertFunction(f, string errorMessage)
Assert f is a function, else throw errorMessage.
 assertNegativeNumber(n, string errorMessage)
Assert n is a negative number, else throw errorMessage.
 assertNil(n, string errorMessage)
Assert n is nil, else throw errorMessage.
 assertNotEmptyString(s, string errorMessage)
Assert s is a not-nil and not empty string, else throw errorMessage.
 assertNotNil(n, string errorMessage)
Assert n is not nil, else throw errorMessage.
 assertNotZero(n, string errorMessage)
Assert n is a number but not 0, else throw errorMessage.
 assertNumber(n, string errorMessage)
Assert n is a not-nil number, else throw errorMessage.
 assertPositiveNumber(n, string errorMessage)
Assert n is a positive number, else throw errorMessage.
 assertScore(s, string errorMessage)
Assert s is a Score, else throw errorMessage.
 assertString(s, string errorMessage)
Assert s is a not-nil string (possibly empty), else throw errorMessage.
 assertTable(t, string errorMessage)
Assert t is a table, else throw errorMessage.
 assertTrue(b, string errorMessage)
Assert b is true, else throw errorMessage.
 assertType(t, string expectedType, string errorMessage)
Assert type(t) is a expectedType, else throw errorMessage.
tablecase(string _type, _params, function _func, bool _break)
Create a case for switch() function.
tabledefault(function _func)
Create a default case for switch() function.
numberduration_256th_of_quarter_to_ms(int nbOf256th, number tempo)
Convert 256ths of quarter to milliseconds, according to tempo.
intduration_256th_of_quarter_to_percent_of_note(int nbOf256th, int noteDuration, number tempo)
Convert 256ths of quarter to a percentage of a note duration, according to tempo.
intduration_ms_to_256th_of_quarter(number milliseconds, int noteDuration, number tempo)
Convert at duration in milliseconds to 256th of quarter, according to tempo
intduration_ms_to_note(number milliseconds, number tempo)
Convert a duration in milliseconds to a note duration according to tempo.
intduration_ms_to_percent_of_note(number milliseconds, int noteDuration, number tempo)
Convert a duration in milliseconds to a percentage of a note duration, according to tempo.
numberduration_note_to_ms(int noteDuration, number tempo)
Convert a note duration to milliseconds, according to tempo.
intduration_percent_of_note_to_256th_of_quarter(int nbOf256th, int noteDuration, number tempo)
Convert a percentage of a note duration to 256ths of quarter, according to tempo.
numberduration_percent_of_note_to_ms(int percent, int noteDuration, number tempo)
Convert a percentage of note duration to milliseconds, according to tempo.
numberround(number num, int numberOfDecimals)
Round a number.
?switch(term, table cases)
switch..case.
 throw(string exception)
Log (console and/or file) and stop the script with error().

Functions

IncludeOnce(string file)

Include file only and only if it hasn't been included before.

For that, you must always use IncludeOnce instead of Include. Include is safe and fast for simple script that create constants and functions, but may load the CPU if included file performs heavy tasks.

ParameterTypeDefaultDescription
filestring Filename to include, file extension is not mandatory.
Usage
IncludeOnce("SMJavaCollections")

throw(string exception)

Log (console and/or file) and stop the script with error().

Inspired from Java's throw new Exception(...) but without 'catch' mechanism in Lua.

ParameterTypeDefaultDescription
exceptionstring Error message
See
err

assertNumber(n, string errorMessage)

Assert n is a not-nil number, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected number, got ..." will be concatenated.
See
assertPositiveNumber
assertNegativeNumber
assertNotZero

assertPositiveNumber(n, string errorMessage)

Assert n is a positive number, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected positive number, got ..." will be concatenated.
See
assertNumber
assertNegativeNumber
assertNotZero

assertNegativeNumber(n, string errorMessage)

Assert n is a negative number, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected negative number, got ..." will be concatenated.
See
assertNumber
assertPositiveNumber
assertNotZero

assertNotZero(n, string errorMessage)

Assert n is a number but not 0, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected not-zero number, got ..." will be concatenated.
See
assertNumber
assertPositiveNumber
assertNegativeNumber

assertString(s, string errorMessage)

Assert s is a not-nil string (possibly empty), else throw errorMessage.

ParameterTypeDefaultDescription
s   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected string, got ..." will be concatenated.
See
assertNotEmptyString

assertNotEmptyString(s, string errorMessage)

Assert s is a not-nil and not empty string, else throw errorMessage.

ParameterTypeDefaultDescription
s   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected not-empty string, got ..." will be concatenated.
See
assertString

assertTrue(b, string errorMessage)

Assert b is true, else throw errorMessage.

ParameterTypeDefaultDescription
b   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected true, got ..." will be concatenated.
See
assertFalse
assertNotNil
assertExpression

assertFalse(b, string errorMessage)

Assert b is false, else throw errorMessage.

Note: if you check a expression, e.g. x < y, Lua returns nil if the comparaison fails, instead of false.

ParameterTypeDefaultDescription
b   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected false, got ..." will be concatenated.
See
assertTrue
assertNil
assertExpression

assertTable(t, string errorMessage)

Assert t is a table, else throw errorMessage.

ParameterTypeDefaultDescription
t   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected table, got ..." will be concatenated.

assertFunction(f, string errorMessage)

Assert f is a function, else throw errorMessage.

ParameterTypeDefaultDescription
f   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected function, got ..." will be concatenated.

assertNil(n, string errorMessage)

Assert n is nil, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected nil, got ..." will be concatenated.
See
assertNotNil
assertFalse
assertExpression

assertNotNil(n, string errorMessage)

Assert n is not nil, else throw errorMessage.

ParameterTypeDefaultDescription
n   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected not nil, got ..." will be concatenated.
See
assertNil
assertTrue
assertExpression

assertExpression(expr, string errorMessage)

Assert an expression result is true.

This is the equivalent of Lua assert function with more logging.

ParameterTypeDefaultDescription
expr  Result of an expression, e.g. x < y
errorMessagestring Nothing is concatenated, the message must be full and self-explainatory.
See
assertTrue
assertNotNil

assertEquals(expr, expected, string Text)

Assertion an expression or function call equals an expected result.

This is useful for unit tests.

ParameterTypeDefaultDescription
expr  Result of an expression
expected  Expected result
Textstring to print on console and throw if expr ~= expected
Error
If expr ~= expected

assertDialog(dialog, string errorMessage)

Assert dialog is a Dialog, else throw errorMessage.

ParameterTypeDefaultDescription
dialog   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected Dialog, got ..." will be concatenated.

assertScore(s, string errorMessage)

Assert s is a Score, else throw errorMessage.

ParameterTypeDefaultDescription
s   
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected Score, got ..." will be concatenated.

assertType(t, string expectedType, string errorMessage)

Assert type(t) is a expectedType, else throw errorMessage.

ParameterTypeDefaultDescription
t   
expectedTypestring  
errorMessagestring Message to throw: by convention, the function where it happen, and the argument's or variable's name.
": expected 'expectedType', got ..." will be concatenated.
See
assertDialog
assertFunction
assertNumber
assertScore
assertString
assertTable
Example
assertType(s, "Staff", "MyFunction, argument #1")
--> if s is not a Staff, this print
--> ERROR MyFunction, argument #1, expected Staff, got ...

CompareMyrScriptVersion(string version)

Is MyrScript =, < or > version x.y.z?

As Application.MyrScriptVersion is a string, comparison may fail in the future, "10.1.1" is greater than "9.9.9" but string comparison will stay it's lower (because "1" < "9").

ParameterTypeDefaultDescription
versionstring Version to compare, in x.y.z form (e.g.: "1.6.9")
Return
string: "<", ">" or "=" if version is lower, greater or equal to MyrScript version.

CompareVersions(string a, string b)

Compare two version numbers in x.y.z string format.

ParameterTypeDefaultDescription
astring  
bstring  
Return
string: "<", ">" or "=" if a is lower, greater or equal to b.
Example
CompareVersions("9.9.7", "9.9.6") --> ">"

PlayFromBar(Score score, int barNumber, bool showKaraoke, bool scrollMusic, bool followMusic, int metronomeBars)

Start playing music from specified bar.

Target.PlayMusic() is bogus; here is a work-around.

ParameterTypeDefaultDescription
scoreScore The score to play
barNumberint The bar to start from, could be Target.Bar
showKaraokebooluser prefsDisplay karaoke if score has lyrics?
scrollMusicbooluser prefsScrolls the score while playing?
followMusicbooluser prefsOpen follow tune dialog?
metronomeBarsintuser prefsNumber of metronome bars to play before the music
Usage
PlayFromBar(FrontScore(), 2)

DeleteAllTargets(Score score, bool preserveScore)

Delete all targets from a score.

ParameterTypeDefaultDescription
scoreScore  
preserveScoreboolfalsePreserve an undo?

SortTargets(Score score)

Sort the targets by bar number.

Targets may be sorted by creation date in your score, if the last inserted is B between A and C, order is A, C, B. Thiis function sorts by deleting and recreating targets as A, B, C.

ParameterTypeDefaultDescription
scoreScore  
Return
bool: false if no sort was needed, true if sort was done.
Usage
SortTargets(FrontScore())

switch(term, table cases)

switch..case.

Keyword switch doesn't exist in Lua? Here it is. Each case can test more things than C-like equals: equals, not equals, comparison (greater, lower), in a table, between two values (range). See SwitchCaseTest() for examples. Note that it creates tables, so switch is not best solution in huge loops where a set of if..elseif..elseif..end can do the job faster.

ParameterTypeDefaultDescription
term  string or number, that can be compared
casestable Table of cases created by case() and default() functions.
Return
a value if cases' "body" functions return a value.
Usage
switch(term, { case(...), case(...), default(...) }).
Example
local result = switch(my_number, {
case("<", 0, function(term) print(term.." is negative") return "negative" end),
case("eq", 2, function(term) print(term.." = two") return "=2" end, false),
case("in", {3,5,7,11,13,17}, function(term) print(term.." is a prime") return "prime" end),
case("range", {20,29}, function(term) print("20 <= "..term.." <= 29") return "between 20 and 29" end),
default( function(term) print(term.." doesn't match any case, this is default") return "The answer is... 42" end)
})

case(string _type, _params, function _func, bool _break)

Create a case for switch() function.

ParameterTypeDefaultDescription
_typestring Accepted values are:
  • "=", "==", "eq" for equals,
  • "~=", "!=", "~eq", "!eq" for not equals,
  • "<", "<=", ">", ">=", "lt", "le", "gt", "ge" for comparison,
  • "in", "!in", "range", "!range"
_params  A number, a string, or a table:
  • For "in" and "!in" table can have 1 to n items.
  • For "range" and "!range" table must have 2 items.
_funcfunction  
_breakbooltruetrue to stop after this case, false to continue and execute function of next case(s) until a case breaks.
Return
table: a case for switch() function
See
switch

default(function _func)

Create a default case for switch() function.

ParameterTypeDefaultDescription
_funcfunction that will receive the tested term as parameter
Return
table: a case for switch() function
See
switch

CopyFXProcessor(FXProcessor source, FXProcessor dest)

Copy all parameters from a FXProcessor to another one.

ParameterTypeDefaultDescription
sourceFXProcessor The FXProcessor to copy
destFXProcessor The destination FXProcessor that will receive source settings.
Error
if source or dest are nil

SetInstrumentFXProcessor(Instrument instr, FXProcessor fxproc)

Set the default FX Processor for an instrument.

The instrument's FXProcessor is not visible on the score. It's the one you edit from the instrument dialog's "FX" button.

ParameterTypeDefaultDescription
instrInstrument The instrument
fxprocFXProcessor The FXProcessor which properties will be copied in the instrument's FX Processor

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

SetDrumGridsDivision(Score score, int numberOfDivisions)

Set the Staff.DefaultDrumDivision to all drum grid-staves.

ParameterTypeDefaultDescription
scoreScore  
numberOfDivisionsint Number of division per beat
Error
if score is nil or numberOfDivisions < 1

round(number num, int numberOfDecimals)

Round a number.

ParameterTypeDefaultDescription
numnumber Number to round()
numberOfDecimalsint0Number of decimals
Return
number: the rounded number, i.e. floor(number + 0.5) for an integer (no decimals)

duration_note_to_ms(int noteDuration, number tempo)

Convert a note duration to milliseconds, according to tempo.

ParameterTypeDefaultDescription
noteDurationint  
temponumber  
Return
number: Rounded to 3 decimals
Error
if noteDuration is nil, if tempo is nil or <= 0

duration_ms_to_note(number milliseconds, number tempo)

Convert a duration in milliseconds to a note duration according to tempo.

ParameterTypeDefaultDescription
millisecondsnumber  
temponumber  
Return
int: A note duration, comparable to DURATION_QUARTER and other constants in MSDefine
Error
if milliseconds is nil, or tempo is nil or <= 0

duration_percent_of_note_to_ms(int percent, int noteDuration, number tempo)

Convert a percentage of note duration to milliseconds, according to tempo.

ParameterTypeDefaultDescription
percentint  
noteDurationint  
temponumber  
Return
number: Rounded to 3 decimals
Error
if percent is nil, if noteDuration is nil, if tempo is nil or <= 0

duration_ms_to_percent_of_note(number milliseconds, int noteDuration, number tempo)

Convert a duration in milliseconds to a percentage of a note duration, according to tempo.

ParameterTypeDefaultDescription
millisecondsnumber  
noteDurationint  
temponumber  
Return
int: Percent of noteDuration
Error
if milliseconds is nil, if noteDuration is nil, if tempo is nil or <= 0

duration_256th_of_quarter_to_ms(int nbOf256th, number tempo)

Convert 256ths of quarter to milliseconds, according to tempo.

ParameterTypeDefaultDescription
nbOf256thint  
temponumber  
Return
number: Rounded to 3 decimals
Error
if nbOf256th is nil, if tempo is nil or <= 0

duration_ms_to_256th_of_quarter(number milliseconds, int noteDuration, number tempo)

Convert at duration in milliseconds to 256th of quarter, according to tempo

ParameterTypeDefaultDescription
millisecondsnumber  
noteDurationint  
temponumber  
Return
int: 256th of quarter
Error
if milliseconds is nil, if noteDuration is nil, if tempo is nil or <= 0

duration_256th_of_quarter_to_percent_of_note(int nbOf256th, int noteDuration, number tempo)

Convert 256ths of quarter to a percentage of a note duration, according to tempo.

ParameterTypeDefaultDescription
nbOf256thint  
noteDurationint  
temponumber  
Return
int:
Error
if nbOf256th is nil, if noteDuration is nil, if tempo is nil or <= 0

duration_percent_of_note_to_256th_of_quarter(int nbOf256th, int noteDuration, number tempo)

Convert a percentage of a note duration to 256ths of quarter, according to tempo.

ParameterTypeDefaultDescription
nbOf256thint  
noteDurationint  
temponumber  
Return
int:
Error
if nbOf256th is nil, if noteDuration is nil, if tempo is nil or <= 0

GetTempoAtTime(Score score, int time)

Get tempo value and its Dynamic object (if applicable) at specified time of the score

ParameterTypeDefaultDescription
scoreScore  
timeint Symbol.Time, Score.TimeBeginSelection
Returns
number: Tempo value (floatting point number)
int: Reference note length, DURATION_QUARTER for general tempo
Dynamic: nil if no tempo was added to the score, i.e. the returned value is general tempo
Error
if score is nil

GetStavesGroup(Score score, Staff staff)

Get the StavesGroup of a Staff, or nil if staff is not grouped.

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
Return
StavesGroup: nil if staff is not grouped
Error
if score is nil or staff is nil

GetDynamicsThatApplyToStaff(Score score, Staff staff)

Get all Dynamic that apply to the specified staff.

Dynamics are:

  • velocity changes (crescendo, descrendo, pppp to fff)
  • Tempo change
  • Pedal on/off
  • Ottava

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
Return
Collection: of Dynamics that apply to staff are on attached to it, or one of merged staves with it, or one of the staves of the contain group, or to the whole score.
Error
if score or staff are nil
See
DYNAMIC_* constants in MSDefine
Dynamic.Type

DynamicIsTempo(Dynamic dynamic)

Is dynamic a Tempo?

ParameterTypeDefaultDescription
dynamicDynamic  
Return
bool: true if dynamic.Type==DYNAMIC_TEMPO

DynamicIsOttava(Dynamic dynamic)

Is dynamic an ottava (8va, 8vb, 15va or 15vb)?

ParameterTypeDefaultDescription
dynamicDynamic  
Return
bool: true if dynamic is 8va, 8vb, 15va or 15vb

DynamicIsPedal(Dynamic dynamic)

Is dynamic an pedal (Ped.

or *)?

ParameterTypeDefaultDescription
dynamicDynamic  
Return
bool: true if dynamic is Ped. or *

DynamicIsVelocity(Dynamic dynamic)

Is dynamic a velocity (power) change?

ParameterTypeDefaultDescription
dynamicDynamic  
Return
bool: true if dynamic is crescendo, decrescendo, ppp to fff... i.e. not a pedal, not a tempo, not a ottava

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  
preferredAccidentalintAUTOPreferred accidental in MSDefine. HA can handle A## and Bbb as note names.
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##".
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.
Return
int: May be out of 0..127 range.

GetChordsFromStaff(Score score, Staff staff, bool held)

Get the chords of a staff from the chord line and return detailed informations.

This is useful to build bass and chords accompaniments, perform analysis, or whatever you want. The returned structure is a table, indexed from 1 to number of chords. Each element is a

table
which contains properties:
  • Chord: a Chord object, able to understand more complex notations than HA. From this object, you can obtain the list of notes, chord octave, bass octave (2 octaves lower), inversion...
  • BarNumber: the bar number where the chord is writed
  • TimeBegin: time (in tick, from the beginning of the score), where the chord starts to play
  • TimeEnd: time (in ticks, from the beginning of the score), where the chord ends, juste before next chord or an empty cell/bar.
  • ArppegioDelay: by default, staff.ChordArpeggioDelay. May change if [Annn] command has been encountered in chord line.

ParameterTypeDefaultDescription
scoreScore  
staffStaff  
heldboolnilHold chord until next is encountered? If nil, use the chord line setup of the staff. HA needs underscore (_) to hold a chord, but this is unsightly for printing, and works randomly.
Return
table:
See
Chord for more details about Chord object.
Example
local chords = GetChordsFromStaff(FrontScore(), FrontScore().FirstStaff)
for i=1,getn(chords) do
print("Chord #" .. i .. ": "..chords[i].Chord:toASCIIName())
print("Bar #" .. chords[i].BarNumber)
print(tdebug(chords[i].Chord:notes()))
end

RGBSelectColor()

Workaround for Application.RGBSelectColor which returns "000000" (black) instead of choosen color in global preferences.

Return
string: