// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Practice metronome // Not compiled or tested in-world // Setup: Add a short licensed sound named tick. Set BPM between 30 and 180. Owner-touch starts and stops. // Stop / restore: Touch to stop before removal; Stop sound in this prim can silence any remaining tick. // Notes: Simulator timers and asset loading introduce jitter. This is a practice aid, not a sample-accurate sequencer. Keep the tick shorter than the beat interval. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Not compiled or tested in-world. float BPM = 60.0; integer active; default { touch_start(integer count) { if (llDetectedKey(0) != llGetOwner()) return; active = !active; if (active) { if (llGetInventoryType("tick") != INVENTORY_SOUND) { active = FALSE; llOwnerSay("Add a sound named tick."); return; } if (BPM < 30.0) BPM = 30.0; if (BPM > 180.0) BPM = 180.0; llSetTimerEvent(60.0 / BPM); } else { llSetTimerEvent(0.0); llStopSound(); } } timer() { if (llGetInventoryType("tick") == INVENTORY_SOUND) llPlaySound("tick", 0.2); } }