- the quest giver's dialog and the quest log are the reference's own `QuestFrame.xml` and `QuestLogFrame.xml`, run off the player's chain at the reference's own toc seats; our 1366-line and 1999-line copies are deleted, and the verbs the stock files call are built — the four `GameTooltip` quest-item and reward-spell setters, the reward spell itself (parsed on all three packets and dropped by the model until now), and two verbs; the detail pane could never scroll because `UpdateScrollChildRect` measured a frame late where the reference's measure is synchronous, so it measures through the installed font engine now; and ten things the reference does that ours did not, each found by a test that had enshrined ours — a shift-click never selects, an empty log hides the whole detail pane and says "No Active Quests", the abandon confirm lives in the popup registry (1944) - the quest bindings' law, read off the binary and folded back: no 1.12 packet carries a quest background material — `GetQuestBackgroundMaterial` (`0x502230`) forks on the dialog's SOURCE object, an item answering its template's PageMaterial, a GameObject its template data, a creature nil (FrameXML's "Parchment"), the id naming a `PageTextMaterial.dbc` row whose six words are nowhere in the binary; its twin `ItemTextGetMaterial` has the same body, so the reader window already held every piece and the giver's feed runs the same resolve; `QuestChooseRewardError` is game-error row `0x98`, and the row plays `igQuestFailed` first, which the verb now queues; the reward-spell getters' third return is `Spell.dbc` Attributes bit 5 (1161 of 22357 rows set — craft-cast spells set, `Pattern:` teaching spells clear), read off the catalog now (1946) - the "20 ms frames" of a raid, chased to their number: the probe's worst frames now carry their churn (entities, assets, first-play sound decodes, live particles, the GPU reading) and in a Blackrock raid with sound on every one of those read flat; then the same window on the PACED clock — under vsync with pipelined rendering the raw delta is mis-split into long/short pairs that sum to exact refresh multiples, so an alone Stormwind leg read 115 of 300 frames over budget with cpu and gpu both at their means, while the paced clock read 0 skipped frames in every leg; what remains real in the raid is `cpu_p99` at 22–23 ms with sound on; and every submesh the streamer spawns now carries why it is an entity, counted per reason — 5.8k resident ADT-doodad submeshes at the Stormwind auction house, 5.3k of them hidden, three prop families the retained pass declines by rule, each riding every per-`Mesh3d` sweep for ~0.4 ms of the alone frame (1947) - a raid's dozen voices cost the mixer ~1.5 ms of every 60 Hz frame: upstream kira spatializes every frame — normalizes, the attenuation curve and a dB→amplitude `powf` per frame per spatial track, two more `powf`s for the volume tween, ~1.7 M `powf`s a second at 48 kHz × 12 tracks for gains that change imperceptibly across a chunk — so kira 0.12.1 is vendored with one patch: the spatial gains and the volume × fade amplitude are evaluated at the chunk's two ends and interpolated across its ~10.7 ms, the granularity FMOD 3, the reference's own mixer, updates them at; nothing a listener can name changes (1945); and rig poses are evaluated in parallel over rigs — each reads its shared clips and writes only its own pose, and a raid's ~400 live rigs were 0.4 ms of one thread walked serially on the main thread's critical path (1947) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
156 lines
3.9 KiB
Rust
156 lines
3.9 KiB
Rust
use std::{
|
|
f32::consts::SQRT_2,
|
|
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},
|
|
};
|
|
|
|
use crate::Panning;
|
|
|
|
/// A stereo audio sample.
|
|
#[derive(Debug, Copy, Clone, PartialEq, Default)]
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
pub struct Frame {
|
|
/// The sample for the left channel.
|
|
pub left: f32,
|
|
/// The sample for the right channel.
|
|
pub right: f32,
|
|
}
|
|
|
|
impl Frame {
|
|
/// A [`Frame`] with both the left and right samples
|
|
/// set to `0.0`.
|
|
pub const ZERO: Frame = Frame {
|
|
left: 0.0,
|
|
right: 0.0,
|
|
};
|
|
|
|
/// Creates a frame with the given left and right values.
|
|
#[must_use]
|
|
pub fn new(left: f32, right: f32) -> Self {
|
|
Self { left, right }
|
|
}
|
|
|
|
/// Creates a frame with both the left and right channels set
|
|
/// to the same value.
|
|
#[must_use]
|
|
pub fn from_mono(value: f32) -> Self {
|
|
Self::new(value, value)
|
|
}
|
|
|
|
/// Pans a frame to the left or right.
|
|
///
|
|
/// A panning of -1.0 represents a hard left panning, a panning of 1.0
|
|
/// represents a hard right panning.
|
|
#[allow(clippy::float_cmp)]
|
|
#[must_use = "This method returns a new Frame and does not mutate the original value"]
|
|
pub fn panned(self, panning: Panning) -> Self {
|
|
// adding a special case for center panning improves
|
|
// performance in the sound playback benchmarks by
|
|
// about 3%
|
|
if panning == Panning::CENTER {
|
|
return self;
|
|
}
|
|
let panning = panning.0.clamp(-1.0, 1.0);
|
|
let left_right_mix = (panning + 1.0) * 0.5;
|
|
Self::new(
|
|
self.left * (1.0 - left_right_mix).sqrt(),
|
|
self.right * left_right_mix.sqrt(),
|
|
) * SQRT_2
|
|
}
|
|
|
|
/// Returns the frame mixed down to mono.
|
|
#[must_use = "This method returns a new Frame and does not mutate the original value"]
|
|
pub fn as_mono(self) -> Self {
|
|
Self::from_mono((self.left + self.right) / 2.0)
|
|
}
|
|
}
|
|
|
|
impl Add for Frame {
|
|
type Output = Self;
|
|
|
|
fn add(self, rhs: Self) -> Self::Output {
|
|
Self::new(self.left + rhs.left, self.right + rhs.right)
|
|
}
|
|
}
|
|
|
|
impl AddAssign for Frame {
|
|
fn add_assign(&mut self, rhs: Self) {
|
|
self.left += rhs.left;
|
|
self.right += rhs.right;
|
|
}
|
|
}
|
|
|
|
impl Sub for Frame {
|
|
type Output = Self;
|
|
|
|
fn sub(self, rhs: Self) -> Self::Output {
|
|
Self::new(self.left - rhs.left, self.right - rhs.right)
|
|
}
|
|
}
|
|
|
|
impl SubAssign for Frame {
|
|
fn sub_assign(&mut self, rhs: Self) {
|
|
self.left -= rhs.left;
|
|
self.right -= rhs.right;
|
|
}
|
|
}
|
|
|
|
impl Mul<f32> for Frame {
|
|
type Output = Self;
|
|
|
|
fn mul(self, rhs: f32) -> Self::Output {
|
|
Self::new(self.left * rhs, self.right * rhs)
|
|
}
|
|
}
|
|
|
|
impl MulAssign<f32> for Frame {
|
|
fn mul_assign(&mut self, rhs: f32) {
|
|
self.left *= rhs;
|
|
self.right *= rhs;
|
|
}
|
|
}
|
|
|
|
impl Div<f32> for Frame {
|
|
type Output = Self;
|
|
|
|
fn div(self, rhs: f32) -> Self::Output {
|
|
Self::new(self.left / rhs, self.right / rhs)
|
|
}
|
|
}
|
|
|
|
impl DivAssign<f32> for Frame {
|
|
fn div_assign(&mut self, rhs: f32) {
|
|
self.left /= rhs;
|
|
self.right /= rhs;
|
|
}
|
|
}
|
|
|
|
impl Neg for Frame {
|
|
type Output = Self;
|
|
|
|
fn neg(self) -> Self::Output {
|
|
Self::new(-self.left, -self.right)
|
|
}
|
|
}
|
|
|
|
/// Given a previous frame, a current frame, the two next frames,
|
|
/// and a position `x` from 0.0 to 1.0 between the current frame
|
|
/// and next frame, get an approximated frame.
|
|
// This is the 4-point, 3rd-order Hermite interpolation x-form
|
|
// algorithm from "Polynomial Interpolators for High-Quality
|
|
// Resampling of Oversampled Audio" by Olli Niemitalo, p. 43:
|
|
// http://yehar.com/blog/wp-content/uploads/2009/08/deip.pdf
|
|
#[must_use]
|
|
pub fn interpolate_frame(
|
|
previous: Frame,
|
|
current: Frame,
|
|
next_1: Frame,
|
|
next_2: Frame,
|
|
fraction: f32,
|
|
) -> Frame {
|
|
let c0 = current;
|
|
let c1 = (next_1 - previous) * 0.5;
|
|
let c2 = previous - current * 2.5 + next_1 * 2.0 - next_2 * 0.5;
|
|
let c3 = (next_2 - previous) * 0.5 + (current - next_1) * 1.5;
|
|
((c3 * fraction + c2) * fraction + c1) * fraction + c0
|
|
}
|