![]() |
uvi-script
Musical event scripting with Lua
|
Functions | |
| function | beat2ms (beat) |
| Convert beat duration to milliseconds based on the current tempo. | |
| function | ms2beat (ms) |
| Convert milliseconds to beat duration based on the current tempo. | |
| function | ms2samples (milli) |
| Convert milliseconds to sample count based on the current sampling rate. | |
| function | samples2ms (samples) |
| Convert sample count to milliseconds based on the current sampling rate. | |
Utility functions for converting between different time and sample units
Mathematical conversion and utility functions for musical calculations.
Provides conversions between different musical units (notes to frequencies, beats to milliseconds, MIDI values to gain, etc.) and musical timing functions that are tempo-aware.
Common Conversions:
Tempo-Synced Functions:
This module provides conversion functions for working with different time representations commonly used in audio and MIDI programming:
These conversions are context-aware and automatically use the current tempo and sampling rate from the engine.
| function beat2ms | ( | beat | ) |
Convert beat duration to milliseconds based on the current tempo.
Converts a musical time value (in beats) to absolute time (in milliseconds) using the current tempo setting. This is useful for scheduling events in musical time that need to be executed at specific clock times.
| beat | The duration in beats (quarter notes). Can be fractional. For example: 1.0 = quarter note, 0.5 = eighth note, 2.0 = half note |
| function ms2beat | ( | ms | ) |
Convert milliseconds to beat duration based on the current tempo.
Converts absolute time (in milliseconds) to musical time (in beats) using the current tempo setting. This is the inverse operation of beat2ms().
| ms | The duration in milliseconds |
| function ms2samples | ( | milli | ) |
Convert milliseconds to sample count based on the current sampling rate.
Converts a time duration in milliseconds to the number of audio samples at the current sampling rate. Useful for buffer size calculations and sample-accurate timing.
| milli | The duration in milliseconds |
| function samples2ms | ( | samples | ) |
Convert sample count to milliseconds based on the current sampling rate.
Converts a number of audio samples to time duration in milliseconds at the current sampling rate. This is the inverse operation of ms2samples().
| samples | The number of samples |