Skip to main content

Loop

The music loop interface

Loop.id = "wind"
Loop.volume = 0.5

Properties​

id​

Loop.id: string

Get/Set the loop by identifier (e.g. "wind")

volume​

Loop.volume: number

Get/Set the loop volume in range [0, 1]

offset​

Loop.offset: number

Get/Set the music offset (s)

elapsed​

Loop.elapsed: number

Get/Set the elapsed loop time (s)

chars_count​

Loop.chars_count: number

Get the total character count of the loop

chars_per_beat​

Loop.chars_per_beat: number

Get the amount of characters in a beat

chars_delta​

Loop.chars_delta: number

Get the time duration of a character

beats_count​

Loop.beats_count: number

Get the total beat count of the loop

beats_per_measure​

Loop.beats_per_measure: number

Get the amount of beats in a measure

beats_per_minute​

Loop.beats_per_minute: number

Get the amount of beats in a minute

beats_elapsed​

Loop.beats_elapsed: number

Get the amount of currently elapsed beats

beats_delta​

Loop.beats_delta: number

Get the time duration of a beat

measures_count​

Loop.measures_count: number

Get the total amount of measures in the loop

measures_elapsed​

Loop.measures_elapsed: number

Get the amount of currently elapsed measures

measures_delta​

Loop.measures_delta: number

Get the time duration of a measure

loops_elapsed​

Loop.loops_elapsed: number

Get the amount of currently elapsed loops

loops_delta​

Loop.loops_delta: number

Get the duration of a loop

Functions​

set​

Loop.set(
id: string,--

loop identifier

options: table--

settings

) → ()

Sets the current loop

Options

Name Type Default Description
volume number 1 audio volume

Start music silent

Loop.set("wind_kick", { volume = 0.0 })

stop​

Loop.stop() → ()

Stops the current loop

skip​

Loop.skip() → ()

Skips the current loop

preload​

Loop.preload(
id: string--

identifier string

) → ()

Loads the music file into cache

wait​

Loop.wait(
measure: number | nil,--

target measure (default 1)

beat: number | nil,--

target beat (default 1)

fraction: number | nil--

beat fraction (default 0)

) → ()

Waits for given target in the loop

Note that (0, 0, 0) is the start of the loop and many DAWs work with MBF values starting with (1, 1, 0).

beats_wait​

Loop.beats_wait(
target: number--

beats elapsed

) → ()

Sleeps until the specified target

measures_wait​

Loop.measures_wait(
target: number--

measures elapsed

) → ()

Sleeps until the specified target

Show raw api
{
    "functions": [
        {
            "name": "set",
            "desc": "Sets the current loop\n\n### Options\n| Name            | Type        | Default | Description                    |\n|-----------------|-------------|---------|--------------------------------|\n| volume          | number      |       1 | audio volume                   |\n\n### Start music silent\n```lua\nLoop.set(\"wind_kick\", { volume = 0.0 })\n```",
            "params": [
                {
                    "name": "id",
                    "desc": "loop identifier",
                    "lua_type": "string"
                },
                {
                    "name": "options",
                    "desc": "settings",
                    "lua_type": "table"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 35,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "stop",
            "desc": "Stops the current loop",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 42,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "skip",
            "desc": "Skips the current loop",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 48,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "preload",
            "desc": "Loads the music file into cache",
            "params": [
                {
                    "name": "id",
                    "desc": "identifier string",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 55,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "wait",
            "desc": "Waits for given target in the loop\n\nNote that (0, 0, 0) is the start of the loop and many DAWs work with MBF\nvalues starting with (1, 1, 0).",
            "params": [
                {
                    "name": "measure",
                    "desc": "target measure (default 1)",
                    "lua_type": "number | nil"
                },
                {
                    "name": "beat",
                    "desc": "target beat (default 1)",
                    "lua_type": "number | nil"
                },
                {
                    "name": "fraction",
                    "desc": "beat fraction (default 0)",
                    "lua_type": "number | nil"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 89,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_wait",
            "desc": "Sleeps until the specified target",
            "params": [
                {
                    "name": "target",
                    "desc": "beats elapsed",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 153,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "measures_wait",
            "desc": "Sleeps until the specified target",
            "params": [
                {
                    "name": "target",
                    "desc": "measures elapsed",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 182,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "id",
            "desc": "Get/Set the loop by identifier (e.g. \"wind\")",
            "lua_type": "string",
            "source": {
                "line": 18,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "volume",
            "desc": "Get/Set the loop volume in range [0, 1]",
            "lua_type": "number",
            "source": {
                "line": 64,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "offset",
            "desc": "Get/Set the music offset (s)",
            "lua_type": "number",
            "source": {
                "line": 71,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "elapsed",
            "desc": "Get/Set the elapsed loop time (s)",
            "lua_type": "number",
            "source": {
                "line": 78,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "chars_count",
            "desc": "Get the total character count of the loop",
            "lua_type": "number",
            "source": {
                "line": 98,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "chars_per_beat",
            "desc": "Get the amount of characters in a beat",
            "lua_type": "number",
            "source": {
                "line": 105,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "chars_delta",
            "desc": "Get the time duration of a character",
            "lua_type": "number",
            "source": {
                "line": 112,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_count",
            "desc": "Get the total beat count of the loop",
            "lua_type": "number",
            "source": {
                "line": 119,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_per_measure",
            "desc": "Get the amount of beats in a measure",
            "lua_type": "number",
            "source": {
                "line": 126,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_per_minute",
            "desc": "Get the amount of beats in a minute",
            "lua_type": "number",
            "source": {
                "line": 133,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_elapsed",
            "desc": "Get the amount of currently elapsed beats",
            "lua_type": "number",
            "source": {
                "line": 140,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "beats_delta",
            "desc": "Get the time duration of a beat",
            "lua_type": "number",
            "source": {
                "line": 147,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "measures_count",
            "desc": "Get the total amount of measures in the loop",
            "lua_type": "number",
            "source": {
                "line": 162,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "measures_elapsed",
            "desc": "Get the amount of currently elapsed measures",
            "lua_type": "number",
            "source": {
                "line": 169,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "measures_delta",
            "desc": "Get the time duration of a measure",
            "lua_type": "number",
            "source": {
                "line": 176,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "loops_elapsed",
            "desc": "Get the amount of currently elapsed loops",
            "lua_type": "number",
            "source": {
                "line": 191,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        },
        {
            "name": "loops_delta",
            "desc": "Get the duration of a loop",
            "lua_type": "number",
            "source": {
                "line": 198,
                "path": "../../res/data/script/lib/system/loop.lua"
            }
        }
    ],
    "types": [],
    "name": "Loop",
    "desc": "The music loop interface\n\n```lua\nLoop.id = \"wind\"\nLoop.volume = 0.5\n```",
    "source": {
        "line": 10,
        "path": "../../res/data/script/lib/system/loop.lua"
    }
}