Section Tempo
Tempo utility functions
- See
- Dynamic
Summary
| Return type | Function and summary |
|---|---|
| int | 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. |
| int | ApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly) Apply a function to all selected Dynamics, individually selected or inside range selection. |
| Collection | GetDynamicsThatApplyToStaff(Score score, Staff staff) Get all Dynamic that apply to the specified Staff. |
| number, int, Dynamic | GetTempoAtTime(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
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| time | int | Symbol.Time, Score.TimeBeginSelection |
- Returns
- number: Tempo value (floatting point number)
- int: Reference note length,
DURATION_QUARTERfor general tempo - Dynamic:
nilif 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
- 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, .
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| filterFunc | function | 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. | |
| processFunc | function | 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. | |
| printedStavesOnly | boolean | false | If 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| staves | nil | ||
| firstBar | int | 1 | First bar to start applying the function. |
| lastBar | int | score.NumberOfBars | Last bar to stop applying the function. |
| filterFunc | function | 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. | |
| processFunc | function | 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