mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b90ee0728c | ||
|
|
5eb8b1e40e | ||
|
|
bce27988ab | ||
|
|
c02a02d902 | ||
|
|
b26da1cc95 | ||
|
|
cf0282f550 |
No files matched your search
Generated
-11
@@ -16436,22 +16436,11 @@ 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"
|
||||
|
||||
@@ -86,7 +86,6 @@ members = [
|
||||
"systems/tone",
|
||||
"systems/mix",
|
||||
"systems/mix/level",
|
||||
"systems/mix/device",
|
||||
"systems/ml",
|
||||
"systems/mlx",
|
||||
"systems/kimodo",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! 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}, time::SystemTime};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::SystemTime;
|
||||
|
||||
use raea_core_brief::make::{self, Make};
|
||||
use raea_core_facts::{Level, record::Entry};
|
||||
@@ -187,11 +188,10 @@ pub fn status(job: &Job) -> Value {
|
||||
}
|
||||
let mut gates = checks(job);
|
||||
gates.extend(lods(job, ¬es));
|
||||
// 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) {
|
||||
(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)),
|
||||
// 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))),
|
||||
_ => gates.extend(critic(job, newest, ¬es)),
|
||||
}
|
||||
let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, ¬es);
|
||||
|
||||
@@ -318,13 +318,3 @@ 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,
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
---
|
||||
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.
|
||||
@@ -10,8 +10,14 @@ use std::path::Path;
|
||||
use raea_core_brief::cut::{self, Cut, norm};
|
||||
use serde_json::Value;
|
||||
|
||||
/// One gate as `raea make status` lists it (a goal's are the same kind)
|
||||
pub use raea_core_brief::make::Gate;
|
||||
/// 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,
|
||||
}
|
||||
|
||||
fn gate(name: &'static str, of: Option<&str>, clear: bool, says: String) -> Gate {
|
||||
Gate { name, of: of.map(str::to_string), clear, says }
|
||||
@@ -186,10 +192,7 @@ 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();
|
||||
// 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 (best, heard_share) = lines.iter().map(|l| (*l, share(l, &last))).fold(("", 0.0), |a, b| if b.1 > a.1 { b } else { a });
|
||||
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) {
|
||||
|
||||
@@ -12,8 +12,14 @@ 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 (a cut's are the same kind): `of` is the rule it's about
|
||||
pub use raea_core_brief::make::Gate;
|
||||
/// 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,
|
||||
}
|
||||
|
||||
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: 98de983bca...ae1c222713.
@@ -9,8 +9,6 @@ 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" }
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
[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"] }
|
||||
@@ -1,130 +0,0 @@
|
||||
//! 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))
|
||||
}
|
||||
+113
-22
@@ -7,15 +7,16 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use cpal::traits::StreamTrait;
|
||||
use audioadapter_buffers::direct::InterleavedSlice;
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use firewheel::backend::BackendProcessInfo;
|
||||
use firewheel::clock::{EventInstant, InstantSamples};
|
||||
use firewheel::node::NodeID;
|
||||
use firewheel::{FirewheelConfig, FirewheelContext};
|
||||
use raea_sys_mix_device::Output;
|
||||
use firewheel::node::{NodeID, StreamStatus};
|
||||
use firewheel::{ActivateInfo, FirewheelConfig, FirewheelContext};
|
||||
|
||||
use crate::nodes::{Stats, event};
|
||||
use raea_io_media::pcm::Pcm;
|
||||
@@ -35,8 +36,13 @@ 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, followed when the system's output changes (raea-sys-mix-device)
|
||||
out: Output,
|
||||
/// 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,
|
||||
voices: NodeID,
|
||||
master: NodeID,
|
||||
score: Option<Score>,
|
||||
@@ -87,7 +93,8 @@ 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 (out, stream, rate) = Output::open(&mut cx, RATE, block)?;
|
||||
let lost = Arc::new(AtomicBool::new(false));
|
||||
let (stream, rate, device) = start(&mut cx, block, lost.clone())?;
|
||||
if rate != RATE {
|
||||
eprintln!("raea mixer: the device runs at {rate} Hz, not {RATE}: live play can't be the bounce sample for sample");
|
||||
}
|
||||
@@ -99,7 +106,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), 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 })
|
||||
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 })
|
||||
}
|
||||
|
||||
/// The master: `gain_db` on the sum, then the limiter at `ceiling_db` (dBTP).
|
||||
@@ -352,22 +359,48 @@ 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) {
|
||||
if !self.out.moved() {
|
||||
let lost = self.lost.load(Ordering::Relaxed);
|
||||
if !lost && self.looked.elapsed() < std::time::Duration::from_secs(1) {
|
||||
return;
|
||||
}
|
||||
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.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();
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -432,6 +465,64 @@ 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 };
|
||||
|
||||
@@ -55,7 +55,6 @@ 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"
|
||||
@@ -169,7 +168,6 @@ 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"
|
||||
@@ -296,8 +294,6 @@ 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
|
||||
|
||||
@@ -18,12 +18,9 @@ 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. 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)
|
||||
# hold them to the candidate's binaries, so newer skills go out on a candidate's binaries
|
||||
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/layers.sh' ':(exclude)tools/layers.toml' ':(exclude)tools/layers.allow')
|
||||
':(exclude)tools/release' ':(exclude)tools/agents' ':(exclude)tools/raea-app' ':(exclude)skills' ':(exclude)docs')
|
||||
|
||||
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[@]}"; }
|
||||
|
||||
Reference in new issue
Block a user