feature: pure volume model, graph state reducer and view model

Cubic percent <-> linear channelVolumes conversions (pavucontrol scale,
up to 150%), dB formatting, balance-preserving linked slider, a reducer
applying WirePlumber node/link/default events and per-tab view rows,
all covered by moon tests that run on any target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-22 21:59:55 +00:00
1 parent 13a1de9b2c
commit 7b2b45067f
10 files changed
+1027

No files matched your search

+137
View File
@@ -0,0 +1,137 @@
// Generated using `moon info`, DON'T EDIT IT
package "geordi/moonmix/model"
import {
"moonbitlang/core/debug",
}
// Values
pub const MAX_PERCENT : Double = 150.0
pub const NORM_PERCENT : Double = 100.0
pub fn clamp_percent(Double) -> Double
pub fn diff_rows(Array[Row], Array[Row]) -> Diff
pub fn display_title(Node) -> String
pub fn format_db(Double) -> String
pub fn format_percent(Double) -> String
pub fn format_volume(Array[Double]) -> String
pub fn linear_to_db(Double) -> Double?
pub fn linear_to_percent(Double) -> Double
pub fn linked_percent(Array[Double]) -> Double
pub fn percent_to_linear(Double) -> Double
pub fn rows(State, Tab) -> Array[Row]
pub fn scale_linked(Array[Double], Double) -> Array[Double]
pub fn should_apply_remote(Int64, Int64, window_us? : Int64) -> Bool
// Errors
// Types and methods
#derive(Eq, @debug.Debug)
pub(all) struct DeviceChoice {
id : Int32
name : String
label : String
}
#derive(Eq, @debug.Debug)
pub(all) struct Diff {
removed : Array[Int32]
added : Array[Int32]
updated : Array[Int32]
}
#derive(@debug.Debug)
pub(all) enum Event {
Upsert(Node)
Remove(Int32)
Links(Array[Link])
Defaults(sink~ : Int32, source~ : Int32)
Reset
}
#derive(Eq, @debug.Debug)
pub(all) struct Link {
output_node : Int32
input_node : Int32
}
#derive(Eq, @debug.Debug)
pub(all) struct Node {
id : Int32
name : String
description : String
media_class : String
app_name : String
media_name : String
icon_name : String
volumes : Array[Double]
mute : Bool
}
pub fn Node::kind(Self) -> NodeKind
pub fn Node::new(Int32, String, name? : String, description? : String, app_name? : String, media_name? : String, icon_name? : String, volumes? : Array[Double], mute? : Bool) -> Self
#derive(Eq, @debug.Debug)
pub(all) enum NodeKind {
Sink
Source
PlaybackStream
RecordStream
Other
}
pub fn NodeKind::from_media_class(String) -> Self
#derive(Eq, @debug.Debug)
pub(all) struct Row {
id : Int32
title : String
subtitle : String
icon_name : String
volumes : Array[Double]
percent : Double
volume_text : String
mute : Bool
has_volume : Bool
is_default : Bool
choices : Array[DeviceChoice]
current_choice : Int32
}
pub(all) struct State {
nodes : Map[Int32, Node]
mut links : Array[Link]
mut default_sink : Int32
mut default_source : Int32
}
pub fn State::apply(Self, Event) -> Bool
pub fn State::new() -> Self
pub fn State::nodes_of(Self, NodeKind) -> Array[Node]
pub fn State::stream_device(Self, Int32) -> Int32?
#derive(Eq, @debug.Debug)
pub(all) enum Tab {
Playback
Recording
OutputDevices
InputDevices
}
pub fn Tab::all() -> Array[Self]
pub fn Tab::empty_text(Self) -> String
pub fn Tab::label(Self) -> String
pub fn Tab::node_kind(Self) -> NodeKind
// Type aliases
// Traits