DatumHueEnterprise v0.0.24datumhue.com
Contents

handle13 methods, 13 fieldsUI apps only

Music

A playing datumhue.audio.music: every Audio member, plus live edits and the step heard now.

Obtained from
datumhue.audio.music

The examples on this page start from:

lua
local hi = { waveform = "square", frequency = 880, duration = 0.25 }
local lo = { waveform = "square", frequency = 440, duration = 0.25 }
local song = datumhue.audio.music({
    patterns = { { hi, lo, lo, lo }, { lo, lo, hi, hi } },
    sequence = { 1, 2 },
    looping = true,
})

Fields 13

FieldTypeAccessDescription
positionnumber?read/writeSeconds of the sound's own time, as heard: source seconds for a clip, written seconds for a synth, sfx or music (pitch and tempo speed it up). Wraps at each loop pass, follows seek, and before a future start_time reads where the sound will start; nil once the instance is gone. Assigning it on a clip's play jumps there after a 5 ms fade (at once before the sound has started), clamped to the clip, and reads back at once; on a synth, sfx or music it raises.
atVec2?read/writeWhere a sound played with at stands, in the units of its ear. An assignment moves it: its pan and distance gain follow, gliding like volume, so a sound assigned a new place each frame moves smoothly. nil on any other sound, where assigning raises, and once the instance is gone.
playingbooleanread-onlytrue from the call until the sound has ended (as heard), except while paused; false once stopped.
volumenumber?read/writeThe instance's own linear gain, clamped to 0..4; the audible volume is master x bus x instance. An assignment reads back at once and glides over 50 ms (or the device period, if longer) from the level sounding; nil once the instance is gone.
pannumber?read/writeStereo position, clamped to -1 (left) .. 1 (right), constant power with the centre at the sound's own level; a sequence's per-note pans add to it. An assignment reads back at once and glides like volume; nil once the instance is gone. On a sound played with at it reads the pan its position gives, and assigning it raises.
levelnumber?read-onlyThe RMS of what the instance played over the last 1024 frames heard (about 21 ms at 48 kHz), linear, after its own volume and pan; nil once the instance is gone.
peaknumber?read-onlyThe largest absolute sample the instance played over the same span as level; nil once the instance is gone.
pitchnumber?read/writePlayback rate, clamped to 0.25..4: the sound plays as if resampled, so rate and pitch move together (2.0 plays an octave up at double speed), and so do its notes, envelope, muffle, space and duty sweeps; its filter keeps its cutoff in heard Hz. Steps at once with no click; nil once the instance is gone.
dutynumber?read/writeA square synth's pulse width, clamped to 0..1; it steps at once, taking effect at the next cycle. Reads nil on any other voice, where assigning raises.
filterAudioFilter?read/writeThe voice's filter, or nil with none. Assigning a table merges into it (creating it, with its required keys, when there is none); assigning nil removes it with a 20 ms crossfade.
stepinteger?read-onlyThe 1-based step of the slot's first track heard now, to about one device period; nil before the first step and after the end.
slotinteger?read-onlyThe 1-based sequence entry heard now; nil before the first step and after the end.
temponumber?read/writePlayback speed of the written durations, clamped to 0.25..4 (2 plays twice as fast), for every track; pitch is unchanged and envelope, vibrato and arpeggio times keep their seconds. Steps at once.

Methods 13

Music:stop

method
Music:stop()

Stop playback after a 5 ms fade and release the instance at once.

Music:on_end

method
Music:on_end(callback?: fun(audio: Audio))

Set, replace, or clear (pass nil) the callback run once when the sound is heard ending: it played out, was released or was stolen, or its clip failed to load. It does not run after stop(), after its bus's remove() or once the app has ended.

Music:pause

method
Music:pause()

Fade out over 5 ms and hold the instance where it is; its own time stops.

Music:resume

method
Music:resume()

Fade a paused instance back in over 5 ms from where it was held.

Music:release

method
Music:release(seconds?: number)

Start no further notes: the sounding note falls from its current level over its envelope's release, or over seconds of the sound's own time (5 ms with no envelope), then the instance ends after any space tail. A seconds of 0 or less falls over 2 ms. Called again with seconds, the fall restarts from the current level; without, it changes nothing. A paused instance ends at once; a clip fades out, then ends.

Music:volume_to

method
Music:volume_to(volume: number, seconds: number)

Ramp the instance gain linearly to volume (clamped to 0..4) over seconds of played sound, from the value sounding; the sound keeps playing. Assigning volume cancels the ramp, and a seconds of 0 or less is an assignment.

Music:pan_to

method
Music:pan_to(pan: number, seconds: number)

Ramp the stereo position linearly to pan (clamped to -1..1) over seconds of played sound, sample-exact; assigning pan cancels the ramp, and a seconds of 0 or less is an assignment. On a sound played with at it raises: its position pans it.

Music:pitch_to

method
Music:pitch_to(pitch: number, seconds: number)

Ramp the playback rate to pitch (clamped to 0.25..4) in equal ratios, so each octave takes the same time, over seconds of played sound, sample-exact; assigning pitch cancels the ramp, and a seconds of 0 or less applies it at once.

Music:duty_to

method
Music:duty_to(duty: number, seconds: number)

Ramp a square synth's pulse width linearly to duty (clamped to 0..1) over seconds of the sound's own time, so pitch speeds it up; any other voice raises. Assigning duty cancels the ramp, and a seconds of 0 or less applies it at once.

Music:set_pattern

method
Music:set_pattern(index: integer, notes: audio.SfxNote[])

Replace pattern index (1-based; #patterns + 1 appends). Every slot and track playing it switches at the current time: notes starting from now play, the sounding note finishes, and no note starts part-way; nothing restarts. An index outside 1..#patterns + 1 raises.

Example
-- Rewrite pattern 2 while the song plays; nothing restarts.
song:set_pattern(2, { hi, hi, lo, lo })
-- One past the last pattern adds a new one.
song:set_pattern(3, { lo, hi, lo, hi })

notes audio.SfxNote options 16 keys

KeyTypeDefaultDescription
waveform required"sine" | "square" | "triangle" | "sawtooth" | "noise" | Wavetableno defaultOscillator waveform for this note: a named shape or a Wavetable.
frequencynumber440Tone frequency in Hz.
durationnumber0.1Note duration in seconds, at least 0.001: the note's gate.
volumenumber1Linear volume for this note, at most 4 (clamped); 0 is a rest, which lets the previous note's release ring on.
slidenumberthe pitch holdsTarget frequency in Hz to glide toward over the note.
vibratoaudio.Vibratono vibratoPitch vibrato parameters.
arpeggionumber[]no arpeggioSemitone offsets cycled per arpeggio step; an empty list is no arpeggio.
arpeggio_ticksnumber1; giving it without arpeggio raises1/60 s ticks per arpeggio step, fractions allowed.
envelopeaudio.Envelope2 ms edgesThe note's volume envelope.
pannumber0Stereo position, -1 (left) .. 1 (right), added to the play's pan and clamped.
dutynumber0.5; giving it for any waveform but square raisesPulse width 0..1, clamped.
duty_slidenumberthe duty holds; giving it for any waveform but square raisesTarget pulse width of a linear sweep across the note.
noise_mode"white" | "long" | "periodic"white noise; giving it for any waveform but noise raisesThe noise generator.
syncnumberno syncHard sync: the cycle runs at this ratio of frequency and restarts at each cycle of frequency.
sync_slidenumberthe sync ratio holds; giving it without sync raisesTarget sync ratio of a linear sweep across the note.
ringnumberno ring modulationRing modulation by a ±1 square at this ratio of frequency.

Music:set_sequence

method
Music:set_sequence(sequence: (integer | integer[])[])

Play sequence after the current slot: the slot playing finishes, then entry slot + 1 of the new order plays; past its end the music wraps to entry 1 when looping and ends otherwise. Validated as MusicOptions.sequence is.

Example
-- A new order: pattern 1, then patterns 1 and 2 together as tracks.
-- The entry playing finishes, then the new order goes on from the
-- entry after it.
song:set_sequence({ 1, { 1, 2 } })

Music:seek

method
Music:seek(slot: integer, step?: integer)

After a 5 ms fade, jump to step (1-based) of slot (1-based) in the newest order; notes already under way there sound from where they would be. step and slot read back at once, and on_step fires once for the target. A position outside the sequence raises.

Example
-- Jump to step 3 of the second entry; both read back at once.
song:seek(2, 3)
print(song.slot, song.step) --> 2 3

Music:on_step

method
Music:on_step(callback?: fun(music: Music, slot: integer, step: integer))

Set, replace, or clear (pass nil) the callback fired as each step is heard, with the music and the 1-based slot and step. Fires that wait fold into one carrying the latest step, as timers do.

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page