Section Tempo

Tempo utility functions

See
Dynamic

Summary

Return typeFunction and summary
intApplyToAllDynamics(Score score, staves, int firstBar, int lastBar, function filterFunc, function processFunc)
Apply a function to all Dynamics in the score, or staff, or in a range of bars.
intApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly)
Apply a function to all selected Dynamics, individually selected or inside range selection.
CollectionGetDynamicsThatApplyToStaff(Score score, Staff staff)
Get all Dynamic that apply to the specified Staff.
number, int, DynamicGetTempoAtTime(Score score, int time)
Get tempo value and its Dynamic object (if applicable) at specified time of the score

Functions

GetTempoAtTime(Score score, int time)

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

ParameterTypeDefaultDescription
scoreScore score
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

GetDynamicsThatApplyToStaff(Score score, Staff staff)

Get all Dynamic that apply to the specified Staff.

Dynamics are:

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

ParameterTypeDefaultDescription
scoreScore score
staffStaff staff
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 group, or to the whole score.
Error
if score or staff are nil

ApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly)

Apply a function to all selected Dynamics, individually selected or inside range selection.

This browses selected Dynamics on visible (printed) staves from first to last, .

ParameterTypeDefaultDescription
scoreScore score
filterFuncfunction Dynamic are tempo, pedal, ottava or... dynamics. The filter function, if not nil, is here to apply processFunc on the Dynamics you want.
This function accepts on Dynamic argument and returns true to be processed.
You can use DynamicIsTempo, DynamicIsPedal, DynamicIsVelocity or DynamicIsOttava or create your own filter.
nil means no filter, all kind of Dynamics are processed.
processFuncfunction Function with two Dynamic and Staff arguments, which returns true (= 1) if Dynamic has been processed, -1 to stop the process. Other returned values are ignored, process continue to next.
printedStavesOnlybooleanfalseIf true selected Dynamics on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible.
Return
int: Number of processed Dynamics
Error
if arguments are not valid.
Example


 local nb = ApplyToAllSelectedDynamics(FrontScore(), DynamicIsTempo, function(dyn,staff)
    print(dyn.TempoValue); return true
  end, false)
 print(nb .. " tempo found.")

ApplyToAllDynamics(Score score, staves, int firstBar, int lastBar, function filterFunc, function processFunc)

Apply a function to all Dynamics in the score, or staff, or in a range of bars.

ParameterTypeDefaultDescription
scoreScore score
staves nil
  • nil means all staves
  • a Staff object to apply only to that staff
  • a table of Staff to apply to a list of staves
firstBarint1First bar to start applying the function.
lastBarintscore.NumberOfBarsLast bar to stop applying the function.
filterFuncfunction Dynamic are tempo, pedal, ottava or... dynamics. The filter function, if not nil, is here to apply processFunc on the Dynamics you want.
This function accepts on Dynamic argument and returns true to be processed.
You can use DynamicIsTempo, DynamicIsPedal, DynamicIsVelocity or DynamicIsOttava or create your own filter.
nil means no filter, all kind of Dynamics are processed.
processFuncfunction Function with two Dynamic and Staff arguments, which returns true (= 1) if Dynamic has been processed, -1 to stop the process. Other returned values are ignored, process continue to next Dynamic.
Return
int: Number of processed Dynamics
Error
if arguments are not valid.
See
ApplyToAllSelectedDynamics