Compare commits

..
13 Commits
Author SHA1 Message Date
shinyobjectz f4db12c1d0 CI's size and dupes gates on 0.1.11: the mixer's output device (the stream and following the system's output) in its own crate, raea-sys-mix-device, so raea-sys-mix is under 2000 lines and live.rs under 500; one make::Gate in raea-core-brief for a cut's and a goal's gates (cut-plan and goal-plan had the same struct, and status.rs the same closure twice); the CTA's best line found without a copy of hands-audit's fold 2026-11-26 17:26:59 -08:00
shinyobjectz cd159fe0be promoted-from: the layers gate's files (tools/layers.sh, layers.toml, layers.allow) may differ between an rc and its release, as no build reads them (0.1.11-rc2's one-line layers fix would otherwise force a rebuild) 2026-11-26 16:57:39 -08:00
shinyobjectz 316b612d70 layers: raea-runtime-goal-plan is in the runtime layer (MK28's crate had none, and main's CI gates failed on it from c41ec580 on) 2026-11-26 16:57:08 -08:00
shinyobjectz aa40a2fa86 #82: the ARM64 build (it compiles: raea.exe is AA64 and runs) is packed and checked without drawing (release-check.sh RAEA_CHECK_NO_GPU=1 keeps plugins, guides, song map and bin\'s files; the windows-11-arm runner has only WARP, which segfaults in Bevy as on x64, and lavapipe has no ARM64 build), and it uses the release's compile cache 2026-11-26 14:01:28 -08:00
shinyobjectz 48705982b6 windows-arm.yml runs on v* tags too, beside release.yml, and attaches raea-VERSION-windows-arm64.zip to that release (skills-passed from the tag, as release.yml reads it); an ARM64 failure never holds up the release 2026-11-26 14:01:28 -08:00
shinyobjectz 7580433cd2 windows-arm.yml: metis-sys alone on windows-latest's x64 MSVC too, which release.yml builds with 2026-11-26 14:01:28 -08:00
shinyobjectz 28f3fd814b #82: metis-sys vendored with GKlib's stdint.h/inttypes.h stand-ins only before Visual Studio 2013 (Visual Studio 18's stdint.h types int_fast16_t differently, and the windows-11-arm build failed on every GKlib file); its graphs, manual and programs left out 2026-11-26 14:01:28 -08:00
shinyobjectz 1905dc723c #82: a windows-arm64 zip: RAEA_WIN_ARCH=arm64 has onnxruntime.sh and win-bundle.sh take the ARM64 runtime, VC++ CRT, uv and DXC (FFmpeg stays x64, run emulated), release.sh names and packs raea-VERSION-windows-arm64.zip, and windows-arm.yml packs and checks it on WARP 2026-11-26 14:01:28 -08:00
shinyobjectz c41dd64516 #82: raea built natively for Windows on ARM in CI (windows-arm.yml on windows-11-arm: the release's four binaries, raea --version, a 2D still on WARP); rav1d's assembly off there, where MSVC skips its GNU .S files 2026-11-26 14:01:28 -08:00
shinyobjectz 1fc3a07655 Merge branch 'whats-new-0111' 2026-11-26 14:01:28 -08:00
shinyobjectz 986bd33463 whats-new 0.1.11: goals as make jobs, live sound following the output, tall pictures (#245), Windows on ARM (#82), and in the app typed Ideate on your own agent, one Settings, voice with Studio, Codex on Windows (#244) 2026-11-26 14:01:27 -08:00
shane c41ec580a9 Merge pull request #246 from shinyobjectz/skills-0111
skills: CLI reference for 0.1.11
2026-11-26 11:23:26 -08:00
shane 7e25dcc56e skills: the CLI reference as 0.1.11 prints it (raea-skills 98de983: make judge, make status's goal kind) 2026-11-26 11:23:10 -08:00
14 changed files with 296 additions and 138 deletions

No files matched your search

Generated
+11
View File
@@ -16436,11 +16436,22 @@ dependencies = [
"raea-io-home",
"raea-io-media",
"raea-io-trace",
"raea-sys-mix-device",
"raea-sys-mix-level",
"raea-sys-tone",
"serde_json",
]
[[package]]
name = "raea-sys-mix-device"
version = "0.1.0"
dependencies = [
"audioadapter-buffers",
"cpal 0.15.3",
"firewheel",
"raea-io-trace",
]
[[package]]
name = "raea-sys-mix-level"
version = "0.1.0"
+1
View File
@@ -86,6 +86,7 @@ members = [
"systems/tone",
"systems/mix",
"systems/mix/level",
"systems/mix/device",
"systems/ml",
"systems/mlx",
"systems/kimodo",
+5 -5
View File
@@ -1,8 +1,7 @@
//! Whether a job is done (docs/make.feature MK1), from what's on disk and nothing the agent says: the deliverables, the
//! notes, the record of renders and checks, and the judge's rounds. Pure over a `Job` so it is tested on fixtures.
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use std::{path::{Path, PathBuf}, time::SystemTime};
use raea_core_brief::make::{self, Make};
use raea_core_facts::{Level, record::Entry};
@@ -188,10 +187,11 @@ pub fn status(job: &Job) -> Value {
}
let mut gates = checks(job);
gates.extend(lods(job, &notes));
// a cut job: its brief's rules over every delivered file (MK25-MK27), and the person's review its critic; a goal's
let plan = |g: make::Gate| gate(g.name, g.of.as_deref(), g.clear, g.says);
match (&job.make.cut, job.make.kind) {
// a cut job: its brief's rules over every delivered file (MK25-MK27), and the person's review its critic
(Some(c), make::Kind::Cut) => gates.extend(raea_runtime_cut_plan::gates(c, job.dir).into_iter().map(|g| gate(g.name, g.of.as_deref(), g.clear, g.says))),
(_, make::Kind::Goal) => gates.extend(job.make.goal.iter().flat_map(|g| raea_runtime_goal_plan::gates(g, job.dir)).map(|g| gate(g.name, g.of.as_deref(), g.clear, g.says))),
(Some(c), make::Kind::Cut) => gates.extend(raea_runtime_cut_plan::gates(c, job.dir).into_iter().map(plan)),
(_, make::Kind::Goal) => gates.extend(job.make.goal.iter().flat_map(|g| raea_runtime_goal_plan::gates(g, job.dir)).map(plan)),
_ => gates.extend(critic(job, newest, &notes)),
}
let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, &notes);
+10
View File
@@ -318,3 +318,13 @@ pub fn doctor(m: &Make) -> Vec<String> {
}
out
}
/// One gate as `raea make status` lists it: its name, the file, item or rule it's about, whether it's clear, and what
/// it says. A cut's gates come from raea-runtime-cut-plan, a goal's from raea-runtime-goal-plan.
#[derive(Debug, Clone, PartialEq)]
pub struct Gate {
pub name: &'static str,
pub of: Option<String>,
pub clear: bool,
pub says: String,
}
+81
View File
@@ -0,0 +1,81 @@
---
title: "raea 0.1.11"
version: "0.1.11"
date: "2026-11-26"
summary: "A goal is a make job, judged by its own commands and a fresh critic. Live sound follows your output device, a picture taller than the GPU's largest texture draws, and Windows on ARM gets raea's installer and its own build. In the app, typing to Ideate answers with your own agent, there is one Settings page, and voice comes with Studio."
sources: ["https://github.com/shinyobjectz/raea/releases/tag/v0.1.11"]
---
raea 0.1.11 makes a goal something `raea make` holds an agent to: the goal's own commands and a critic that only
reads decide when it's done, never the agent's word. Live sound now follows the output you're listening on, a very
tall picture draws instead of being refused, and Windows on ARM PCs get raea's installer and a build of their own. In
the app, typing to Ideate answers with the agent you connected, Settings are one page, and talking with Ideate comes
with Studio.
**Get the app at [raea.io](https://raea.io)** (a Mac with Apple silicon, Windows 10 or 11, or Linux on x86_64).
The engine alone:
```sh
curl -fsSL https://raea.io/install | sh
```
On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`.
## What changed since 0.1.10
**A goal is a make job.** Besides scenes, kits, shots and cuts, `make: goal({...})` in `brief.ts` is a fifth kind of
job (MK28-MK29). Its rules are commands that must pass and things it must say, and `raea make judge` has a fresh
critic, which only reads, judge each `says` rule into `review/goal.judge.json`. `raea make status` is the one judge
of whether the goal is met.
**Cuts from a brief rotate their call to action.** A `cut` brief's `cta.also` lists the other lines a brief rotates,
and each cut ends on one of them within its last 8 seconds (MK25).
**Live sound follows your output.** When the system's output changes (headphones, AirPods, a display) or the stream
breaks, live sound reopens on the device in use instead of going quiet.
**A tall picture draws (#245).** A picture larger than the GPU's image atlas (a 1080 x 18000 site capture drawn 880
wide) was refused with a message about a filtered layer. It is now decoded at a size that fits the atlas, which is
16384 px a side even on a GPU that allows larger textures.
**Windows on ARM (#82).**
- `irm https://raea.io/install.ps1 | iex` installs on an ARM64 PC: raea's ARM64 build when the release has one, else
the x86_64 build, which Windows 11 on ARM runs emulated. Before, the installer refused ARM64 PCs.
- raea is built natively for Windows on ARM (`raea-0.1.11-windows-arm64.zip`) when its build passes, beside the
release's other archives.
- On a Snapdragon PC, raea picks DirectX 12 for its Adreno GPU, where Vulkan drew 2D pages striped and with grey boxes
behind fading text.
**In the app.**
- Typing to Ideate answers with your own agent (Claude, Codex, or whichever you connected), named on screen while it
thinks, and the conversation stays open instead of fading after a few seconds. raea's own voice model is only for
speaking.
- Talking with Ideate comes with Studio (300 minutes a month) and Enterprise (no limit). Free and Pro type.
- Settings are one page: your workspace's sections, then this computer's (account, plan, sharing, general, storage
and debugging), searched together.
- Signing out on the Mac's workspace signs raea's account out, and the menu names the account you're in.
- A review's player starts with sound, and remembers if you turn it off.
- Every project has a canvas: deliverables, previews and the brief's frames, marked with a region or a point and a
`#tag`, sent back as a note or as edits.
- On Windows, Codex's shell commands run (#244). Codex's elevated sandbox waited on a Windows prompt or failed every
call with "The tool call failed"; raea now starts it with Windows' unelevated sandbox, unless you set your own.
**raea cloud.**
- Boxes move onto each new release, and each box build is stamped with the commit and files it came from.
- An agent's errors go into its run's trace, a runaway render is stopped before it takes the box down, and an agent
waiting on a long render keeps its connection.
- A render sends a project's footage once, known by the file rather than its path.
- `raea words` on a box transcribes with Whisper large-v3, and `raea frames check` measures what a cut's pictures get
wrong (faces cut off, split frames that make no sense).
- Google's AI signs in on the box, in a browser you work from the dashboard.
**Known**
- The Windows on ARM build is checked in CI without drawing: GitHub's ARM64 runner has no GPU raea can draw on. A
Snapdragon PC is where its pictures are checked. If something looks wrong, the x86_64 build still runs there, and
`WGPU_BACKEND=vulkan` or `dx12` chooses the graphics API by hand.
- The Windows app is unsigned, as before: Windows asks once whether to run it (#221).
- On Linux, raea needs a processor with AVX (most from 2011 on) and glibc 2.39 or newer (Ubuntu 24.04, Debian 13,
Fedora 40 and later).
- A proxy set by an automatic configuration (PAC) file isn't read. If yours uses one, start raea with `HTTPS_PROXY`
set.
+6 -9
View File
@@ -10,14 +10,8 @@ use std::path::Path;
use raea_core_brief::cut::{self, Cut, norm};
use serde_json::Value;
/// One gate as `raea make status` lists it: its name, the file or item it's about, whether it's clear, what it says.
#[derive(Debug, Clone, PartialEq)]
pub struct Gate {
pub name: &'static str,
pub of: Option<String>,
pub clear: bool,
pub says: String,
}
/// One gate as `raea make status` lists it (a goal's are the same kind)
pub use raea_core_brief::make::Gate;
fn gate(name: &'static str, of: Option<&str>, clear: bool, says: String) -> Gate {
Gate { name, of: of.map(str::to_string), clear, says }
@@ -192,7 +186,10 @@ fn file_gates(c: &Cut, plan: &cut::CutPlan, format: &str, f: &Path, rel: &str, s
in_order(&want, &j.iter().map(|(w, _)| w.as_str()).collect::<Vec<_>>())
};
let lines: Vec<&str> = std::iter::once(cta.text.as_str()).chain(cta.also.iter().map(String::as_str)).collect();
let (best, heard_share) = lines.iter().map(|l| (*l, share(l, &last))).fold(("", 0.0), |a, b| if b.1 > a.1 { b } else { a });
// the line heard most, the first of equals (none when no line's words were heard)
let heard: Vec<_> = lines.iter().map(|l| share(l, &last)).collect();
let heard_share = heard.iter().copied().fold(0.0, f64::max);
let best = lines.iter().zip(&heard).find(|(_, h)| heard_share > 0.0 && **h == heard_share).map_or("", |(l, _)| *l);
let on_screen = screen.iter().any(|(s, at)| *at >= end - within && lines.iter().any(|l| share(l, &s.split(' ').collect::<Vec<_>>()) >= CTA_SHARE));
let ok = heard_share >= CTA_SHARE || on_screen;
let says = match (ok, on_screen) {
+2 -8
View File
@@ -12,14 +12,8 @@ use std::time::{Duration, Instant, SystemTime};
use raea_core_brief::goal::Goal;
use serde_json::{Value, json};
/// One gate as `raea make status` lists it: its name, the rule it's about, whether it's clear, what it says.
#[derive(Debug, Clone, PartialEq)]
pub struct Gate {
pub name: &'static str,
pub of: Option<String>,
pub clear: bool,
pub says: String,
}
/// One gate as `raea make status` lists it (a cut's are the same kind): `of` is the rule it's about
pub use raea_core_brief::make::Gate;
fn gate(name: &'static str, of: &str, clear: bool, says: String) -> Gate {
Gate { name, of: Some(of.to_string()), clear, says }
+1 -1
Submodule skills updated: ae1c222713...98de983bca.
+2
View File
@@ -9,6 +9,8 @@ description = "raea's one mixer core: the same Firewheel graph plays live in the
[dependencies]
# the mix before the master: dialogue at one level, room tone at the joins
raea-sys-mix-level = { path = "level" }
# the system's output: the stream live play runs in, moved onto the device in use
raea-sys-mix-device = { path = "device" }
raea-io-trace = { path = "../../io/trace" }
# the bounce's scratch file, as the frames come (SG4a)
raea-io-home = { path = "../../io/home" }
+16
View File
@@ -0,0 +1,16 @@
[package]
name = "raea-sys-mix-device"
version = "0.1.0"
edition = "2024"
license = "FSL-1.1-ALv2"
publish = false
description = "raea's mixer on the system's output: Firewheel's processor driven from cpal's callback, and moved onto the device in use when the output changes or the stream breaks"
[dependencies]
raea-io-trace = { path = "../../../io/trace" }
# the mixer's graph, as raea-sys-mix pins it
firewheel = { version = "=0.12.1", default-features = false, features = ["std", "scheduled_events"] }
# the cpal react and the legacy app use (0.15): Firewheel's own CPAL backend needs 0.18, which can't link beside 0.15
cpal = "0.15"
# the processor's output, pulled into a stereo buffer
audioadapter-buffers = { version = "4.0.0", default-features = false, features = ["std"] }
+130
View File
@@ -0,0 +1,130 @@
//! The mixer's output: the system's default device, with Firewheel's processor pulled from cpal's callback, followed
//! when the system's output changes (headphones in, AirPods away, a display's speakers) or cpal says the stream broke
//! (11-26, Shane: "sometimes i dont hear any sound": the stream stayed on the device it opened on, gone or not the one
//! being listened to).
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, Instant};
use audioadapter_buffers::direct::InterleavedSlice;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
pub use cpal::Stream;
use firewheel::backend::BackendProcessInfo;
use firewheel::node::StreamStatus;
use firewheel::{ActivateInfo, FirewheelContext};
/// The output a mixer plays on: the device's name (empty while there's none), the rate and block size it asks for,
/// and whether cpal said the stream broke.
pub struct Output {
pub name: String,
rate: u32,
block: u32,
lost: Arc<AtomicBool>,
looked: Instant,
}
impl Output {
/// The default device's stream, and the rate it runs at (`rate` when the device takes it).
pub fn open(cx: &mut FirewheelContext, rate: u32, block: u32) -> Result<(Output, Stream, u32), String> {
let lost = Arc::new(AtomicBool::new(false));
let (stream, got, name) = start(cx, rate, block, lost.clone())?;
Ok((Output { name, rate, block, lost, looked: Instant::now() }, stream, got))
}
/// Whether the stream should move: at once after cpal said it broke, else when the system's default output, looked
/// at once a second, is another device.
pub fn moved(&mut self) -> bool {
let lost = self.lost.load(Ordering::Relaxed);
if !lost && self.looked.elapsed() < Duration::from_secs(1) {
return false;
}
self.looked = Instant::now();
let now = cpal::default_host().default_output_device().and_then(|d| d.name().ok()).unwrap_or_default();
lost || (!now.is_empty() && now != self.name)
}
/// The stream started again on the default device: `old` is let go first, which hands the graph back (its
/// processor dropped). The new stream and its rate, or no device to play on (looked for again in a second).
pub fn reopen(&mut self, cx: &mut FirewheelContext, old: Option<Stream>) -> Result<(Stream, u32), String> {
drop(old);
let t0 = Instant::now();
while cx.is_active() && t0.elapsed() < Duration::from_millis(500) {
let _ = cx.update();
std::thread::sleep(Duration::from_millis(1));
}
self.lost.store(false, Ordering::Relaxed);
match start(cx, self.rate, self.block, self.lost.clone()) {
Ok((stream, rate, name)) => {
eprintln!("raea mixer: sound now on {name} (was {})", if self.name.is_empty() { "nothing" } else { &self.name });
self.name = name;
Ok((stream, rate))
}
Err(e) => {
if !self.name.is_empty() {
eprintln!("raea mixer: no sound: {e}");
}
self.name.clear();
Err(e)
}
}
}
}
/// The default output device, at `want` Hz when it takes it, `block` frames a callback when it takes that: Firewheel's
/// processor pulled from cpal's callback, as the bounce pulls it into a buffer (stereo, spread over the device's
/// channels).
fn start(cx: &mut FirewheelContext, want: u32, block: u32, lost: Arc<AtomicBool>) -> Result<(Stream, u32, String), String> {
let host = cpal::default_host();
let dev = host.default_output_device().ok_or("no audio output device")?;
let name = dev.name().unwrap_or_default();
let def = dev.default_output_config().map_err(|e| format!("audio output: {e}"))?;
let channels = def.channels();
let takes_48k = dev.supported_output_configs().map(|mut c| c.any(|r| r.channels() == channels && r.sample_format() == cpal::SampleFormat::F32 && r.min_sample_rate().0 <= want && r.max_sample_rate().0 >= want)).unwrap_or(false);
let rate = if takes_48k { want } else { def.sample_rate().0 };
let max_block = 8192usize;
let mut proc = cx
.activate(ActivateInfo { sample_rate: std::num::NonZeroU32::new(rate).unwrap(), max_block_frames: std::num::NonZeroU32::new(max_block as u32).unwrap(), num_stream_in_channels: 0, num_stream_out_channels: 2, input_to_output_latency_seconds: 0.0 })
.map_err(|e| format!("the mixer's graph: {e:?}"))?;
let ch = channels as usize;
let began = std::time::Instant::now();
let mut stereo = vec![0f32; max_block * 2];
let empty: [f32; 0] = [];
let mut callback = move |out: &mut [f32], info: &cpal::OutputCallbackInfo| {
let ts = info.timestamp();
let delay = ts.playback.duration_since(&ts.callback);
let frames = out.len() / ch.max(1);
let mut done = 0;
while done < frames {
let k = (frames - done).min(max_block);
let pi = BackendProcessInfo { frames: k, process_timestamp: Some(std::time::Instant::now()), duration_since_stream_start: began.elapsed(), input_stream_status: StreamStatus::empty(), output_stream_status: StreamStatus::empty(), dropped_frames: 0, process_to_playback_delay: delay };
if let (Ok(input), Ok(mut output)) = (InterleavedSlice::new(&empty[..], 0, 0), InterleavedSlice::new_mut(&mut stereo[..k * 2], 2, k)) {
proc.process(&input, &mut output, pi);
}
for i in 0..k {
let (l, r) = (stereo[2 * i], stereo[2 * i + 1]);
let o = &mut out[(done + i) * ch..(done + i + 1) * ch];
match ch {
1 => o[0] = 0.5 * (l + r),
_ => {
o[0] = l;
o[1] = r;
o[2..].fill(0.0);
}
}
}
done += k;
}
};
// the block size when the device's range takes it, else its own
let fits = dev.supported_output_configs().map(|mut c| c.any(|r| r.channels() == channels && matches!(r.buffer_size(), cpal::SupportedBufferSize::Range { min, max } if *min <= block && block <= *max))).unwrap_or(false);
let config = cpal::StreamConfig { channels, sample_rate: cpal::SampleRate(rate), buffer_size: if fits { cpal::BufferSize::Fixed(block) } else { cpal::BufferSize::Default } };
let mut said = raea_io_trace::once::said_once::<cpal::StreamError>("raea mixer");
let broke = move |e: cpal::StreamError| {
lost.store(true, Ordering::Relaxed);
said(e)
};
let stream = dev.build_output_stream(&config, move |o: &mut [f32], i: &cpal::OutputCallbackInfo| callback(o, i), broke, None).map_err(|e| format!("audio stream: {e}"))?;
stream.play().map_err(|e| format!("audio stream: {e}"))?;
Ok((stream, rate, name))
}
+22 -113
View File
@@ -7,16 +7,15 @@
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::Ordering;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::sync::{Arc, Mutex};
use audioadapter_buffers::direct::InterleavedSlice;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use firewheel::backend::BackendProcessInfo;
use cpal::traits::StreamTrait;
use firewheel::clock::{EventInstant, InstantSamples};
use firewheel::node::{NodeID, StreamStatus};
use firewheel::{ActivateInfo, FirewheelConfig, FirewheelContext};
use firewheel::node::NodeID;
use firewheel::{FirewheelConfig, FirewheelContext};
use raea_sys_mix_device::Output;
use crate::nodes::{Stats, event};
use raea_io_media::pcm::Pcm;
@@ -36,13 +35,8 @@ pub struct Live {
cx: FirewheelContext,
/// the device's stream: None for the moment it's reopened on another device (follow_device)
_stream: Option<cpal::Stream>,
/// the output it plays on (its name), the block size it was asked for, and whether cpal said the stream broke
/// (the device unplugged, its AirPods put away): the stage follows the system's output (11-26, Shane: "sometimes i
/// dont hear any sound": the stream stayed on the device it opened on, gone or not the one being listened to)
device: String,
block: u32,
lost: Arc<AtomicBool>,
looked: std::time::Instant,
/// the output it plays on, followed when the system's output changes (raea-sys-mix-device)
out: Output,
voices: NodeID,
master: NodeID,
score: Option<Score>,
@@ -93,8 +87,7 @@ impl Live {
let mut cx = FirewheelContext::new(FirewheelConfig::default());
let (voices, master) = crate::graph(&mut cx, stats.clone(), tap.as_ref().map(|t| t.1.clone()), mute)?;
let block = std::env::var("RAEA_AUDIO_BLOCK").ok().and_then(|v| v.parse().ok()).unwrap_or(256u32);
let lost = Arc::new(AtomicBool::new(false));
let (stream, rate, device) = start(&mut cx, block, lost.clone())?;
let (out, stream, rate) = Output::open(&mut cx, RATE, block)?;
if rate != RATE {
eprintln!("raea mixer: the device runs at {rate} Hz, not {RATE}: live play can't be the bounce sample for sample");
}
@@ -106,7 +99,7 @@ impl Live {
// a device opened beside the edit's open waits for nothing by then
Ok(Live {
opened: std::time::Instant::now(),
settled: false, cx, _stream: Some(stream), device, block, lost, looked: std::time::Instant::now(), voices, master, score: None, pcm: HashMap::new(), opening: HashMap::new(), loader: raea_io_media::pcm::loader(), rate, head, head_base: head, origin: None, drift_ms: Vec::new(), anchors: Vec::new(), slews: 0, load_ms: Vec::new(), load_wait: std::time::Duration::from_millis(std::env::var("RAEA_AUDIO_LOAD_WAIT_MS").ok().and_then(|v| v.parse().ok()).unwrap_or(80)), used: HashMap::new(), items: Vec::new(), keep: HashMap::new(), blocks: Vec::new(), master_set: (0.0, 20.0 * (crate::nodes::CEILING as f64).log10()), bypass: false, resting: false, built: Default::default(), stats, tap })
settled: false, cx, _stream: Some(stream), out, voices, master, score: None, pcm: HashMap::new(), opening: HashMap::new(), loader: raea_io_media::pcm::loader(), rate, head, head_base: head, origin: None, drift_ms: Vec::new(), anchors: Vec::new(), slews: 0, load_ms: Vec::new(), load_wait: std::time::Duration::from_millis(std::env::var("RAEA_AUDIO_LOAD_WAIT_MS").ok().and_then(|v| v.parse().ok()).unwrap_or(80)), used: HashMap::new(), items: Vec::new(), keep: HashMap::new(), blocks: Vec::new(), master_set: (0.0, 20.0 * (crate::nodes::CEILING as f64).log10()), bypass: false, resting: false, built: Default::default(), stats, tap })
}
/// The master: `gain_db` on the sum, then the limiter at `ceiling_db` (dBTP).
@@ -359,48 +352,22 @@ impl Live {
/// old one is let go, which hands the graph back (its processor dropped), and it starts again on the new device. The
/// timeline is placed again on the next frame, as after a rest.
fn follow_device(&mut self) {
let lost = self.lost.load(Ordering::Relaxed);
if !lost && self.looked.elapsed() < std::time::Duration::from_secs(1) {
if !self.out.moved() {
return;
}
self.looked = std::time::Instant::now();
let now = cpal::default_host().default_output_device().and_then(|d| d.name().ok()).unwrap_or_default();
if !lost && (now.is_empty() || now == self.device) {
return;
}
// the old stream and its callback go, and the processor in it: the context is free to start again
self._stream = None;
let t0 = std::time::Instant::now();
while self.cx.is_active() && t0.elapsed() < std::time::Duration::from_millis(500) {
let _ = self.cx.update();
std::thread::sleep(std::time::Duration::from_millis(1));
}
self.lost.store(false, Ordering::Relaxed);
match start(&mut self.cx, self.block, self.lost.clone()) {
Ok((stream, rate, device)) => {
eprintln!("raea mixer: sound now on {device} (was {})", if self.device.is_empty() { "nothing" } else { &self.device });
if rate != self.rate {
// the head and the score count samples: both at the new device's rate
self.head_base = (self.head_base as f64 * rate as f64 / self.rate as f64).round() as i64;
self.rate = rate;
self.score = None;
}
self._stream = Some(stream);
self.device = device;
self.resting = false;
self.origin = None;
self.settled = false;
self.opened = std::time::Instant::now();
let _ = self.cx.update();
}
// no device to play on (none plugged in): looked for again in a second
Err(e) => {
if !self.device.is_empty() {
eprintln!("raea mixer: no sound: {e}");
}
self.device.clear();
}
let Ok((stream, rate)) = self.out.reopen(&mut self.cx, self._stream.take()) else { return };
if rate != self.rate {
// the head and the score count samples: both at the new device's rate
self.head_base = (self.head_base as f64 * rate as f64 / self.rate as f64).round() as i64;
self.rate = rate;
self.score = None;
}
self._stream = Some(stream);
self.resting = false;
self.origin = None;
self.settled = false;
self.opened = std::time::Instant::now();
let _ = self.cx.update();
}
/// The device stream stopped (after stop_all and its fade-outs: nothing is heard): no callback runs, so neither the
@@ -465,64 +432,6 @@ impl Live {
}
}
/// The default output device, at 48 kHz when it takes it, `block` frames a callback when it takes that: Firewheel's
/// processor pulled from cpal's callback, as the bounce pulls it into a buffer (stereo, spread over the device's
/// channels).
fn start(cx: &mut FirewheelContext, block: u32, lost: Arc<AtomicBool>) -> Result<(cpal::Stream, u32, String), String> {
let host = cpal::default_host();
let dev = host.default_output_device().ok_or("no audio output device")?;
let name = dev.name().unwrap_or_default();
let def = dev.default_output_config().map_err(|e| format!("audio output: {e}"))?;
let channels = def.channels();
let takes_48k = dev.supported_output_configs().map(|mut c| c.any(|r| r.channels() == channels && r.sample_format() == cpal::SampleFormat::F32 && r.min_sample_rate().0 <= RATE && r.max_sample_rate().0 >= RATE)).unwrap_or(false);
let rate = if takes_48k { RATE } else { def.sample_rate().0 };
let max_block = 8192usize;
let mut proc = cx
.activate(ActivateInfo { sample_rate: std::num::NonZeroU32::new(rate).unwrap(), max_block_frames: std::num::NonZeroU32::new(max_block as u32).unwrap(), num_stream_in_channels: 0, num_stream_out_channels: 2, input_to_output_latency_seconds: 0.0 })
.map_err(|e| format!("the mixer's graph: {e:?}"))?;
let ch = channels as usize;
let began = std::time::Instant::now();
let mut stereo = vec![0f32; max_block * 2];
let empty: [f32; 0] = [];
let mut callback = move |out: &mut [f32], info: &cpal::OutputCallbackInfo| {
let ts = info.timestamp();
let delay = ts.playback.duration_since(&ts.callback);
let frames = out.len() / ch.max(1);
let mut done = 0;
while done < frames {
let k = (frames - done).min(max_block);
let pi = BackendProcessInfo { frames: k, process_timestamp: Some(std::time::Instant::now()), duration_since_stream_start: began.elapsed(), input_stream_status: StreamStatus::empty(), output_stream_status: StreamStatus::empty(), dropped_frames: 0, process_to_playback_delay: delay };
if let (Ok(input), Ok(mut output)) = (InterleavedSlice::new(&empty[..], 0, 0), InterleavedSlice::new_mut(&mut stereo[..k * 2], 2, k)) {
proc.process(&input, &mut output, pi);
}
for i in 0..k {
let (l, r) = (stereo[2 * i], stereo[2 * i + 1]);
let o = &mut out[(done + i) * ch..(done + i + 1) * ch];
match ch {
1 => o[0] = 0.5 * (l + r),
_ => {
o[0] = l;
o[1] = r;
o[2..].fill(0.0);
}
}
}
done += k;
}
};
// the block size when the device's range takes it, else its own
let fits = dev.supported_output_configs().map(|mut c| c.any(|r| r.channels() == channels && matches!(r.buffer_size(), cpal::SupportedBufferSize::Range { min, max } if *min <= block && block <= *max))).unwrap_or(false);
let config = cpal::StreamConfig { channels, sample_rate: cpal::SampleRate(rate), buffer_size: if fits { cpal::BufferSize::Fixed(block) } else { cpal::BufferSize::Default } };
let mut said = raea_io_trace::once::said_once::<cpal::StreamError>("raea mixer");
let broke = move |e: cpal::StreamError| {
lost.store(true, Ordering::Relaxed);
said(e)
};
let stream = dev.build_output_stream(&config, move |o: &mut [f32], i: &cpal::OutputCallbackInfo| callback(o, i), broke, None).map_err(|e| format!("audio stream: {e}"))?;
stream.play().map_err(|e| format!("audio stream: {e}"))?;
Ok((stream, rate, name))
}
impl Drop for Live {
fn drop(&mut self) {
let Some((path, buf)) = self.tap.take() else { return };
+4
View File
@@ -55,6 +55,7 @@ raea-core-ask = "core"
raea-sys-k = "systems"
raea-sys-mix = "systems"
raea-sys-mix-level = "systems"
raea-sys-mix-device = "systems"
raea-sys-tone = "systems"
raea-seedling = "systems"
raea-sys-ml = "systems"
@@ -168,6 +169,7 @@ raea-runtime-twins = "runtime"
raea-runtime-dom = "runtime"
raea-runtime-dom-media = "runtime"
raea-runtime-edit = "runtime"
raea-runtime-goal-plan = "runtime"
raea-runtime-input = "runtime"
raea-runtime-bake = "runtime"
raea-runtime-bundle = "runtime"
@@ -294,6 +296,8 @@ raea-sys-rt = true
raea-sys-mix = true
# the mix before the master: dialogue at one level, room tone at the joins (the mix masters what it gives)
raea-sys-mix-level = true
# the mixer's output: the device stream live play runs in, followed when the system's output changes
raea-sys-mix-device = true
raea-sys-tone = true
raea-sys-ml = true
raea-sys-mlx = true
+5 -2
View File
@@ -18,9 +18,12 @@ die() { echo "promoted-from: $*" >&2; exit 1; }
# tests include tools/release.sh and an sdk/guides page, and tests aren't in a release build). The skills (skills/, the
# raea-skills pin) and docs/ are read by no build either (11-11, Shane: "promote skills to the latest possible"):
# release.sh packs the skills the release's commit pins, and the skills gate (its skills-passed line) and check-cli
# hold them to the candidate's binaries, so newer skills go out on a candidate's binaries
# hold them to the candidate's binaries, so newer skills go out on a candidate's binaries. The layers gate's files
# (tools/layers.sh and its layers.toml) are read by CI's check of the crate graph only (11-26: 0.1.11-rc2's commit failed
# CI on a crate with no layer, and the one-line fix would have forced a rebuild)
SAME=(':(exclude)README.md' ':(exclude).github' ':(exclude)tools/release.sh' ':(exclude)tools/release-check.sh' ':(exclude)tools/release-appimage.sh'
':(exclude)tools/release' ':(exclude)tools/agents' ':(exclude)tools/raea-app' ':(exclude)skills' ':(exclude)docs')
':(exclude)tools/release' ':(exclude)tools/agents' ':(exclude)tools/raea-app' ':(exclude)skills' ':(exclude)docs'
':(exclude)tools/layers.sh' ':(exclude)tools/layers.toml' ':(exclude)tools/layers.allow')
fetch_tag() { git cat-file -e "refs/tags/$1" 2>/dev/null || git fetch -q --depth=1 origin "refs/tags/$1:refs/tags/$1"; }
differ() { git diff --name-only "$1^{commit}" "$2^{commit}" -- . "${SAME[@]}"; }