P1a: material import, sixteen faces, sample engine and quarry

This commit is contained in:
Emil
2026-11-01 00:56:51 +03:00
parent db4368efae
commit ebdeca3b92
28 changed files with 2799 additions and 114 deletions
+113 -7
View File
@@ -79,6 +79,46 @@ pub enum Actor {
System,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Seal {
Found,
Taken,
Gift,
Loan,
Unknown,
}
/// A face of a core, as the wire sees it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FaceSummary {
pub index: u8,
/// 0 is the loudest face.
pub rank: u8,
pub start_sec: f32,
pub end_sec: f32,
pub rms: f32,
}
/// A core in the archive, without the samples themselves.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CoreSummary {
pub id: String,
pub name: String,
pub seal: Seal,
pub sample_rate: u32,
pub duration_sec: f32,
pub faces: Vec<FaceSummary>,
/// Normalised waveform envelope for the quarry, roughly 1400 bins.
pub peaks: Vec<f32>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct FaceRef {
pub core: String,
pub face: u8,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ClientMessage {
@@ -91,6 +131,12 @@ pub enum ClientMessage {
id: u64,
command: Command,
},
/// The next binary frame is the encoded audio for this import.
ImportCore {
id: u64,
name: String,
seal: Seal,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
@@ -113,6 +159,10 @@ pub enum ServerMessage {
id: u64,
result: CommandResult,
},
Imported {
id: u64,
core: CoreSummary,
},
Error {
id: Option<u64>,
code: ErrorCode,
@@ -126,9 +176,37 @@ pub enum Command {
GetSnapshot,
Play,
Stop,
Strike { vein: VeinId, velocity: f32 },
SetTempo { bpm: f32 },
SetVeinGain { vein: VeinId, gain: f32 },
Strike {
vein: VeinId,
velocity: f32,
},
StrikeFace {
core: String,
face: u8,
velocity: f32,
},
SetTempo {
bpm: f32,
},
SetVeinGain {
vein: VeinId,
gain: f32,
},
SetPatternStep {
row: u8,
step: u8,
velocity: u8,
},
SetPatternFace {
row: u8,
core: String,
face: u8,
},
/// Journal-only: a core was imported through the binary path.
ImportCore {
name: String,
seal: Seal,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
@@ -141,10 +219,35 @@ pub enum CommandResult {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum Event {
Transport { playing: bool },
Tempo { bpm: f32 },
VeinGain { vein: VeinId, gain: f32 },
Struck { vein: VeinId, velocity: f32 },
Transport {
playing: bool,
},
Tempo {
bpm: f32,
},
VeinGain {
vein: VeinId,
gain: f32,
},
Struck {
vein: VeinId,
velocity: f32,
},
PatternStep {
row: u8,
step: u8,
velocity: u8,
},
PatternFace {
row: u8,
core: String,
face: u8,
},
FaceStruck {
core: String,
face: u8,
velocity: f32,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -184,6 +287,7 @@ pub struct State {
pub transport: TransportState,
pub veins: Vec<VeinState>,
pub pattern: Pattern,
pub cores: Vec<CoreSummary>,
pub audio: AudioInfo,
pub journal_len: usize,
}
@@ -219,6 +323,8 @@ impl Pattern {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PatternRow {
pub vein: VeinId,
/// None keeps the procedural voice for this vein; Some plays a face.
pub face: Option<FaceRef>,
/// One velocity per step, 0..=127. Zero means the step is empty.
pub velocities: Vec<u8>,
}