Développement précocePré-1.0 : la syntaxe peut évoluer.Historique des versionsGitHub
DAW et Synthétiseur 8-Bit

Rune Studio : DAW Chiptune 8-Bit

Composez un morceau 8 bits dans le navigateur, modifiez les notes et exportez votre musique en code .rune.

Voir le code source

Licence de l’outil

rune_studio.rune
#!RUNE

import "parts"

@App
name = RuneStudio
version = 1.0
type = REST
port = 3001

@Frontend
type = rune-web
path = %ROOT%
page = studio

@Page/studio
title = Rune Studio — 8-Bit Chiptune DAW
style = studio
logic = studio
view:
    main .studio-cabinet:
        StudioHeader
        SongSelector
        TransportBar
        div .studio-workspace:
            StudioTrackList
            NoteEditorPanel
        LowerContentTabs
parts/components/editor_panel.rune
@Component/StudioTrackList
view:
    aside .studio-tracks aria-label="Tracks":
        h2 .tracks-heading "Tracks"
        div .voice-tabs:
            button .voice-tab {.active when active_voice == 'lead'} aria-pressed="{active_voice == 'lead'}" click="selectVoice('lead')":
                span .voice-name "Lead"
                span .voice-sound "{lead_instrument}"
            button .voice-tab {.active when active_voice == 'bass'} aria-pressed="{active_voice == 'bass'}" click="selectVoice('bass')":
                span .voice-name "Bass"
                span .voice-sound "{bass_instrument}"
            button .voice-tab {.active when active_voice == 'chords'} aria-pressed="{active_voice == 'chords'}" click="selectVoice('chords')":
                span .voice-name "Chords"
                span .voice-sound "{chords_instrument}"
            button .voice-tab {.active when active_voice == 'drums'} aria-pressed="{active_voice == 'drums'}" click="selectVoice('drums')":
                span .voice-name "Drums"
                span .voice-sound "Percussion"

@Component/NoteEditorPanel
view:
    section .note-editor-panel:
        if editor_mode == 'matrix':
            div .editor-header:
                if active_voice != 'drums':
                    div .instrument-picker:
                        span .editor-label "SOUND:"
                        button .pill-instrument {.active when active_instrument == 'square'} click="setVoiceInstrument('square')":
                            "Square"
                        button .pill-instrument {.active when active_instrument == 'sawtooth'} click="setVoiceInstrument('sawtooth')":
                            "Saw"
                        button .pill-instrument {.active when active_instrument == 'triangle'} click="setVoiceInstrument('triangle')":
                            "Triangle"
                        button .pill-instrument {.active when active_instrument == 'sine'} click="setVoiceInstrument('sine')":
                            "Sine"
                        button .pill-instrument {.active when active_instrument == 'pluck'} click="setVoiceInstrument('pluck')":
                            "Pluck"

                div .duration-picker:
                    span .editor-label "LENGTH:"
                    button .pill-duration {.active when active_duration == ':16'} click="selectDuration(':16')":
                        "1/16"
                    button .pill-duration {.active when active_duration == ':8'} click="selectDuration(':8')":
                        "1/8"
                    button .pill-duration {.active when active_duration == ':4'} click="selectDuration(':4')":
                        "1/4"
                    button .pill-duration {.active when active_duration == ':2'} click="selectDuration(':2')":
                        "1/2"

                div .editor-tools:
                    div .current-note-badge:
                        span .badge-lbl "NOTE:"
                        span .badge-val "{selected_note}"
                        span .badge-sub "{active_duration}"

        # Master timeline
        div .timeline-ruler:
            div .ruler-header-row:
                span .ruler-header "Timeline · {time_signature} · {bars} bars"
                span .ruler-hint "Space to play or pause · Drag the playhead to seek"
                button .bar-tab {.active when selected_bar == 0} click="selectBar(0)" "All bars"
            div .ruler-track:
                div .ruler-scrub {.can-seek when !is_playing} data-studio-seek="progress" role="slider" tabindex="0" aria-label="Playback position in beats" aria-valuemin="0":
                div .ruler-playhead #ruler-playhead data-sync-playhead="progress":
                div .ruler-bars:
                    if bars >= 1:
                        button .ruler-bar-item .bar-tab data-bar-num="1" data-sync-bar="1" aria-pressed="{selected_bar == 1}" {.active-bar when selected_bar == 1} {.active when selected_bar == 1} {.playing-bar when playback_bar == 1} click="selectBar(1)":
                            span .ruler-bar-num "BAR 1"
                    if bars >= 2:
                        button .ruler-bar-item .bar-tab data-bar-num="2" data-sync-bar="2" aria-pressed="{selected_bar == 2}" {.active-bar when selected_bar == 2} {.active when selected_bar == 2} {.playing-bar when playback_bar == 2} click="selectBar(2)":
                            span .ruler-bar-num "BAR 2"
                    if bars >= 3:
                        button .ruler-bar-item .bar-tab data-bar-num="3" data-sync-bar="3" aria-pressed="{selected_bar == 3}" {.active-bar when selected_bar == 3} {.active when selected_bar == 3} {.playing-bar when playback_bar == 3} click="selectBar(3)":
                            span .ruler-bar-num "BAR 3"
                    if bars >= 4:
                        button .ruler-bar-item .bar-tab data-bar-num="4" data-sync-bar="4" aria-pressed="{selected_bar == 4}" {.active-bar when selected_bar == 4} {.active when selected_bar == 4} {.playing-bar when playback_bar == 4} click="selectBar(4)":
                            span .ruler-bar-num "BAR 4"
                    if bars >= 5:
                        button .ruler-bar-item .bar-tab data-bar-num="5" data-sync-bar="5" aria-pressed="{selected_bar == 5}" {.active-bar when selected_bar == 5} {.active when selected_bar == 5} {.playing-bar when playback_bar == 5} click="selectBar(5)":
                            span .ruler-bar-num "BAR 5"
                    if bars >= 6:
                        button .ruler-bar-item .bar-tab data-bar-num="6" data-sync-bar="6" aria-pressed="{selected_bar == 6}" {.active-bar when selected_bar == 6} {.active when selected_bar == 6} {.playing-bar when playback_bar == 6} click="selectBar(6)":
                            span .ruler-bar-num "BAR 6"
                    if bars >= 7:
                        button .ruler-bar-item .bar-tab data-bar-num="7" data-sync-bar="7" aria-pressed="{selected_bar == 7}" {.active-bar when selected_bar == 7} {.active when selected_bar == 7} {.playing-bar when playback_bar == 7} click="selectBar(7)":
                            span .ruler-bar-num "BAR 7"
                    if bars >= 8:
                        button .ruler-bar-item .bar-tab data-bar-num="8" data-sync-bar="8" aria-pressed="{selected_bar == 8}" {.active-bar when selected_bar == 8} {.active when selected_bar == 8} {.playing-bar when playback_bar == 8} click="selectBar(8)":
                            span .ruler-bar-num "BAR 8"

        if editor_mode == 'matrix':
            div .bar-actions:
                button .btn-bar-action .btn-add-bar click="addNewBar" "Add bar"
                button .btn-bar-action click="duplicateCurrentBar" "Duplicate"
                button .btn-bar-action .btn-tool-danger click="deleteCurrentBar" "Delete bar"
                button .btn-bar-action .btn-tool-danger click="clearActiveTrack" "Clear track"

        # 2D Piano Roll Matrix Grid View (Cubase MIDI Editor style)
        if editor_mode == 'matrix':
            div .piano-matrix-rack:
                div .matrix-header:
                    h2 .matrix-title "Piano roll · {active_voice}"
                    div .matrix-note-tools aria-label="Note selection and clipboard":
                        button .step-stretch-btn {.active when studio_note_tool == 'select'} type=button data-studio-note-tool="select" aria-pressed="{studio_note_tool == 'select'}" "Select"
                        button .step-stretch-btn type=button data-studio-note-tool="copy" disabled="{studio_selection_count == 0 and selected_step_id < 0}" aria-keyshortcuts="Control+C Meta+C" "Copy"
                        button .step-stretch-btn {.active when studio_note_tool == 'paste'} type=button data-studio-note-tool="paste" disabled="{studio_clipboard_count == 0}" aria-pressed="{studio_note_tool == 'paste'}" aria-keyshortcuts="Control+V Meta+V" "Paste"
                        if studio_selection_count > 0:
                            span .matrix-sub "{studio_selection_count} selected"
                    if studio_note_tool == 'edit':
                        span .matrix-sub "Tap to add · Drag to move · Drag the edge to resize · Right-click or × to remove"
                    if studio_note_tool == 'select':
                        span .matrix-sub "Tap notes or drag a box to select"
                    if studio_note_tool == 'paste':
                        span .matrix-sub "Tap the grid where the copied notes should start"
                    for step in active_steps:
                        if !step.is_bar and !step.is_rest and selected_step_id == step.id and studio_note_tool == 'edit':
                            div .matrix-length-controls:
                                if step.can_shorten:
                                    button .step-stretch-btn click="stretchStep(step.id, -1)":
                                        "Shorten"
                                if step.can_stretch:
                                    button .step-stretch-btn click="stretchStep(step.id, 1)":
                                        "Lengthen"
                div .matrix-container .matrix-timeline-scroll data-sync-scroll="beat" data-sync-view-bar="{selected_bar}" data-studio-scroll="matrix-{selected_bar}" data-studio-voice="{active_voice}":
                    div .matrix-keys-column:
                        if active_voice == 'drums':
                            button .matrix-key .mkey-drum {.selected-key when selected_note == 'hihat'} click="auditionNote('hihat')":
                                "⚡ HI-HAT"
                            button .matrix-key .mkey-drum {.selected-key when selected_note == 'snare'} click="auditionNote('snare')":
                                "🥁 SNARE"
                            button .matrix-key .mkey-drum {.selected-key when selected_note == 'kick'} click="auditionNote('kick')":
                                "💥 KICK"
                        if active_voice != 'drums':
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'C5'} click="auditionNote('C5')":
                                "C5"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'B4'} click="auditionNote('B4')":
                                "B4"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'A#4'} click="auditionNote('A#4')":
                                "A#4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'A4'} click="auditionNote('A4')":
                                "A4"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'G#4'} click="auditionNote('G#4')":
                                "G#4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'G4'} click="auditionNote('G4')":
                                "G4"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'F#4'} click="auditionNote('F#4')":
                                "F#4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'F4'} click="auditionNote('F4')":
                                "F4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'E4'} click="auditionNote('E4')":
                                "E4"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'D#4'} click="auditionNote('D#4')":
                                "D#4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'D4'} click="auditionNote('D4')":
                                "D4"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'C#4'} click="auditionNote('C#4')":
                                "C#4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'C4'} click="auditionNote('C4')":
                                "C4"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'B3'} click="auditionNote('B3')":
                                "B3"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'A#3'} click="auditionNote('A#3')":
                                "A#3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'A3'} click="auditionNote('A3')":
                                "A3"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'G#3'} click="auditionNote('G#3')":
                                "G#3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'G3'} click="auditionNote('G3')":
                                "G3"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'F#3'} click="auditionNote('F#3')":
                                "F#3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'F3'} click="auditionNote('F3')":
                                "F3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'E3'} click="auditionNote('E3')":
                                "E3"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'D#3'} click="auditionNote('D#3')":
                                "D#3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'D3'} click="auditionNote('D3')":
                                "D3"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'C#3'} click="auditionNote('C#3')":
                                "C#3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'C3'} click="auditionNote('C3')":
                                "C3"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'B2'} click="auditionNote('B2')":
                                "B2"
                            button .matrix-key .mkey-black {.selected-key when selected_note == 'A#2'} click="auditionNote('A#2')":
                                "A#2"
                            button .matrix-key .mkey-white {.selected-key when selected_note == 'A2'} click="auditionNote('A2')":
                                "A2"

                            button .matrix-key .mkey-black {.selected-key when selected_note == 'G#2'} click="auditionNote('G#2')":
                                "G#2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'G2'} click="auditionNote('G2')":
                                "G2"

                            button .matrix-key .mkey-black {.selected-key when selected_note == 'F#2'} click="auditionNote('F#2')":
                                "F#2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'F2'} click="auditionNote('F2')":
                                "F2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'E2'} click="auditionNote('E2')":
                                "E2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'D2'} click="auditionNote('D2')":
                                "D2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'C2'} click="auditionNote('C2')":
                                "C2"

                            button .matrix-key .mkey-white {.selected-key when selected_note == 'A1'} click="auditionNote('A1')":
                                "A1"

                    div .matrix-note-timeline data-sync-view-bar="{selected_bar}":
                        div .seq-playhead #seq-playhead data-sync-playhead="beat":
                            if !is_playing:
                                span .seq-seek-grip data-studio-seek="beat" title="Drag to set playback position":
                        div .matrix-grid-surface {.surface-drums when active_voice == 'drums'} {.selection-tool when studio_note_tool == 'select'} {.paste-tool when studio_note_tool == 'paste'} style="width: {studio_timeline_width}px;" click="placeMatrixNote(event.offsetX, event.offsetY)":
                            for step in active_steps:
                                if selected_bar == 0 or step.bar_num == selected_bar:
                                    if step.is_bar and selected_bar == 0 and step.lane == 0:
                                        div .matrix-bar-divider style="left: {step.matrix_left}px;" click="selectBar(step.bar_num)":
                                            span .matrix-bar-divider-label "{step.len_label}"
                                    if !step.is_bar and !step.is_rest:
                                        div .matrix-note-block .chip-{step.pitch_class} {.compact-note when step.beats == 0.25} {.selected-step when selected_step_id == step.id or studio_selected_notes[step.id]} {.playing-step-now when playback_step_id == step.id} data-sync-step="{step.id}" data-step-idx="{step.id}" data-studio-note="matrix" title="{step.note} · {step.len_label}" style="top: {step.matrix_top}px; left: {step.matrix_left}px; width: {step.matrix_width}px;" click="selectStep(step.id)" on_contextmenu="deleteStep(step.id)":
                                            div .matrix-note-body:
                                                span .matrix-note-pitch "{step.note}"
                                                span .matrix-note-len "{step.len_label}"
                                            span .note-resize-grip data-studio-resize="true" aria-hidden="true" title="Drag to resize":
                                            button .matrix-delete-btn click="deleteStep(step.id)" title="Delete":
                                                "×"

        # Step Sequencer Strip View
        if editor_mode == 'strip':
            div .step-sequencer-rack:
                div .step-rack-header:
                    div .step-rack-title:
                        h2 .step-title-text "Strip · {active_voice}"
                    div .step-rack-hint:
                        "Edit notes in the piano roll"

                div .step-strip-scroll data-sync-scroll="beat" data-sync-view-bar="{selected_bar}" data-sync-pixels-per-beat="192" data-studio-scroll="strip-{selected_bar}":
                    div .seq-playhead #seq-playhead data-sync-playhead="beat":
                        if !is_playing:
                            span .seq-seek-grip data-studio-seek="beat" title="Drag to set playback position":
                    div .step-strip style="width: {studio_strip_width}px; height: {studio_strip_height}px;":
                        for step in active_steps:
                            if selected_bar == 0 or step.bar_num == selected_bar:
                                if step.is_bar and selected_bar == 0 and step.lane == 0:
                                    div .step-bar-divider style="left: {step.strip_left}px;" aria-hidden="true":
                                if !step.is_bar and !step.is_rest:
                                    div .step-chip .chip-{step.pitch_class} {.playing-step-now when playback_step_id == step.id} data-sync-step="{step.id}" style="left: {step.strip_left}px; width: {step.strip_width}px; top: {step.strip_top}px;":
                                        div .step-num "B{step.bar_num}.{step.step_num}"
                                        div .step-pitch "{step.note}"
                                        div .step-len "{step.len_label}"

        # Interactive Audition Keyboard & Drum Pads
        if editor_mode == 'matrix':
            if active_voice != 'drums':
                div .piano-roll-container:
                    div .piano-roll:
                        button .piano-key .key-white {.selected-key when selected_note == 'C3'} click="auditionNote('C3')":
                            "C3"
                        button .piano-key .key-white {.selected-key when selected_note == 'D3'} click="auditionNote('D3')":
                            "D3"
                        button .piano-key .key-white {.selected-key when selected_note == 'E3'} click="auditionNote('E3')":
                            "E3"
                        button .piano-key .key-white {.selected-key when selected_note == 'F3'} click="auditionNote('F3')":
                            "F3"
                        button .piano-key .key-white {.selected-key when selected_note == 'G3'} click="auditionNote('G3')":
                            "G3"
                        button .piano-key .key-white {.selected-key when selected_note == 'A3'} click="auditionNote('A3')":
                            "A3"
                        button .piano-key .key-white {.selected-key when selected_note == 'B3'} click="auditionNote('B3')":
                            "B3"
                        button .piano-key .key-white {.selected-key when selected_note == 'C4'} click="auditionNote('C4')":
                            "C4"
                        button .piano-key .key-black {.selected-key when selected_note == 'C#4'} click="auditionNote('C#4')":
                            "C#4"
                        button .piano-key .key-white {.selected-key when selected_note == 'D4'} click="auditionNote('D4')":
                            "D4"
                        button .piano-key .key-black {.selected-key when selected_note == 'D#4'} click="auditionNote('D#4')":
                            "D#4"
                        button .piano-key .key-white {.selected-key when selected_note == 'E4'} click="auditionNote('E4')":
                            "E4"
                        button .piano-key .key-white {.selected-key when selected_note == 'F4'} click="auditionNote('F4')":
                            "F4"
                        button .piano-key .key-black {.selected-key when selected_note == 'F#4'} click="auditionNote('F#4')":
                            "F#4"
                        button .piano-key .key-white {.selected-key when selected_note == 'G4'} click="auditionNote('G4')":
                            "G4"
                        button .piano-key .key-black {.selected-key when selected_note == 'G#4'} click="auditionNote('G#4')":
                            "G#4"
                        button .piano-key .key-white {.selected-key when selected_note == 'A4'} click="auditionNote('A4')":
                            "A4"
                        button .piano-key .key-black {.selected-key when selected_note == 'A#4'} click="auditionNote('A#4')":
                            "A#4"
                        button .piano-key .key-white {.selected-key when selected_note == 'B4'} click="auditionNote('B4')":
                            "B4"
                        button .piano-key .key-white {.selected-key when selected_note == 'C5'} click="auditionNote('C5')":
                            "C5"
                        button .piano-key .key-white {.selected-key when selected_note == 'D5'} click="auditionNote('D5')":
                            "D5"
                        button .piano-key .key-white {.selected-key when selected_note == 'E5'} click="auditionNote('E5')":
                            "E5"
                        button .piano-key .key-white {.selected-key when selected_note == 'G5'} click="auditionNote('G5')":
                            "G5"
                        button .piano-key .key-white {.selected-key when selected_note == 'A5'} click="auditionNote('A5')":
                            "A5"

            if active_voice == 'drums':
                div .drum-machine-container:
                    div .drum-pads:
                        button .drum-pad {.selected-key when selected_note == 'kick'} click="auditionNote('kick')":
                            span .drum-icon "💥"
                            span .drum-name "KICK"
                        button .drum-pad {.selected-key when selected_note == 'snare'} click="auditionNote('snare')":
                            span .drum-icon "🥁"
                            span .drum-name "SNARE"
                        button .drum-pad {.selected-key when selected_note == 'hihat'} click="auditionNote('hihat')":
                            span .drum-icon "⚡"
                            span .drum-name "HI-HAT"

parts/components/header.rune
@Component/StudioHeader
view:
    header .studio-header:
        h1 .studio-title "RUNE STUDIO"
        p .status-txt role=status "{status_message}"
        button .btn-fullscreen click="toggleFullscreen" aria-pressed="{is_fullscreen}":
            "{is_fullscreen ? 'Exit fullscreen' : 'Fullscreen'}"
parts/components/lower_tabs.rune
@Component/SfxAuditionPad
view:
    div .sfx-section:
        h4 .sfx-heading "⚡ RETRO ARCADE SOUND FX AUDITION PAD"
        div .sfx-pads:
            button .pad-btn click="playSfx('laser')":
                span "💥"
                span "Laser"
            button .pad-btn click="playSfx('hit')":
                span "🥊"
                span "Hit"
            button .pad-btn click="playSfx('explosion')":
                span "💣"
                span "Explosion"
            button .pad-btn click="playSfx('coin')":
                span "🪙"
                span "Coin"
            button .pad-btn click="playSfx('step')":
                span "👣"
                span "Footstep"
            button .pad-btn click="playSfx('gameover')":
                span "💀"
                span "Game Over"
            button .pad-btn click="playSfx('victory')":
                span "🌟"
                span "Victory"

@Component/RuneCodeExport
view:
    div .export-section:
        div .export-header:
            h4 .sfx-heading "📜 GENERATED RUNE DECLARATION"
            div:
                button .btn-storage click="copyCode":
                    "Copy Code"
        pre .code-preview:
            "# {song_title}\n\n@Music/{selected_song}\ntype = 8bit\ntempo = {tempo}\ntime_signature = {time_signature}\nbars = {bars}\nloop = true\nvolume = 0.2\ninstruments = \{{export_instruments_body}\}\n\nlead:\n    {lead_export}\n\nbass:\n    {bass_export}\n\nchords:\n    {chords_export}\n\ndrums:\n    {drums_export}\n{layer_exports}"

@Component/LowerContentTabs
view:
    div .lower-tabs-cabinet:
        div .lower-tab-bar:
            button .lower-tab-btn {.active when active_lower_tab == 'tracks'} click="setLowerTab('tracks')":
                "Track scores"
            button .lower-tab-btn {.active when active_lower_tab == 'sfx'} click="setLowerTab('sfx')":
                "Sound effects"
            button .lower-tab-btn {.active when active_lower_tab == 'export'} click="setLowerTab('export')":
                "Rune code"

        div .lower-tab-content:
            if active_lower_tab == 'tracks':
                div .tracks-container:
                    TrackRack voice_id=lead voice_name="VOICE 1: LEAD" icon="🎹" badge_class="badge-square" badge_text="{lead_instrument}" score_text="{lead_track}" is_active="{active_voice == 'lead'}" is_muted="{lead_muted}"
                    TrackRack voice_id=bass voice_name="VOICE 2: BASS" icon="🎸" badge_class="badge-triangle" badge_text="{bass_instrument}" score_text="{bass_track}" is_active="{active_voice == 'bass'}" is_muted="{bass_muted}"
                    TrackRack voice_id=chords voice_name="VOICE 3: POLYPHONIC CHORDS" icon="✨" badge_class="badge-saw" badge_text="{chords_instrument}" score_text="{chords_track}" is_active="{active_voice == 'chords'}" is_muted="{chords_muted}"
                    TrackRack voice_id=drums voice_name="VOICE 4: PERCUSSION / DRUMS" icon="🥁" badge_class="badge-noise" badge_text="Drums" score_text="{drums_track}" is_active="{active_voice == 'drums'}" is_muted="{drums_muted}"

            if active_lower_tab == 'sfx':
                SfxAuditionPad

            if active_lower_tab == 'export':
                RuneCodeExport

parts/components/song_selector.rune
@Component/SongSelector
view:
    section .song-selector aria-label="Song":
        label .song-title-label for=studio-song-title:
            span .ctrl-label "Song title"
            input #studio-song-title .song-title-input type=text aria-label="Song title" maxlength="80" value="{song_title}" data-studio-song-title="{selected_song}" on_input="renameSong(this.value)"
        div .song-actions:
            button .btn-storage .btn-new-song click="newSong" "New Song"
            select .song-open aria-label="Open song" change="openSong(this.value)":
                option value="" selected=true disabled=true "Open…"
                option value=reload_saved "Reload current saved song"
                if saved_songs.length > 0:
                    optgroup label="Saved songs":
                        for song in saved_songs:
                            option value="{song.key}" "{song.title}"
                optgroup label="Presets":
                    option value=vectraiders "VectRaiders"
                    option value=vectworms "VectWorms"
                    option value=cyber_run "Cyber Run"
                    option value=moonlight "Moonlight Dungeon"
                    option value=victory "Victory Fanfare"
            button .btn-storage click="saveToStorage" "Save"
            button .btn-storage click="exportRune" "Export .rune"
parts/components/track_rack.rune
@Component/TrackRack
props: [voice_id, voice_name, icon, badge_class, badge_text, score_text, is_active?, is_muted?]
view:
    div .track-rack {.active-rack when is_active} click="selectVoice('{voice_id}')":
        div .track-header:
            div .track-meta:
                span .track-icon "{icon}"
                h3 .track-name "{voice_name}"
                span .badge-wave "{badge_text}"
                if is_active:
                    span .pill-active-track "● ACTIVE RECORDING"
            div .track-actions:
                button .btn-track-mute {.btn-muted when is_muted} click="toggleTrackMute('{voice_id}')":
                    if is_muted:
                        "MUTED"
                    if !is_muted:
                        "MUTE"
                button .btn-edit-track {.btn-editing when is_active} click="selectVoice('{voice_id}')":
                    if is_active:
                        "CURRENT VOICE"
                    if !is_active:
                        "✏️ EDIT VOICE"
        div .track-score-box {.active-score-box when is_active}:
            "{score_text}"

parts/components/transport_bar.rune
@Component/TransportBar
props: [is_playing?, is_paused?, tempo?, volume?, time_signature?, editor_mode?]
view:
    div .transport-bar:
        div .transport-buttons {.is-playing when is_playing}:
            button .btn-transport-seek type=button data-studio-seek-bar="start" disabled="{is_playing}" aria-label="Back to start" title="Back to start":
                "«"
            button .btn-transport-seek type=button data-studio-seek-bar="-1" disabled="{is_playing}" aria-label="Previous bar" title="Previous bar":
                "‹"
            if !is_playing:
                button .btn-transport .btn-play click="playTrack" aria-keyshortcuts="Space":
                    "▶ Play"
            if is_playing:
                button .btn-transport .btn-pause click="pauseTrack" aria-keyshortcuts="Space":
                    "⏸ Pause"
            button .btn-transport-seek type=button data-studio-seek-bar="1" disabled="{is_playing}" aria-label="Next bar" title="Next bar":
                "›"

        div .tempo-controls:
            span .ctrl-label "Tempo"
            button .btn-tempo click="changeTempo(-4)":
                "-4"
            span .bpm-badge "{tempo} BPM"
            button .btn-tempo click="changeTempo(4)":
                "+4"

        if editor_mode == 'matrix':
            div .time-sig-controls:
                span .ctrl-label "Meter"
                button .btn-timesig {.active when time_signature == '4/4'} click="setTimeSignature('4/4')":
                    "4/4"
                button .btn-timesig {.active when time_signature == '3/4'} click="setTimeSignature('3/4')":
                    "3/4"

        div .mode-controls:
            span .ctrl-label "View"
            button .btn-mode {.active when editor_mode == 'matrix'} click="setEditorMode('matrix')":
                "Piano roll"
            button .btn-mode {.active when editor_mode == 'strip'} click="setEditorMode('strip')":
                "Strip"
parts/logic/editor.rune
@Logic/studio

action setEditorMode(mode):
    studio_note_tool = "edit"
    editor_mode = mode

action setLowerTab(tab):
    active_lower_tab = tab

action selectVoice(v):
    if v == "drums" and active_voice != "drums":
        selected_note = "kick"
    if v != "drums" and active_voice == "drums":
        selected_note = "E4"
    active_voice = v
    selected_step_id = -1
    music.sync_steps
    status_message = "Active Voice: " + v
    flash_type = "info"

action setVoiceInstrument(inst):
    music.edit_steps("instrument", inst)

action selectDuration(d):
    active_duration = d

action selectBar(b):
    selected_bar = b
    selected_step_id = -1
    music.sync_steps
    if b == 0:
        status_message = "Viewing all bars"
    if b > 0:
        status_message = "Selected Bar " + b
    flash_type = "info"

action addNewBar:
    music.edit_steps("addBar")

action duplicateCurrentBar:
    music.edit_steps("duplicateBar")

action deleteCurrentBar:
    music.edit_steps("deleteBar")

action auditionNote(note):
    music.edit_steps("audition", note)

action placeMatrixNote(x, y):
    music.edit_steps("matrix", x, y)

action clearActiveTrack:
    if active_voice == "lead":
        lead_track = ""
    if active_voice == "bass":
        bass_track = ""
    if active_voice == "chords":
        chords_track = ""
    if active_voice == "drums":
        drums_track = ""
    selected_step_id = -1
    music.sync_steps
    status_message = "Cleared " + active_voice + " track"

action selectStep(id):
    music.select_step(id)

action stretchStep(id, delta):
    music.edit_steps("stretch", id, delta)

action deleteStep(id):
    music.edit_steps("delete", id)
parts/logic/playback.rune
@Logic/studio

action toggleFullscreen:
    fullscreen.toggle()
    is_fullscreen = !is_fullscreen
    if is_fullscreen:
        status_message = "Entered Fullscreen mode"
    if !is_fullscreen:
        status_message = "Exited Fullscreen mode"

action toggleTrackMute(voice):
    if voice == "lead":
        lead_muted = !lead_muted
    if voice == "bass":
        bass_muted = !bass_muted
    if voice == "chords":
        chords_muted = !chords_muted
    if voice == "drums":
        drums_muted = !drums_muted

action playTrack:
    music.compose(selected_song, tempo, lead_track, bass_track, drums_track, time_signature)
    music.play(selected_song, playback_beat)
    is_playing = true
    is_paused = false
    status_message = "Playing: " + song_title + " (" + tempo + " BPM • " + time_signature + ")"
    flash_type = "success"

action pauseTrack:
    music.pause
    is_playing = false
    is_paused = true
    status_message = "Paused: " + song_title
    flash_type = "info"

action stopTrack:
    music.stop
    playback_beat = 0
    playback_bar = 1
    playback_progress = 0
    is_playing = false
    is_paused = false
    status_message = "Stopped playback"
    flash_type = "info"

action changeTempo(delta):
    tempo = clamp(tempo + delta, 40, 240)
    music.tempo = tempo
    status_message = "Tempo: " + tempo + " BPM"

action changeVolume(val):
    volume = clamp(val, 0, 100)
    music.volume = volume / 100

action playSfx(name):
    sound.play(name)
    status_message = "Auditioning sound effect: @" + name
    flash_type = "info"

parts/logic/presets.rune
@Logic/studio

action loadSongLibrary:
    saved_songs = storage.get("rune_studio_song_library")
    if saved_songs == null:
        saved_songs = []

action renameSong(title):
    song_title = title

action newSong:
    call stopTrack
    let number = storage.get("rune_studio_song_number")
    number = (number ?? 0) + 1
    storage.set("rune_studio_song_number", number)
    selected_song = "song_" + number
    song_title = "Untitled " + number
    tempo = 120
    time_signature = "4/4"
    bars = 4
    selected_bar = 0
    selected_step_id = -1
    selected_note = "E4"
    active_duration = ":8"
    active_voice = "lead"
    lead_instrument = "square"
    bass_instrument = "triangle"
    chords_instrument = "sawtooth"
    lead_track = ""
    bass_track = ""
    chords_track = ""
    drums_track = ""
    lead_muted = false
    bass_muted = false
    chords_muted = false
    drums_muted = false
    editor_mode = "matrix"
    studio_note_tool = "edit"
    active_lower_tab = "tracks"
    music.sync_steps
    status_message = "New song ready. Name it and place notes in the piano roll."

action openSong(key):
    if key == "reload_saved":
        call loadFromStorage
    if key == "vectraiders" or key == "vectworms" or key == "cyber_run" or key == "moonlight" or key == "victory":
        call selectSong key
    for entry in saved_songs:
        if entry.key == key:
            selected_song = entry.id
            call loadFromStorage

action selectSong(name):
    selected_song = name
    if name == "vectraiders":
        song_title = "VectRaiders"
        tempo = 144
        time_signature = "4/4"
        bars = 4
        lead_instrument = "square"
        bass_instrument = "triangle"
        chords_instrument = "sawtooth"
        lead_track = "E4:8 D#4:8 E4:8 B3:8 D4:8 C4:8 A3:4 | E4:8 D#4:8 E4:8 B3:8 D4:8 C4:8 A3:4 | C4:8 D4:8 E4:8 G4:8 A4:4 G4:4 | E4:8 D4:8 C4:8 B3:8 A3:2"
        bass_track =
            "A2:4 E2:4 A2:4 E2:4 | A2:4 E2:4 A2:4 E2:4 | C3:4 G2:4 C3:4 G2:4 | F2:4 C2:4 E2:4 G#2:4"
        chords_track = "[A3,C4,E4]:2 [A3,C4,E4]:2 | [A3,C4,E4]:2 [A3,C4,E4]:2 | [C4,E4,G4]:2 [C4,E4,G4]:2 | [F3,A3,C4]:2 [E3,G#3,B3]:2"
        drums_track = "kick:4 snare:4 kick:4 snare:4 | kick:4 snare:4 kick:4 snare:4 | kick:8 hihat:8 snare:4 kick:8 hihat:8 snare:4 | kick:4 snare:4 kick:4 snare:4"
    if name == "vectworms":
        song_title = "VectWorms"
        tempo = 136
        time_signature = "4/4"
        bars = 4
        lead_instrument = "pulse"
        bass_instrument = "triangle"
        chords_instrument = "sine"
        lead_track = "C4:8 E4:8 G4:8 A4:8 G4:8 E4:8 C4:8 D4:8 | E4:8 G4:8 A4:8 C5:8 B4:4 G4:4 | A4:8 G4:8 E4:8 C4:8 D4:8 E4:8 D4:4 | C4:2 -:2"
        bass_track =
            "C2:4 G2:4 C2:4 G2:4 | E2:4 B2:4 E2:4 B2:4 | F2:4 C3:4 G2:4 D3:4 | C2:4 G2:4 C2:2"
        chords_track = "[C4,E4,G4]:2 [C4,E4,G4]:2 | [E4,G4,B4]:2 [E4,G4,B4]:2 | [F4,A4,C5]:2 [G4,B4,D5]:2 | [C4,E4,G4]:2 -:2"
        drums_track = "kick:4 snare:4 kick:8 kick:8 snare:4 | kick:4 snare:4 kick:8 hihat:8 snare:4 | kick:4 snare:4 kick:8 kick:8 snare:4 | kick:4 snare:4 kick:2"
    if name == "cyber_run":
        song_title = "Cyber Run"
        tempo = 152
        time_signature = "4/4"
        bars = 4
        lead_instrument = "sawtooth"
        bass_instrument = "triangle"
        chords_instrument = "sawtooth"
        lead_track = "D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 | D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 | Bb4:8 A4:8 G4:8 F4:8 E4:8 F4:8 G4:4 | D4:8 F4:8 A4:8 D5:4 C5:4 D5:2"
        bass_track = "D2:8 D2:8 A2:8 D2:8 D2:8 A2:8 D2:4 | D2:8 D2:8 A2:8 D2:8 D2:8 A2:8 D2:4 | Bb2:8 Bb2:8 F2:8 Bb2:8 C3:8 C3:8 G2:8 C3:4 | D2:8 D2:8 A2:8 D2:8 D2:2"
        chords_track = "[D4,F4,A4]:2 [C4,E4,G4]:2 | [D4,F4,A4]:2 [C4,E4,G4]:2 | [Bb3,D4,F4]:2 [C4,E4,G4]:2 | [D4,F4,A4]:1"
        drums_track = "kick:4 snare:4 kick:4 snare:4 | kick:4 snare:4 kick:4 snare:4 | kick:8 kick:8 snare:4 kick:8 kick:8 snare:4 | kick:8 hihat:8 snare:8 hihat:8 kick:4 snare:4"
    if name == "moonlight":
        song_title = "Moonlight Dungeon"
        tempo = 108
        time_signature = "3/4"
        bars = 4
        lead_instrument = "square"
        bass_instrument = "triangle"
        chords_instrument = "sine"
        lead_track = "A3:8 C4:8 E4:8 A4:4 G4:8 E4:4 | F4:8 D4:8 B3:8 D4:4 C4:8 A3:2 | E4:8 G4:8 B4:8 D5:4 C5:8 A4:4 | F4:8 E4:8 D#4:8 E4:2 -:4"
        bass_track = "A1:2 E2:4 | D2:2 A1:4 | C2:2 G1:4 | E2:2 E1:4"
        chords_track = "[A3,C4,E4]:2 [A3,C4,E4]:4 | [D3,F3,A3]:2 [D3,F3,A3]:4 | [C3,E3,G3]:2 [C3,E3,G3]:4 | [E3,G#3,B3]:1"
        drums_track = "kick:2 snare:4 | kick:2 snare:4 | kick:2 snare:4 | kick:4 hihat:4 snare:4"
    if name == "victory":
        song_title = "Victory Fanfare"
        tempo = 140
        time_signature = "4/4"
        bars = 3
        lead_instrument = "square"
        bass_instrument = "triangle"
        chords_instrument = "sawtooth"
        lead_track = "C4:8 C4:8 C4:8 C4:4 G3:4 C4:4 | D4:8 D4:8 D4:8 D4:4 A3:4 D4:4 | E4:8 E4:8 F4:8 G4:4 E4:8 D4:4 C4:2"
        bass_track = "C2:4 G2:4 C2:4 G2:4 | D2:4 A2:4 D2:4 A2:4 | E2:4 F2:4 G2:4 C2:2"
        chords_track = "[C4,E4,G4]:1 | [D4,F#4,A4]:1 | [E4,G4,C5]:2 [C4,E4,G4]:2"
        drums_track = "kick:4 snare:4 kick:8 kick:8 snare:4 | kick:4 snare:4 kick:8 kick:8 snare:4 | kick:8 kick:8 snare:8 snare:8 kick:2"

    selected_step_id = -1
    selected_bar = 0
    playback_beat = 0
    playback_bar = 1
    playback_progress = 0
    is_paused = false
    music.sync_steps
    music.compose(selected_song, tempo, lead_track, bass_track, drums_track, time_signature)
    status_message = "Loaded preset: " + song_title + " (" + time_signature + " Time)"
    flash_type = "info"
    if is_playing:
        music.stop
        music.play(selected_song)

action setTimeSignature(sig):
    time_signature = sig
    selected_step_id = -1
    music.sync_steps
    music.compose(selected_song, tempo, lead_track, bass_track, drums_track, time_signature)
    status_message = "Time signature set to " + sig
    flash_type = "info"

action saveToStorage:
    if song_title == "":
        song_title = "Untitled song"
    storage.set("rune_studio_last_song", selected_song)
    storage.set(
        "rune_studio_" + selected_song,
        {
            "title": song_title,
            "tempo": tempo,
            "time_signature": time_signature,
            "bars": bars,
            "lead_instrument": lead_instrument,
            "bass_instrument": bass_instrument,
            "chords_instrument": chords_instrument,
            "lead": lead_track,
            "bass": bass_track,
            "chords": chords_track,
            "drums": drums_track
        }
    )
    call loadSongLibrary
    saved_songs = saved_songs.filter it.id != selected_song
    saved_songs.push({"id": selected_song, "key": "saved:" + selected_song, "title": song_title})
    storage.set("rune_studio_song_library", saved_songs)
    status_message = "Saved " + song_title + " in this browser. EXPORT .RUNE keeps a file copy."
    flash_type = "success"

action loadFromStorage:
    saved = storage.get("rune_studio_" + selected_song)
    if saved != null:
        song_title = saved.title ?? song_title
        tempo = saved.tempo ?? tempo
        time_signature = saved.time_signature ?? time_signature
        bars = saved.bars ?? bars
        lead_instrument = saved.lead_instrument ?? lead_instrument
        bass_instrument = saved.bass_instrument ?? bass_instrument
        chords_instrument = saved.chords_instrument ?? chords_instrument
        selected_bar = 0
        playback_beat = 0
        playback_bar = 1
        playback_progress = 0
        is_paused = false
        lead_track = saved.lead ?? lead_track
        bass_track = saved.bass ?? bass_track
        chords_track = saved.chords ?? chords_track
        drums_track = saved.drums ?? drums_track
        selected_step_id = -1
        music.sync_steps
        status_message = "Restored " + song_title + " from saved browser data."
        flash_type = "success"
        if is_playing:
            music.stop
            music.compose(selected_song, tempo, lead_track, bass_track, drums_track, time_signature)
            music.play(selected_song)
    if saved == null:
        status_message = "No saved browser data found for " + song_title
        flash_type = "warning"

action exportRune:
    code = "# " + song_title + " — Generated with Rune Studio\n\n@Music/" + selected_song + "\ntype = 8bit\ntempo = " + tempo + "\ntime_signature = " + time_signature + "\nbars = " + bars + "\nloop = true\nvolume = 0.2\ninstruments = {" + export_instruments_body + "}\n\nlead:\n    " + lead_export + "\n\nbass:\n    " + bass_export + "\n\nchords:\n    " + chords_export + "\n\ndrums:\n    " + drums_export + "\n" + layer_exports
    download(selected_song + ".rune", code)
    status_message = "Exported " + selected_song + ".rune!"
    flash_type = "success"

action copyCode:
    code = "# " + song_title + " — Generated with Rune Studio\n\n@Music/" + selected_song + "\ntype = 8bit\ntempo = " + tempo + "\ntime_signature = " + time_signature + "\nbars = " + bars + "\nloop = true\nvolume = 0.2\ninstruments = {" + export_instruments_body + "}\n\nlead:\n    " + lead_export + "\n\nbass:\n    " + bass_export + "\n\nchords:\n    " + chords_export + "\n\ndrums:\n    " + drums_export + "\n" + layer_exports
    copy(code)
    status_message = "Copied .rune code to clipboard!"
    flash_type = "success"

parts/logic/state.rune
@Logic/studio

state:
    selected_song = "vectworms"
    song_title = "VectWorms"
    saved_songs = []
    tempo = 136
    time_signature = "4/4"
    bars = 4
    studio_fixed_bars = true
    studio_note_tool = "edit"
    studio_selected_notes = {}
    studio_selection_count = 0
    studio_clipboard_count = 0
    volume = 20
    is_playing = false
    is_paused = false
    is_fullscreen = false
    status_message = "Open a preset or start a new song."
    flash_type = "info"
    active_voice = "lead"
    active_duration = ":8"
    selected_note = "E4"
    selected_step_id = -1
    editor_mode = "matrix"
    selected_bar = 0
    active_lower_tab = "tracks"

    # Audio Sync Engine Reactive State
    playback_step_id = -1
    playback_bar = 1
    playback_beat = 0
    playback_progress = 0
    playback_playing = false

    lead_instrument = "pulse"
    bass_instrument = "triangle"
    chords_instrument = "sine"
    drums_instrument = "drums"
    active_instrument = "pulse"

    lead_muted = false
    bass_muted = false
    chords_muted = false
    drums_muted = false

    lead_track = "C4:8 E4:8 G4:8 A4:8 G4:8 E4:8 C4:8 D4:8 | E4:8 G4:8 A4:8 C5:8 B4:4 G4:4 | A4:8 G4:8 E4:8 C4:8 D4:8 E4:8 D4:4 | C4:2 -:2"
    bass_track = "C2:4 G2:4 C2:4 G2:4 | E2:4 B2:4 E2:4 B2:4 | F2:4 C3:4 G2:4 D3:4 | C2:4 G2:4 C2:2"
    chords_track = "[C4,E4,G4]:2 [C4,E4,G4]:2 | [E4,G4,B4]:2 [E4,G4,B4]:2 | [F4,A4,C5]:2 [G4,B4,D5]:2 | [C4,E4,G4]:2 -:2"
    drums_track = "kick:4 snare:4 kick:8 kick:8 snare:4 | kick:4 snare:4 kick:8 hihat:8 snare:4 | kick:4 snare:4 kick:8 kick:8 snare:4 | kick:4 snare:4 kick:2"
parts/sound.rune
# Rune Studio — Sound & Music Presets

@Sound/laser
wave = sawtooth
freq = 880 -> 110
duration = 120ms
volume = 0.25
curve = exponential

@Sound/hit
wave = square
freq = 180 -> 40
duration = 90ms
volume = 0.35

@Sound/explosion
wave = noise
filter = lowpass 800 -> 60
duration = 350ms
volume = 0.45

@Sound/step
wave = square
notes = 110, 98, 87, 82
duration = 80ms
volume = 0.2

@Sound/coin
wave = sine
sequence = D5:80ms, A5:200ms
volume = 0.25

@Sound/gameover
wave = sawtooth
sequence = E4:150ms, D4:150ms, C4:250ms, G3:450ms
duration = 600ms
volume = 0.3

@Sound/victory
wave = triangle
sequence = C5:120ms, E5:120ms, G5:120ms, C6:240ms
duration = 600ms
volume = 0.3

@Sound/key_lead
wave = square
freq = 523.25
duration = 150ms
volume = 0.25

@Sound/key_bass
wave = triangle
freq = 130.81
duration = 180ms
volume = 0.3

@Sound/drum_kick
wave = sine
freq = 150 -> 40
duration = 120ms
volume = 0.4
curve = exponential

@Sound/drum_snare
wave = noise
filter = bandpass 1200 -> 300
duration = 100ms
volume = 0.35

@Sound/drum_hihat
wave = noise
filter = highpass 5000 -> 8000
duration = 50ms
volume = 0.2

@Music/vectraiders
type = 8bit
tempo = 144
time_signature = 4/4
bars = 4
loop = true
volume = 0.18

lead:
    E4:8 D#4:8 E4:8 B3:8 D4:8 C4:8 A3:4           # Bar 1: Alien theme
    E4:8 D#4:8 E4:8 B3:8 D4:8 C4:8 A3:4           # Bar 2: Motif reprise
    C4:8 D4:8 E4:8 G4:8 A4:4 G4:4                 # Bar 3: Ascending run
    E4:8 D4:8 C4:8 B3:8 A3:2                      # Bar 4: Minor cadence

bass:
    A2:4 E2:4 A2:4 E2:4                           # Bar 1: Driving pulse
    A2:4 E2:4 A2:4 E2:4                           # Bar 2
    C3:4 G2:4 C3:4 G2:4                           # Bar 3
    F2:4 C2:4 E2:4 G#2:4                          # Bar 4

chords:
    [A3,C4,E4]:2 [A3,C4,E4]:2                     # Bar 1: Polyphonic Am Pad
    [A3,C4,E4]:2 [A3,C4,E4]:2                     # Bar 2
    [C4,E4,G4]:2 [C4,E4,G4]:2                     # Bar 3: C Major
    [F3,A3,C4]:2 [E3,G#3,B3]:2                    # Bar 4: F to E Cadence

drums:
    kick:4 snare:4 kick:4 snare:4                 # Bar 1
    kick:4 snare:4 kick:4 snare:4                 # Bar 2
    kick:8 hihat:8 snare:4 kick:8 hihat:8 snare:4 # Bar 3: Roll
    kick:4 snare:4 kick:4 snare:4                 # Bar 4

@Music/vectworms
type = 8bit
tempo = 136
time_signature = 4/4
bars = 4
loop = true
volume = 0.18

lead:
    C4:8 E4:8 G4:8 A4:8 G4:8 E4:8 C4:8 D4:8       # Bar 1: Bouncy opening
    E4:8 G4:8 A4:8 C5:8 B4:4 G4:4                 # Bar 2: Peak melody
    A4:8 G4:8 E4:8 C4:8 D4:8 E4:8 D4:4           # Bar 3: Playful turn
    C4:2 -:2                                      # Bar 4: Rest & resolve

bass:
    C2:4 G2:4 C2:4 G2:4                           # Bar 1: Walking groove
    E2:4 B2:4 E2:4 B2:4                           # Bar 2
    F2:4 C3:4 G2:4 D3:4                           # Bar 3
    C2:4 G2:4 C2:2                                # Bar 4

chords:
    [C4,E4,G4]:2 [C4,E4,G4]:2                     # Bar 1: C Major
    [E4,G4,B4]:2 [E4,G4,B4]:2                     # Bar 2: E Minor
    [F4,A4,C5]:2 [G4,B4,D5]:2                     # Bar 3: F to G
    [C4,E4,G4]:2 -:2                              # Bar 4: Resolution

drums:
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 1: Syncopated beat
    kick:4 snare:4 kick:8 hihat:8 snare:4         # Bar 2
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 3
    kick:4 snare:4 kick:2                         # Bar 4

@Music/cyber_run
type = 8bit
tempo = 152
time_signature = 4/4
bars = 4
loop = true
volume = 0.18

lead:
    D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 # Bar 1: Arp rush
    D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 D4:16 F4:16 A4:16 D5:16 C5:8 A4:8 # Bar 2: Repeat
    Bb4:8 A4:8 G4:8 F4:8 E4:8 F4:8 G4:4                                  # Bar 3: Cascade
    D4:8 F4:8 A4:8 D5:4 C5:4 D5:2                                        # Bar 4: Climax

bass:
    D2:8 D2:8 A2:8 D2:8 D2:8 A2:8 D2:4            # Bar 1: Octave drive
    D2:8 D2:8 A2:8 D2:8 D2:8 A2:8 D2:4            # Bar 2
    Bb2:8 Bb2:8 F2:8 Bb2:8 C3:8 C3:8 G2:8 C3:4    # Bar 3: Power chords
    D2:8 D2:8 A2:8 D2:8 D2:2                      # Bar 4

chords:
    [D4,F4,A4]:2 [C4,E4,G4]:2                     # Bar 1: Dm / C
    [D4,F4,A4]:2 [C4,E4,G4]:2                     # Bar 2
    [Bb3,D4,F4]:2 [C4,E4,G4]:2                    # Bar 3: Bb / C
    [D4,F4,A4]:1                                  # Bar 4: Dm Hold

drums:
    kick:4 snare:4 kick:4 snare:4                 # Bar 1: Four on floor
    kick:4 snare:4 kick:4 snare:4                 # Bar 2
    kick:8 kick:8 snare:4 kick:8 kick:8 snare:4   # Bar 3: Double kick
    kick:8 hihat:8 snare:8 hihat:8 kick:4 snare:4 # Bar 4

@Music/moonlight
type = 8bit
tempo = 108
time_signature = 3/4
bars = 4
loop = true
volume = 0.18

lead:
    A3:8 C4:8 E4:8 A4:4 G4:8 E4:4                 # Bar 1: Eerie opening
    F4:8 D4:8 B3:8 D4:4 C4:8 A3:2                 # Bar 2: Descent
    E4:8 G4:8 B4:8 D5:4 C5:8 A4:4                 # Bar 3: Echoes
    F4:8 E4:8 D#4:8 E4:2 -:4                      # Bar 4: Mystery rest

bass:
    A1:2 E2:4                                     # Bar 1: 3/4 Waltz bass
    D2:2 A1:4                                     # Bar 2
    C2:2 G1:4                                     # Bar 3
    E2:2 E1:4                                     # Bar 4

chords:
    [A3,C4,E4]:2 [A3,C4,E4]:4                     # Bar 1: Am waltz
    [D3,F3,A3]:2 [D3,F3,A3]:4                     # Bar 2: Dm waltz
    [C3,E3,G3]:2 [C3,E3,G3]:4                     # Bar 3: C waltz
    [E3,G#3,B3]:1                                 # Bar 4: E major

drums:
    kick:2 snare:4                                # Bar 1: 3/4 beat
    kick:2 snare:4                                # Bar 2
    kick:2 snare:4                                # Bar 3
    kick:4 hihat:4 snare:4                        # Bar 4

@Music/victory
type = 8bit
tempo = 140
time_signature = 4/4
bars = 3
loop = true
volume = 0.18

lead:
    C4:8 C4:8 C4:8 C4:4 G3:4 C4:4                 # Bar 1: Trumpet call
    D4:8 D4:8 D4:8 D4:4 A3:4 D4:4                 # Bar 2: Lift
    E4:8 E4:8 F4:8 G4:4 E4:8 D4:4 C4:2            # Bar 3: Resolution

bass:
    C2:4 G2:4 C2:4 G2:4                           # Bar 1
    D2:4 A2:4 D2:4 A2:4                           # Bar 2
    E2:4 F2:4 G2:4 C2:2                           # Bar 3

chords:
    [C4,E4,G4]:1                                  # Bar 1: C Major Triad
    [D4,F#4,A4]:1                                 # Bar 2: D Major Triad
    [E4,G4,C5]:2 [C4,E4,G4]:2                     # Bar 3: Grand Finale

drums:
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 1
    kick:4 snare:4 kick:8 kick:8 snare:4          # Bar 2
    kick:8 kick:8 snare:8 snare:8 kick:2          # Bar 3: Grand roll
parts/style/base.rune
@Style/studio

tokens:
    neon_cyan = #00e5ff
    neon_lime = #39ff14
    neon_pink = #ff2a85
    neon_amber = #ffaa00
    chassis_bg = #080b16
    rack_bg = #0d1224
    card_bg = #121830
    grid_border = #202b48
    text_muted = #9aaac0

rules:
    body:
        margin = 0
        padding = 8px
        box-sizing = border-box
        background = {chassis_bg}
        color = #ffffff
        font-family = system-ui, sans-serif

    .studio-cabinet:
        background = {chassis_bg}
        color = #ffffff
        font-family = system-ui, sans-serif
        padding = clamp(0.55rem, 1.4vw, 1.2rem)
        border-radius = 12px
        border = 1px solid {grid_border}
        max-width = 1520px
        margin = 0 auto
        width = 100%
        box-sizing = border-box
        display = grid
        gap = 0.65rem

    .studio-header:
        display = flex
        justify-content = space-between
        align-items = center
        gap = 0.8rem

    .studio-title:
        color = #e7f3ff
        font-size = 1.05rem
        font-weight = 800
        letter-spacing = 2px
        margin = 0

    .btn-fullscreen:
        padding = 0.4rem 0.85rem
        border-radius = 6px
        font-size = 0.75rem
        letter-spacing = 1px
        font-weight = bold
        background = {card_bg}
        border = 1px solid {neon_cyan}
        color = {neon_cyan}
        cursor = pointer
        transition = all 0.15s ease
        touch-action = manipulation

    .btn-fullscreen:hover:
        background = {neon_cyan}
        color = #000000
        box-shadow = 0 0 12px {neon_cyan}

    .status-txt:
        flex = 1
        margin = 0
        padding = 0.2rem 0.3rem
        min-height = 1rem
        font-size = 0.78rem
        color = {text_muted}

    .song-selector:
        display = flex
        align-items = end
        justify-content = space-between
        gap = 0.6rem
        flex-wrap = wrap
        padding = 0.75rem
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 9px

    .song-title-label:
        flex = 1
        min-width = min(100%, 230px)
        display = grid
        gap = 0.25rem

    .song-title-input, .song-open:
        background = {chassis_bg}
        border = 1px solid {grid_border}
        border-radius = 6px
        color = #e7f3ff
        box-sizing = border-box
        min-height = 36px
        padding = 0.4rem 0.6rem
        font-family = inherit
        color-scheme = dark

    .song-title-input:
        font-size = 1rem
        font-weight = 650
        width = 100%

    .song-open:
        font-size = 0.8rem
        max-width = 14rem

    .song-actions:
        display = flex
        flex-wrap = wrap
        gap = 0.35rem

    .btn-storage.btn-new-song:
        background = #263c58
        color = #e7f3ff
        border-color = #486786
        font-weight = 700

    .transport-bar:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 9px
        padding = 0.45rem 0.65rem
        display = flex
        align-items = center
        flex-wrap = wrap
        gap = 0.6rem 1.15rem
        position = sticky
        top = 0
        z-index = 30

    .studio-workspace:
        display = grid
        grid-template-columns = minmax(130px, 172px) minmax(0, 1fr)
        align-items = start
        gap = 0.65rem

    .studio-cabinet :focus-visible:
        outline = 2px solid {neon_cyan}
        outline-offset = 2px

    .transport-buttons:
        display = flex
        gap = 0.5rem

    .btn-transport:
        padding = 0.6rem 1.2rem
        border-radius = 8px
        font-weight = bold
        border = none
        cursor = pointer
        font-family = inherit
        letter-spacing = 1px
        font-size = 0.9rem
        display = flex
        align-items = center
        gap = 0.4rem
        transition = all 0.15s ease
        touch-action = manipulation
        min-height = 42px

    .btn-play:
        background = #8de0a5
        color = #102518

    .btn-play:hover:
        background = #b4edc1

    .btn-pause:
        background = {neon_amber}
        color = #000000

    .btn-transport-seek:
        min-width = 32px
        padding = 0 0.45rem
        border-radius = 6px
        font-family = inherit
        font-size = 1.2rem
        line-height = 1
        border = 1px solid {grid_border}
        background = {card_bg}
        color = #e7f3ff
        cursor = pointer
        touch-action = manipulation

    .btn-transport-seek:hover:
        border-color = {neon_cyan}

    .transport-buttons.is-playing .btn-transport-seek:
        visibility = hidden

    .btn-transport-seek:disabled:
        opacity = 0.45
        cursor = default

    .tempo-controls:
        display = flex
        align-items = center
        gap = 0.6rem

    .ctrl-label:
        font-size = 0.8rem
        color = {text_muted}
        font-weight = bold

    .bpm-badge:
        font-size = 1.1rem
        font-weight = bold
        color = {neon_lime}
        min-width = 80px
        text-align = center

    .btn-tempo:
        background = {card_bg}
        color = #ffffff
        border = 1px solid {grid_border}
        width = 36px
        height = 36px
        border-radius = 6px
        cursor = pointer
        font-weight = bold
        touch-action = manipulation

    .time-sig-controls:
        display = flex
        align-items = center
        gap = 0.4rem

    .btn-timesig:
        background = {card_bg}
        color = {text_muted}
        border = 1px solid {grid_border}
        padding = 0.4rem 0.65rem
        border-radius = 6px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.8rem
        transition = all 0.15s ease

    .btn-timesig.active:
        background = {neon_amber}
        color = #000000
        border-color = {neon_amber}
        box-shadow = 0 0 10px {neon_amber}

    .mode-controls:
        margin-left = auto
        display = flex
        align-items = center
        gap = 0.4rem

    .btn-mode:
        background = {card_bg}
        color = {neon_cyan}
        border = 1px solid {grid_border}
        padding = 0.4rem 0.65rem
        border-radius = 6px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.75rem
        transition = all 0.15s ease

    .btn-mode.active:
        background = {neon_cyan}
        color = #000000
        box-shadow = 0 0 12px {neon_cyan}

    .btn-storage:
        background = {card_bg}
        color = {neon_cyan}
        border = 1px solid {grid_border}
        padding = 0.5rem 0.8rem
        border-radius = 6px
        cursor = pointer
        font-family = inherit
        font-size = 0.75rem
        letter-spacing = 1px
        transition = all 0.15s ease
        touch-action = manipulation
        min-height = 36px

    .btn-storage:hover:
        border-color = {neon_cyan}
        box-shadow = 0 0 10px rgba(0, 229, 255, 0.3)

parts/style/editor.rune
@Style/studio

rules:
    .studio-tracks, .note-editor-panel:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 9px
        min-width = 0
        padding = 0.7rem

    .tracks-heading:
        margin = 0 0 0.55rem
        color = {text_muted}
        font-size = 0.76rem
        font-weight = 650

    .voice-tabs:
        display = grid
        gap = 0.3rem

    .voice-tab:
        display = grid
        gap = 0.1rem
        width = 100%
        background = {card_bg}
        color = #e7f3ff
        border = 1px solid {grid_border}
        border-radius = 6px
        padding = 0.45rem 0.55rem
        text-align = left
        cursor = pointer
        font-family = inherit
        touch-action = manipulation

    .voice-tab.active:
        border-color = {neon_cyan}
        background = #173546

    .voice-tab:hover:
        border-color = {neon_cyan}

    .voice-name:
        font-size = 0.82rem
        font-weight = 700

    .voice-sound:
        color = {text_muted}
        font-size = 0.68rem
        text-transform = capitalize

    .editor-header:
        display = flex
        flex-wrap = wrap
        align-items = center
        gap = 0.4rem 0.8rem
        margin-bottom = 0.5rem

    .editor-label:
        font-size = 0.75rem
        color = {text_muted}
        font-weight = 650
        align-self = center

    .instrument-picker:
        display = flex
        gap = 0.4rem
        align-items = center
        flex-wrap = wrap

    .pill-instrument:
        background = {card_bg}
        color = {neon_cyan}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.65rem
        border-radius = 12px
        font-size = 0.75rem
        font-weight = bold
        cursor = pointer
        transition = all 0.15s ease
        touch-action = manipulation

    .pill-instrument:hover:
        border-color = {neon_cyan}
        box-shadow = 0 0 8px rgba(0, 229, 255, 0.4)

    .pill-instrument.active:
        background = {neon_cyan}
        color = #000000
        border-color = {neon_cyan}
        box-shadow = 0 0 12px {neon_cyan}

    .duration-picker:
        display = flex
        gap = 0.4rem
        align-items = center
        flex-wrap = wrap

    .pill-duration:
        background = {card_bg}
        color = {neon_lime}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.75rem
        border-radius = 16px
        font-size = 0.8rem
        font-weight = bold
        cursor = pointer
        transition = all 0.15s ease
        touch-action = manipulation

    .pill-duration.active:
        background = {neon_lime}
        color = #000000
        box-shadow = 0 0 12px {neon_lime}
        border-color = {neon_lime}

    .editor-tools:
        display = flex
        gap = 0.5rem
        align-items = center
        flex-wrap = wrap

    .current-note-badge:
        display = flex
        align-items = center
        gap = 0.4rem
        background = {card_bg}
        border = 1px solid {neon_lime}
        border-radius = 6px
        padding = 0.3rem 0.65rem

    .badge-lbl:
        font-size = 0.65rem
        color = {text_muted}
        font-weight = bold

    .badge-val:
        font-size = 0.9rem
        color = {neon_lime}
        font-weight = 900

    .badge-sub:
        font-size = 0.75rem
        color = {neon_cyan}

    .btn-tool:
        background = {card_bg}
        color = #ffffff
        border = 1px solid {grid_border}
        padding = 0.45rem 0.85rem
        border-radius = 6px
        font-size = 0.8rem
        cursor = pointer
        font-family = inherit
        transition = all 0.15s ease
        touch-action = manipulation

    .btn-tool:hover:
        border-color = {neon_cyan}

    .btn-tool-danger:
        color = {neon_pink}
        border-color = rgba(255, 42, 133, 0.4)

    .btn-tool-danger:hover:
        background = {neon_pink}
        color = #000000

    .step-sequencer-rack:
        background = #050814
        border = 1px solid {grid_border}
        border-radius = 10px
        padding = 0.85rem
        margin-bottom = 1rem

    .step-rack-header:
        display = flex
        justify-content = space-between
        align-items = center
        margin-bottom = 0.6rem
        flex-wrap = wrap
        gap = 0.5rem

    .step-rack-title:
        display = flex
        align-items = center
        gap = 0.5rem

    .step-title-icon:
        font-size = 1rem

    .step-title-text:
        margin = 0
        font-size = 0.8rem
        font-weight = bold
        letter-spacing = 1px
        color = {neon_cyan}
        text-transform = uppercase

    .step-rack-hint:
        font-size = 0.7rem
        color = {text_muted}

    .step-strip-scroll:
        overflow-x = auto
        padding = 0.4rem 0
        -webkit-overflow-scrolling = touch
        position = relative

    .step-strip:
        position = relative

    .step-bar-divider:
        position = absolute
        top = 0
        bottom = 0
        margin-left = -3px
        border-left = 2px solid {neon_amber}
        pointer-events = none

    .step-chip:
        background = {card_bg}
        border = 1px solid {grid_border}
        border-radius = 8px
        padding = 0.35rem 0.15rem
        box-sizing = border-box
        height = 84px
        display = flex
        flex-direction = column
        align-items = center
        justify-content = center
        gap = 0.15rem
        font-family = inherit
        transition = all 0.12s ease
        position = absolute
        top = 0
        user-select = none

    .step-chip.playing-step-now:
        border-color = {neon_cyan} !important
        background = rgba(0, 229, 255, 0.35) !important
        box-shadow = 0 0 18px {neon_cyan} !important
        z-index = 15 !important

    .step-num:
        font-size = 0.6rem
        color = {text_muted}

    .step-pitch:
        font-size = 0.85rem
        font-weight = 900
        color = #ffffff

    .step-len:
        font-size = 0.65rem
        color = {neon_cyan}

    .chip-step-high .step-pitch:
        color = {neon_cyan}

    .chip-step-mid .step-pitch:
        color = {neon_lime}

    .chip-step-mid-low .step-pitch:
        color = {neon_amber}

    .chip-step-bass .step-pitch:
        color = {neon_pink}

    .chip-step-kick .step-pitch:
        color = #ff5500

    .chip-step-snare .step-pitch:
        color = {neon_pink}

    .chip-step-hihat .step-pitch:
        color = #ffd000

    .chip-step-rest:
        border-style = dashed
        opacity = 0.6

    .chip-step-chord:
        border-color = {neon_amber}
        background = rgba(255, 170, 0, 0.15)


    .timeline-ruler:
        background = #080c1a
        border = 1px solid {grid_border}
        border-radius = 8px
        padding = 0.6rem 0.8rem
        margin = 0.45rem 0
        display = flex
        flex-direction = column
        gap = 0.35rem

    .ruler-header-row:
        display = flex
        gap = 0.5rem
        justify-content = space-between
        align-items = center

    .ruler-header:
        font-size = 0.7rem
        font-weight = bold
        color = {text_muted}
        letter-spacing = 1px

    .ruler-hint:
        margin-left = auto
        font-size = 0.65rem
        color = {text_muted}

    .ruler-track:
        position = relative
        width = 100%

    .ruler-scrub:
        height = 22px
        border-bottom = 1px solid {grid_border}
        touch-action = none

    .ruler-scrub.can-seek:
        cursor = ew-resize

    .ruler-playhead::before:
        content = ""
        position = absolute
        left = -4px
        top = 2px
        width = 11px
        height = 11px
        background = {neon_cyan}
        border-radius = 3px

    .ruler-playhead:
        position = absolute
        top = 0
        bottom = 0
        width = 3px
        background = {neon_cyan}
        box-shadow = 0 0 10px {neon_cyan}
        z-index = 20
        pointer-events = none
        left = 0%
        display = block

    .ruler-bars:
        display = flex
        gap = 0.35rem
        width = 100%

    .ruler-bars .ruler-bar-item:
        flex = 1
        min-width = 0
        padding = 0.35rem 0.1rem
        color = {text_muted}
        text-align = center

    .ruler-bar-item:hover:
        border-color = {neon_cyan}
        background = rgba(0, 229, 255, 0.08)

    .ruler-bars .ruler-bar-item.active-bar:
        border-color = {neon_cyan}
        background = rgba(0, 229, 255, 0.18)
        box-shadow = 0 0 10px rgba(0, 229, 255, 0.3)

    .ruler-bars .ruler-bar-item.playing-bar:
        border-color = {neon_lime} !important
        background = rgba(57, 255, 20, 0.22) !important
        box-shadow = 0 0 14px {neon_lime} !important

    .ruler-bar-num:
        font-size = 0.75rem
        font-weight = 900
        color = {neon_cyan}

    .bar-tab:
        background = {card_bg}
        color = {text_muted}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.65rem
        border-radius = 6px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.75rem
        transition = all 0.15s ease
        touch-action = manipulation

    .bar-tab:hover:
        color = #ffffff
        border-color = {neon_cyan}

    .bar-tab.active:
        background = {neon_cyan}
        color = #000000
        border-color = {neon_cyan}
        box-shadow = 0 0 10px {neon_cyan}

    .bar-actions:
        display = flex
        gap = 0.4rem
        align-items = center

    .btn-bar-action:
        background = {card_bg}
        color = {neon_cyan}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.65rem
        border-radius = 6px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.75rem
        transition = all 0.15s ease

    .btn-bar-action:hover:
        border-color = {neon_cyan}
        box-shadow = 0 0 8px rgba(0, 229, 255, 0.4)

    .btn-add-bar:
        border-color = {neon_lime}
        color = {neon_lime}

    .btn-add-bar:hover:
        border-color = {neon_lime}
        box-shadow = 0 0 10px rgba(57, 255, 20, 0.4)

    .seq-playhead:
        position = absolute
        top = 0
        bottom = 0
        width = 2px
        background = {neon_cyan}
        box-shadow = 0 0 10px {neon_cyan}
        z-index = 25
        pointer-events = none
        left = 0%
        display = block

    .seq-seek-grip:
        position = absolute
        top = 1px
        left = -4px
        width = 13px
        height = 19px
        background = {neon_cyan}
        border-radius = 3px
        pointer-events = auto
        cursor = ew-resize
        touch-action = none

    .piano-matrix-rack:
        background = #050814
        border = 1px solid {grid_border}
        border-radius = 8px
        padding = 0.75rem
        margin = 0.45rem 0

    .matrix-header:
        display = flex
        flex-wrap = wrap
        justify-content = space-between
        align-items = center
        margin-bottom = 0.5rem
        flex-wrap = wrap
        gap = 0.5rem

    .matrix-title:
        margin = 0
        font-size = 0.8rem
        font-weight = 900
        color = {neon_lime}
        letter-spacing = 1px

    .matrix-sub:
        font-size = 0.7rem
        color = {text_muted}

    .matrix-container:
        display = flex
        border = 1px solid {grid_border}
        border-radius = 6px
        overflow = auto
        max-height = clamp(300px, 48vh, 580px)
        background = #080c1a
        position = relative

    .matrix-note-tools:
        display = flex
        flex-wrap = wrap
        align-items = center
        gap = 0.35rem

    .matrix-note-tools .step-stretch-btn:
        font-family = inherit
        font-size = 0.75rem
        padding = 0.3rem 0.55rem
        touch-action = manipulation

    .matrix-note-tools .step-stretch-btn.active:
        background = #173546
        border-color = {neon_cyan}
        color = #e7f3ff

    .matrix-note-tools .step-stretch-btn:disabled:
        opacity = 0.45
        cursor = default

    .matrix-grid-surface.selection-tool:
        touch-action = none

    .matrix-grid-surface.selection-tool .matrix-note-block, .matrix-grid-surface.paste-tool .matrix-note-block:
        cursor = crosshair

    .matrix-grid-surface.selection-tool .matrix-delete-btn, .matrix-grid-surface.selection-tool .note-resize-grip, .matrix-grid-surface.paste-tool .matrix-delete-btn, .matrix-grid-surface.paste-tool .note-resize-grip:
        visibility = hidden

    .studio-note-marquee:
        position = fixed
        z-index = 100000
        box-sizing = border-box
        pointer-events = none
        border = 1px solid {neon_cyan}
        background = rgba(0, 229, 255, 0.17)

    .matrix-keys-column:
        position = sticky
        left = 0
        z-index = 27
        display = flex
        flex-direction = column
        background = #03050c
        border-right = 2px solid {grid_border}
        width = 68px
        flex-shrink = 0

    .matrix-key:
        font-family = inherit
        font-size = 0.65rem
        font-weight = bold
        padding = 0 6px
        border = none
        border-bottom = 1px solid rgba(255, 255, 255, 0.05)
        text-align = right
        cursor = pointer
        transition = all 0.1s ease
        touch-action = manipulation
        height = 28px
        flex-shrink = 0
        box-sizing = border-box
        display = flex
        align-items = center
        justify-content = flex-end

    .mkey-drum:
        height = 48px
        font-size = 0.7rem
        background = #131b2e
        color = {neon_amber}
        justify-content = center

    .mkey-white:
        background = #e2e8f0
        color = #0f172a

    .mkey-black:
        background = #1e293b
        color = {neon_cyan}

    .matrix-key.selected-key:
        background = {neon_cyan} !important
        color = #000000 !important
        box-shadow = 0 0 10px {neon_cyan} !important
        font-weight = 900

    .matrix-note-timeline:
        position = relative
        flex = none

    .matrix-grid-surface:
        position = relative
        height = 1008px
        cursor = crosshair
        background-color = #070b18
        background-image = linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(to right, rgba(0, 229, 255, 0.18) 1px, transparent 1px, transparent 119px, rgba(0, 229, 255, 0.18) 120px), linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px)
        background-size = 100% 28px, 120px 100%, 30px 100%

    .matrix-grid-surface.surface-drums:
        height = 144px
        background-image = linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 1px, transparent 1px), linear-gradient(to right, rgba(0, 229, 255, 0.18) 1px, transparent 1px, transparent 119px, rgba(0, 229, 255, 0.18) 120px), linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px)
        background-size = 100% 48px, 120px 100%, 30px 100%

    .matrix-bar-divider:
        position = absolute
        top = 0
        bottom = 0
        width = 2px
        background = rgba(255, 170, 0, 0.45)
        border-right = 1px dashed rgba(255, 170, 0, 0.75)
        z-index = 8
        cursor = pointer

    .matrix-bar-divider-label:
        position = absolute
        top = 4px
        left = 4px
        font-size = 9px
        font-weight = 900
        color = {neon_amber}
        background = rgba(0, 0, 0, 0.75)
        padding = 1px 4px
        border-radius = 3px
        pointer-events = none

    .note-resize-grip:
        position = absolute
        top = 1px
        bottom = 1px
        right = 0
        width = 8px
        z-index = 21
        background = linear-gradient(to left, rgba(255, 255, 255, 0.38) 2px, transparent 2px)
        cursor = ew-resize
        touch-action = none

    .note-resize-grip:hover:
        background = rgba(255, 255, 255, 0.28)

    .studio-drag-preview:
        position = fixed
        pointer-events = none
        box-sizing = border-box
        z-index = 1000
        background = rgba(0, 229, 255, 0.25)
        border = 2px solid {neon_cyan}
        border-radius = 4px

    .studio-drag-preview.studio-drag-blocked:
        background = rgba(255, 42, 133, 0.25)
        border-color = {neon_pink}

    .matrix-note-block:
        position = absolute
        height = 24px
        box-sizing = border-box
        border-radius = 4px
        border = 1px solid rgba(255, 255, 255, 0.25)
        background = rgba(0, 229, 255, 0.22)
        display = flex
        align-items = center
        justify-content = space-between
        padding = 0 8px 0 2px
        overflow = hidden
        cursor = grab
        transition = transform 0.1s ease, box-shadow 0.1s ease
        touch-action = none
        z-index = 10
        user-select = none

    .matrix-note-block.compact-note:
        padding = 0 5px 0 0

    .compact-note .note-resize-grip:
        width = 5px

    .compact-note .matrix-delete-btn:
        width = 8px
        margin-left = 0

    .surface-drums .matrix-note-block:
        height = 42px

    .matrix-note-block:hover:
        border-color = {neon_cyan}
        box-shadow = 0 0 10px rgba(0, 229, 255, 0.5)
        z-index = 15

    .matrix-note-block.selected-step:
        border-color = {neon_lime} !important
        background = rgba(57, 255, 20, 0.35) !important
        box-shadow = 0 0 16px rgba(57, 255, 20, 0.7) !important
        z-index = 20 !important

    .matrix-note-block.playing-step-now:
        border-color = #ffffff !important
        background = {neon_cyan} !important
        box-shadow = 0 0 20px {neon_cyan} !important
        color = #000000 !important
        z-index = 25 !important

    .matrix-note-body:
        display = flex
        flex = 1
        min-width = 0
        align-items = baseline
        gap = 4px
        overflow = hidden
        white-space = nowrap
        pointer-events = none

    .matrix-note-pitch:
        font-size = 11px
        font-weight = 900
        color = #ffffff

    .playing-step-now .matrix-note-pitch:
        color = #000000

    .matrix-note-len:
        font-size = 9px
        color = rgba(255, 255, 255, 0.7)

    .playing-step-now .matrix-note-len:
        color = rgba(0, 0, 0, 0.8)

    .matrix-length-controls:
        display = flex
        gap = 6px
        margin-left = auto

    .matrix-delete-btn:
        background = {neon_pink}
        color = #ffffff
        border = 1px solid rgba(255, 255, 255, 0.4)
        border-radius = 50%
        width = 16px
        height = 16px
        font-size = 11px
        line-height = 1
        display = flex
        align-items = center
        justify-content = center
        cursor = pointer
        padding = 0
        flex-shrink = 0
        z-index = 12
        margin-left = 2px

    .matrix-delete-btn:hover:
        transform = scale(1.2)
        box-shadow = 0 0 8px {neon_pink}

    .chip-step-high.matrix-note-block:
        border-left = 4px solid {neon_cyan}

    .chip-step-mid.matrix-note-block:
        border-left = 4px solid {neon_lime}

    .chip-step-mid-low.matrix-note-block:
        border-left = 4px solid {neon_amber}

    .chip-step-bass.matrix-note-block:
        border-left = 4px solid {neon_pink}

    .chip-step-kick.matrix-note-block:
        border-left = 4px solid #ff5500

    .chip-step-snare.matrix-note-block:
        border-left = 4px solid {neon_pink}

    .chip-step-hihat.matrix-note-block:
        border-left = 4px solid #ffd000

    .chip-step-rest.matrix-note-block:
        border-style = dashed
        opacity = 0.5

    .step-stretch-btn:
        background = rgba(255, 255, 255, 0.1)
        color = #ffffff
        border = 1px solid rgba(255, 255, 255, 0.2)
        border-radius = 3px
        padding = 1px 4px
        font-size = 9px
        cursor = pointer
        transition = all 0.1s ease

    .step-stretch-btn:hover:
        background = {neon_cyan}
        color = #000000

    .piano-roll-container:
        overflow-x = auto
        padding = 0.5rem 0 1rem 0
        margin-top = 0.5rem

    .piano-roll:
        display = flex
        gap = 3px
        min-width = 720px
        padding = 4px

    .piano-key:
        border-radius = 0 0 6px 6px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.75rem
        display = flex
        align-items = flex-end
        justify-content = center
        padding-bottom = 8px
        transition = all 0.1s ease
        user-select = none
        touch-action = manipulation

    .key-white:
        background = #e2e8f0
        color = #0f172a
        border = 1px solid #94a3b8
        width = 36px
        height = 110px
        z-index = 1

    .key-white:hover:
        background = #00e5ff
        color = #000000
        box-shadow = 0 0 14px #00e5ff

    .key-white:active:
        background = #39ff14
        transform = translateY(2px)

    .key-black:
        background = #090d1a
        color = #00e5ff
        border = 1px solid #00e5ff
        width = 30px
        height = 75px
        margin-left = -15px
        margin-right = -15px
        z-index = 2
        box-shadow = 0 2px 8px rgba(0, 0, 0, 0.9)

    .key-black:hover:
        background = #ff2a85
        color = #ffffff
        border-color = #ff2a85
        box-shadow = 0 0 14px #ff2a85

    .key-black:active:
        background = #39ff14
        color = #000000
        transform = translateY(2px)

    .piano-key.selected-key:
        background = {neon_lime} !important
        color = #000000 !important
        box-shadow = 0 0 18px {neon_lime} !important
        border-color = {neon_lime} !important
        transform = translateY(2px)
        font-weight = 900 !important

    .drum-machine-container:
        padding = 1rem 0

    .drum-pads:
        display = grid
        grid-template-columns = repeat(auto-fit, minmax(130px, 1fr))
        gap = 0.75rem

    .drum-pad:
        background = {card_bg}
        border = 2px solid {grid_border}
        border-radius = 12px
        padding = 1.25rem 0.5rem
        cursor = pointer
        display = flex
        flex-direction = column
        align-items = center
        gap = 0.5rem
        font-family = inherit
        transition = all 0.12s ease
        touch-action = manipulation
        min-height = 90px

    .drum-pad:hover:
        border-color = {neon_pink}
        box-shadow = 0 0 18px {neon_pink}
        transform = translateY(-2px)

    .drum-pad:active:
        background = {neon_pink}
        color = #000000
        transform = scale(0.96)

    .drum-pad.selected-key:
        border-color = {neon_lime} !important
        box-shadow = 0 0 20px {neon_lime} !important
        background = rgba(57, 255, 20, 0.2) !important

    .drum-icon:
        font-size = 1.75rem

    .drum-name:
        font-size = 0.85rem
        font-weight = bold
        color = #ffffff
        letter-spacing = 2px

parts/style/panels.rune
@Style/studio

rules:
    .tracks-container:
        display = flex
        flex-direction = column
        gap = 1rem
        margin-bottom = 1.25rem

    .track-rack:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 12px
        padding = 1rem
        transition = all 0.18s ease
        cursor = pointer

    .track-rack:hover:
        border-color = rgba(0, 229, 255, 0.5)

    .track-rack.active-rack:
        border = 2px solid {neon_cyan}
        box-shadow = 0 0 25px rgba(0, 229, 255, 0.35)
        background = rgba(0, 229, 255, 0.05)

    .pill-active-track:
        color = {neon_cyan}
        background = rgba(0, 229, 255, 0.2)
        border = 1px solid {neon_cyan}
        border-radius = 12px
        padding = 0.2rem 0.6rem
        font-size = 0.65rem
        font-weight = bold
        letter-spacing = 1px
        box-shadow = 0 0 10px rgba(0, 229, 255, 0.4)

    .track-header:
        display = flex
        justify-content = space-between
        align-items = center
        margin-bottom = 0.75rem
        flex-wrap = wrap
        gap = 0.5rem

    .track-meta:
        display = flex
        align-items = center
        gap = 0.6rem
        flex-wrap = wrap

    .track-icon:
        font-size = 1.25rem

    .track-name:
        font-size = 1rem
        font-weight = bold
        color = #ffffff
        margin = 0

    .track-actions:
        display = flex
        align-items = center
        gap = 0.4rem

    .btn-track-mute:
        background = {card_bg}
        color = {text_muted}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.6rem
        border-radius = 6px
        font-size = 0.75rem
        cursor = pointer
        font-weight = bold
        font-family = inherit
        transition = all 0.15s ease
        touch-action = manipulation

    .btn-track-mute.btn-muted:
        background = #ef4444 !important
        color = #ffffff !important
        border-color = #ef4444 !important
        box-shadow = 0 0 10px #ef4444 !important

    .btn-edit-track:
        background = {card_bg}
        color = {neon_cyan}
        border = 1px solid {grid_border}
        padding = 0.35rem 0.75rem
        border-radius = 6px
        font-size = 0.75rem
        cursor = pointer
        font-family = inherit
        font-weight = bold
        letter-spacing = 1px
        transition = all 0.15s ease
        touch-action = manipulation

    .btn-edit-track:hover:
        background = {neon_cyan}
        color = #000000
        border-color = {neon_cyan}
        box-shadow = 0 0 10px {neon_cyan}

    .btn-editing:
        background = {neon_cyan} !important
        color = #000000 !important
        box-shadow = 0 0 12px {neon_cyan} !important
        border-color = {neon_cyan} !important

    .badge-wave:
        font-size = 0.7rem
        padding = 0.2rem 0.5rem
        border-radius = 4px
        text-transform = uppercase
        letter-spacing = 1px
        font-weight = bold

    .badge-square:
        background = rgba(0, 229, 255, 0.2)
        color = {neon_cyan}
        border = 1px solid {neon_cyan}

    .badge-triangle:
        background = rgba(57, 255, 20, 0.2)
        color = {neon_lime}
        border = 1px solid {neon_lime}

    .badge-noise:
        background = rgba(255, 42, 133, 0.2)
        color = {neon_pink}
        border = 1px solid {neon_pink}

    .badge-saw:
        background = rgba(255, 170, 0, 0.2)
        color = {neon_amber}
        border = 1px solid {neon_amber}

    .track-score-box:
        background = #03050c
        border = 1px solid {grid_border}
        border-radius = 8px
        padding = 0.75rem
        color = #e2e8f0
        font-family = "Courier New", monospace
        font-size = 0.85rem
        line-height = 1.5
        white-space = pre-wrap
        word-break = break-word

    .active-score-box:
        border-color = {neon_cyan}
        box-shadow = 0 0 12px rgba(0, 229, 255, 0.25)
        background = #060b18

    .sfx-section:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 12px
        padding = 1rem
        margin-bottom = 1.25rem

    .sfx-heading:
        font-size = 0.95rem
        color = {neon_pink}
        letter-spacing = 2px
        margin = 0 0 0.75rem 0
        font-weight = bold

    .sfx-pads:
        display = grid
        grid-template-columns = repeat(auto-fit, minmax(110px, 1fr))
        gap = 0.5rem

    .pad-btn:
        background = {card_bg}
        color = #ffffff
        border = 1px solid {grid_border}
        padding = 0.75rem 0.5rem
        border-radius = 8px
        cursor = pointer
        font-family = inherit
        font-size = 0.8rem
        letter-spacing = 1px
        display = flex
        flex-direction = column
        align-items = center
        gap = 0.25rem
        transition = all 0.1s ease
        touch-action = manipulation
        min-height = 54px

    .pad-btn:hover:
        border-color = {neon_pink}
        box-shadow = 0 0 12px {neon_pink}
        transform = scale(1.03)

    .pad-btn:active:
        transform = scale(0.96)
        background = {neon_pink}
        color = #000000

    .export-section:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 12px
        padding = 1rem

    .export-header:
        display = flex
        justify-content = space-between
        align-items = center
        margin-bottom = 0.75rem

    .code-preview:
        background = #02040a
        border = 1px solid {grid_border}
        border-radius = 8px
        padding = 1rem
        font-family = "Courier New", monospace
        font-size = 0.8rem
        color = {neon_lime}
        overflow-x = auto
        white-space = pre-wrap
        max-height = 240px

    .lower-tabs-cabinet:
        background = {rack_bg}
        border = 1px solid {grid_border}
        border-radius = 12px
        padding = 1.25rem
        margin-top = 1.25rem
        box-shadow = 0 8px 32px rgba(0, 0, 0, 0.4)

    .lower-tab-bar:
        display = flex
        gap = 0.5rem
        border-bottom = 2px solid {grid_border}
        padding-bottom = 0.75rem
        margin-bottom = 1rem
        flex-wrap = wrap

    .lower-tab-btn:
        background = {card_bg}
        color = {text_muted}
        border = 1px solid {grid_border}
        padding = 0.55rem 1rem
        border-radius = 8px
        cursor = pointer
        font-family = inherit
        font-weight = bold
        font-size = 0.8rem
        letter-spacing = 1px
        transition = all 0.15s ease
        touch-action = manipulation

    .lower-tab-btn:hover:
        color = #ffffff
        border-color = {neon_cyan}

    .lower-tab-btn.active:
        background = {neon_cyan}
        color = #000000
        border-color = {neon_cyan}
        box-shadow = 0 0 12px {neon_cyan}

    .lower-tab-content:
        min-height = 120px

fullscreen:
    body:
        margin = 0
        padding = 0
        background = #020308
        overflow = auto
    .studio-cabinet:
        position = fixed
        top = 0
        left = 0
        width = 100vw
        height = 100vh
        max-width = 100vw
        border-radius = 0
        border = none
        min-height = 100vh
        box-shadow = none
        padding = 1.25rem 2rem
        z-index = 99999
        overflow-y = auto
        box-sizing = border-box
    .piano-roll-container:
        padding = 1rem 0
    .track-rack:
        border-color = rgba(0, 229, 255, 0.4)

responsive:
    (max-width: 768px):
        .studio-cabinet:
            padding = 0.75rem
            border-radius = 12px
        .studio-header:
            display = grid
            grid-template-columns = minmax(0, 1fr) auto
            gap = 0.2rem 0.5rem
        .studio-header .status-txt:
            grid-row = 2
            grid-column = 1 / -1
            padding = 0
        .studio-header .btn-fullscreen:
            grid-row = 1
            grid-column = 2
        .studio-workspace:
            grid-template-columns = minmax(0, 1fr)
        .studio-tracks .voice-tabs:
            grid-template-columns = repeat(4, minmax(0, 1fr))
        .studio-tracks .voice-tab:
            padding = 0.35rem
        .studio-tracks .voice-sound:
            font-size = 0.62rem
            overflow = hidden
            text-overflow = ellipsis
        .transport-bar:
            gap = 0.35rem 0.65rem
        .mode-controls:
            margin-left = 0
        .song-selector:
            padding = 0.55rem
        .piano-roll-container:
            overflow-x = auto
            padding-bottom = 0.5rem
        .step-strip-scroll:
            padding-bottom = 0.5rem
        .piano-key:
            min-width = 38px
            height = 90px
        .drum-pads:
            grid-template-columns = repeat(3, 1fr)

    (max-width: 480px):
        .studio-cabinet:
            padding = 0.45rem
        .song-title-label .ctrl-label, .tracks-heading, .editor-tools, .tempo-controls .ctrl-label, .ruler-hint:
            display = none
        .studio-cabinet:
            gap = 0.4rem
        .studio-tracks, .note-editor-panel:
            padding = 0.45rem
        .transport-buttons:
            gap = 0.25rem
        .btn-transport-seek:
            min-width = 26px
            padding = 0 0.28rem
        .btn-tempo:
            width = 30px
            height = 32px
        .bpm-badge:
            min-width = 64px
            font-size = 0.95rem
        .tempo-controls:
            gap = 0.35rem
        .instrument-picker:
            width = 100%
            flex-wrap = nowrap
            overflow-x = auto
            padding-bottom = 0.12rem
        .instrument-picker button:
            flex-shrink = 0
            padding-inline = 0.48rem
        .ruler-header-row .bar-tab:
            margin-left = auto
        .timeline-ruler, .piano-matrix-rack:
            padding = 0.45rem
        .song-open:
            width = 90px
        .song-actions .btn-storage:
            letter-spacing = 0
        .bar-actions .btn-bar-action:
            padding = 0.38rem 0.45rem
            white-space = nowrap
            font-size = 0.7rem
        .btn-transport:
            padding = 0.4rem 0.7rem
            font-size = 0.78rem
        .btn-storage:
            font-size = 0.72rem
            padding = 0.35rem 0.55rem
        .ruler-bars:
            gap = 0.15rem
        .ruler-bar-item:
            padding = 0.3rem 0.1rem
        .ruler-bar-num:
            font-size = 0.63rem
        .matrix-keys-column:
            width = 52px

Appuyez sur Espace pour lire ou mettre en pause. Faites glisser la tête de lecture à l’arrêt et superposez des notes dans une colonne pour former un accord.

Comment fonctionne cet exemple

🎹 Synthétiseur Chiptune Web Audio

Écoutez des ondes carrées, basses triangulaires et percussions bruit blanc en temps réel avec enveloppes ADSR et fréquences configurables.

🎼 Séquenceur Multipiste Visuel

Composez mélodies principales, arpèges, basses pulsées et percussions avec notation mesure par mesure et tempo ajustable.

💾 Enregistrer et restaurer un arrangement

SAVE et LOAD conservent vos arrangements dans ce navigateur et les partagent entre la vue intégrée et l’onglet autonome. Export .rune télécharge une copie.

⚡ Exporter votre morceau

EXPORT .RUNE télécharge le code @Music du morceau, distinct de l’application Studio complète et de ses fichiers sources.

Comment utiliser

🎵 Choisissez un morceau et appuyez sur Espace pour le lire ou le mettre en pause. Utilisez les flèches du transport pour changer de mesure. Modifiez les notes dans le piano roll et suivez la lecture dans la vue STRIP.

💾 Choisissez New Song pour créer un arrangement vide, nommez-le et utilisez Save. Open song affiche les arrangements enregistrés et les préréglages. Export .rune télécharge une copie.

Exécuter localement

Pour exécuter l’exemple complet, installez Vectrune et Git. Clonez le dépôt une fois et conservez le dossier parts avec le fichier principal.

Démarrage rapide
git clone https://github.com/davethomas11/vectrune.git
cd vectrune

Exécutez ces commandes à la racine du dépôt. Si vous avez déjà une copie, ouvrez simplement un terminal à sa racine.

vectrune examples/rune-web/studio/rune_studio.rune
vectrune examples/rune-web/studio/rune_studio.rune -o html > rune_studio.html
Site entièrement créé avec Rune-Web