tempo

From PenguinMod Wiki (Official)
Tempo
Jump to navigation Jump to search

The tempo block is a reporter block in the Music extension that reports the current tempo in bpm (beats per minute). It can be shown as a stage monitor, is global, and originates from Scratch. The default value of the tempo is the same as the default value of the set tempo to () block, which is 60. The tempo shows how fast or slow the instrument blocks in the extension play, so lower values mean that those blocks play slower, while higher values mean that those blocks play faster. The minimum is 20, while the maximum is 500, in both PenguinMod and Scratch.[1][2][3]

Workaround

This block can be worked around by using a variable to store the value of the tempo when the set tempo to () and change tempo by () blocks are used:

define set tempo to (number1)
set [tempo v] to (number1)
set tempo to (tempo::variables)
define change tempo by (number1)
set tempo to ((tempo::variables) + (number1))::custom

However, this does not check if the value goes above the maximum value or below the minimum, so if statements can be added to the set tempo custom block:

define set tempo to (number1)
set [tempo v] to (number1)
if <(tempo::variables) < [20]> then
set [tempo v] to [20]
end
if <(tempo::variables) > [500]> then
set [tempo v] to [500]
end
set tempo to (tempo::variables)

References