Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
FP11c: a note's Reading, the readings' agreement and a label's span move to raea-sys-fingerprint-use (reading.rs), keeping raea-app-fingerprint under its 2,000 lines; sound_band finds its box without a copied closure
shinyobjectze85de83289aa
diff --git a/apps/fingerprint/src/notes.rs b/apps/fingerprint/src/notes.rsindex 6899c926..5424fe26 100644--- a/apps/fingerprint/src/notes.rs+++ b/apps/fingerprint/src/notes.rs@@ -12,47 +12,13 @@use crate::{flag, has, words};use raea_sys_fingerprint::folder::Folder;use raea_sys_fingerprint::taxonomy::Fingerprint;-use serde::{Deserialize, Serialize};+pub use raea_sys_fingerprint_use::reading::{Reading, agreement, earned};+use raea_sys_fingerprint_use::reading::span;use serde_json::{Value, json};use std::path::{Path, PathBuf};-/// FP5b's bar, out of every 50 checked-pub const KIND_BAR: f64 = 45.0 / 50.0;-pub const AXIS_BAR: f64 = 40.0 / 50.0;pub const INBOX: &str = "fingerprint";-#[derive(Clone, Debug, Default, Serialize, Deserialize)]-pub struct Reading {- pub note: String,- pub text: String,- pub who: String,- pub media: PathBuf,- pub t: f64,- pub project: String,- /// defect, direction, praise or both- pub kind: String,- pub axis: Option<String>,- /// how it was read: kimi or claude- pub by: String,- /// the person's check: Some(true) agreed, Some(false) not; None until asked- #[serde(default)]- pub kind_ok: Option<bool>,- #[serde(default)]- pub axis_ok: Option<bool>,- /// a span pin's end: the label covers t..to (FP11b)- #[serde(default, skip_serializing_if = "Option::is_none")]- pub to: Option<f64>,- /// where in the frame the note's marks say the thing is, x0,y0,x1,y1 in 0-1 (FP11b)- #[serde(default, skip_serializing_if = "Option::is_none")]- pub region: Option<[f32; 4]>,- /// the layers under the pin's x,y in the layer pass, on a render with one (FP5a)- #[serde(default, skip_serializing_if = "Vec::is_empty")]- pub layers: Vec<String>,- /// a box on the sound's spectrogram: its pitch band, 0-1 of the mel scale (FP11c); its time is t..to- #[serde(default, skip_serializing_if = "Option::is_none")]- pub band: Option<[f32; 2]>,-}-/// A post's video on this machine: the renders library, else the project's own folderfn media(project: &Path, m: &Value) -> Option<PathBuf> {@@ -204,18 +170,6 @@ pub(crate) fn read_here(args: &[String], cwd: &Path) -> i32 {}}-/// The share of checked readings the person agreed with, for kind and for axis, and how many were checked-pub fn agreement(r: &[Reading]) -> (Option<f64>, Option<f64>, usize) {- let share = |v: Vec<bool>| (!v.is_empty()).then(|| v.iter().filter(|x| **x).count() as f64 / v.len() as f64);- let checked = r.iter().filter(|x| x.kind_ok.is_some()).count();- (share(r.iter().filter_map(|x| x.kind_ok).collect()), share(r.iter().filter_map(|x| x.axis_ok).collect()), checked)-}--/// Whether the readings have earned training (FP5b): 50 checked, the kind right 45 times and the axis 40-pub fn earned(r: &[Reading]) -> bool {- matches!(agreement(r), (Some(k), Some(a), n) if n >= 50 && k >= KIND_BAR && a >= AXIS_BAR)-}-/// The choices a reading is checked with, and what each says about kind and axispub const CHOICES: [(&str, bool, bool); 4] = [("Right", true, true), ("Right kind, wrong axis", true, false), ("Wrong kind", false, false), ("Right axis, wrong kind", false, true)];@@ -321,17 +275,6 @@ pub(crate) fn learn(enc: &mut raea_sys_columns::Encoders, dir: &Folder, l: &mutOk(format!("{made} notes are evidence now (defects and praise; directions stay with the brief)\n"))}-/// A span pin's label: t..to inside the piece, widened about its middle to half a second when it's shorter (a box on a-/// click of sound)-fn span(t: f64, to: f64, dur: f64) -> (f64, f64) {- let (a, b) = (t.max(0.0), to.min(dur));- if b - a >= 0.5 {- return (a, b);- }- let mid = ((a + b) / 2.0).clamp(0.25, (dur - 0.25).max(0.25));- ((mid - 0.25).max(0.0), (mid + 0.25).min(dur))-}-#[cfg(test)]mod tests {use super::*;@@ -362,23 +305,4 @@ mod tests {assert_eq!(r.len(), 1);assert_eq!((r[0].t, r[0].to, r[0].band, r[0].region), (2.0, Some(4.0), Some([0.6, 0.9]), None));}-- #[test]- fn a_span_is_the_label_and_a_short_one_is_widened() {- assert_eq!(span(2.0, 4.0, 10.0), (2.0, 4.0));- let (a, b) = span(2.0, 2.1, 10.0);- assert!((a - 1.8).abs() < 1e-9 && (b - 2.3).abs() < 1e-9, "a box on a click of sound is half a second about it: {a}..{b}");- assert_eq!(span(9.9, 10.0, 10.0), (9.5, 10.0), "kept inside the piece");- }-- #[test]- fn notes_train_only_once_the_person_agrees_enough() {- let r = |k: bool, a: bool| Reading { kind_ok: Some(k), axis_ok: Some(a), ..Default::default() };- let mut v: Vec<Reading> = (0..45).map(|_| r(true, true)).collect();- v.extend((0..5).map(|_| r(false, false)));- assert!(earned(&v), "45 and 45 of 50");- v[0] = r(false, true);- assert!(!earned(&v), "44 kinds of 50 is under the bar");- assert!(!earned(&v[..40]), "fewer than 50 checked");- }}diff --git a/systems/fingerprint-use/src/grow.rs b/systems/fingerprint-use/src/grow.rsindex 6d33b1f4..f5aa3152 100644--- a/systems/fingerprint-use/src/grow.rs+++ b/systems/fingerprint-use/src/grow.rs@@ -207,7 +207,8 @@ pub fn marked(pin: &serde_json::Value) -> Option<[f32; 4]> {/// The pitch band of a box drawn on the sound's spectrogram (FP11c), low and high in 0-1 of the mel scale: its points are/// [time, pitch], and its time is the pin's own t..topub fn sound_band(pin: &serde_json::Value) -> Option<[f32; 2]> {- let m = pin["marks"].as_array()?.iter().find(|m| m["on"] == "sound" && m["kind"] == "box")?;+ let mut boxes = pin["marks"].as_array()?.iter().filter(|m| m["kind"] == "box");+ let m = boxes.find(|m| m["on"].as_str() == Some("sound"))?;let p: Vec<f32> = m["points"].as_array()?.iter().filter_map(|p| p[1].as_f64()).map(|v| v.clamp(0.0, 1.0) as f32).collect();let (lo, hi) = (p.iter().copied().fold(f32::INFINITY, f32::min), p.iter().copied().fold(f32::NEG_INFINITY, f32::max));(p.len() == 2 && hi > lo).then_some([lo, hi])diff --git a/systems/fingerprint-use/src/lib.rs b/systems/fingerprint-use/src/lib.rsindex e4ca5140..0f18bbe1 100644--- a/systems/fingerprint-use/src/lib.rs+++ b/systems/fingerprint-use/src/lib.rs@@ -8,12 +8,14 @@//! - fixed.rs: a fix checked against the flag it claims to fix, and against the axis's disguises (FP9a)//! - postmortem.rs: a project looked back on, its least sure moments asked as yes/no questions (FP7a)//! - grow.rs: a note's mark grown into its thing and tracked over its label by EdgeTAM (FP11b)+//! - reading.rs: a note's reading, its check, and the span and band a label takes from it (FP5b, FP11c)pub mod diff;pub mod fixed;pub mod grow;pub mod patch;pub mod postmortem;+pub mod reading;pub mod profile;pub mod realness;pub mod score;diff --git a/systems/fingerprint-use/src/reading.rs b/systems/fingerprint-use/src/reading.rsnew file mode 100644index 00000000..2fe5c54a--- /dev/null+++ b/systems/fingerprint-use/src/reading.rs@@ -0,0 +1,92 @@+//! A note's reading (docs/fingerprint.feature FP5a, FP5b): what a fresh agent session read a person's pinned note as+//! (a kind and an axis), the person's check of it, and where it points: its moment or span, its marks' region in the+//! frame (FP11b) and its box's pitch band on the sound (FP11c). Notes train only once the person has agreed with+//! enough readings; raea-app-fingerprint's notes.rs reads them, puts them to the person and learns from them.++use serde::{Deserialize, Serialize};+use std::path::PathBuf;++/// FP5b's bar, out of every 50 checked+pub const KIND_BAR: f64 = 45.0 / 50.0;+pub const AXIS_BAR: f64 = 40.0 / 50.0;++#[derive(Clone, Debug, Default, Serialize, Deserialize)]+pub struct Reading {+ pub note: String,+ pub text: String,+ pub who: String,+ pub media: PathBuf,+ pub t: f64,+ pub project: String,+ /// defect, direction, praise or both+ pub kind: String,+ pub axis: Option<String>,+ /// how it was read: kimi or claude+ pub by: String,+ /// the person's check: Some(true) agreed, Some(false) not; None until asked+ #[serde(default)]+ pub kind_ok: Option<bool>,+ #[serde(default)]+ pub axis_ok: Option<bool>,+ /// a span pin's end: the label covers t..to (FP11b)+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub to: Option<f64>,+ /// where in the frame the note's marks say the thing is, x0,y0,x1,y1 in 0-1 (FP11b)+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub region: Option<[f32; 4]>,+ /// the layers under the pin's x,y in the layer pass, on a render with one (FP5a)+ #[serde(default, skip_serializing_if = "Vec::is_empty")]+ pub layers: Vec<String>,+ /// a box on the sound's spectrogram: its pitch band, 0-1 of the mel scale (FP11c); its time is t..to+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub band: Option<[f32; 2]>,+}++++/// The share of checked readings the person agreed with, for kind and for axis, and how many were checked+pub fn agreement(r: &[Reading]) -> (Option<f64>, Option<f64>, usize) {+ let share = |v: Vec<bool>| (!v.is_empty()).then(|| v.iter().filter(|x| **x).count() as f64 / v.len() as f64);+ let checked = r.iter().filter(|x| x.kind_ok.is_some()).count();+ (share(r.iter().filter_map(|x| x.kind_ok).collect()), share(r.iter().filter_map(|x| x.axis_ok).collect()), checked)+}++/// Whether the readings have earned training (FP5b): 50 checked, the kind right 45 times and the axis 40+pub fn earned(r: &[Reading]) -> bool {+ matches!(agreement(r), (Some(k), Some(a), n) if n >= 50 && k >= KIND_BAR && a >= AXIS_BAR)+}++/// A span pin's label: t..to inside the piece, widened about its middle to half a second when it's shorter (a box on a+/// click of sound)+pub fn span(t: f64, to: f64, dur: f64) -> (f64, f64) {+ let (a, b) = (t.max(0.0), to.min(dur));+ if b - a >= 0.5 {+ return (a, b);+ }+ let mid = ((a + b) / 2.0).clamp(0.25, (dur - 0.25).max(0.25));+ ((mid - 0.25).max(0.0), (mid + 0.25).min(dur))+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn a_span_is_the_label_and_a_short_one_is_widened() {+ assert_eq!(span(2.0, 4.0, 10.0), (2.0, 4.0));+ let (a, b) = span(2.0, 2.1, 10.0);+ assert!((a - 1.8).abs() < 1e-9 && (b - 2.3).abs() < 1e-9, "a box on a click of sound is half a second about it: {a}..{b}");+ assert_eq!(span(9.9, 10.0, 10.0), (9.5, 10.0), "kept inside the piece");+ }++ #[test]+ fn notes_train_only_once_the_person_agrees_enough() {+ let r = |k: bool, a: bool| Reading { kind_ok: Some(k), axis_ok: Some(a), ..Default::default() };+ let mut v: Vec<Reading> = (0..45).map(|_| r(true, true)).collect();+ v.extend((0..5).map(|_| r(false, false)));+ assert!(earned(&v), "45 and 45 of 50");+ v[0] = r(false, true);+ assert!(!earned(&v), "44 kinds of 50 is under the bar");+ assert!(!earned(&v[..40]), "fewer than 50 checked");+ }+}