Add render-time color transforms and audio-reactive hooks - #24
Open
avillagran wants to merge 5 commits into
Open
Add render-time color transforms and audio-reactive hooks#24avillagran wants to merge 5 commits into
avillagran wants to merge 5 commits into
Conversation
…lti-strike) Implements the Effect::on_audio reference implementation on thunderstorm: - Loud passages / detected beats trigger lightning strikes on the beat - Strike count scales with volume (1..10 thin rays), branches per ray capped at 5 for user-controlled jaggedness - Strike fall speed (batch/delay) follows volume for punchy drops - Loop the storm phase continuously so external supervisors (background rotators) control lifetime without a visible fade-out/fade-in seam
Apply opt-in transforms when cached visuals are emitted so embedders can update colors without rebuilding effects. Preserve indexed xterm output, keep fast paths for disabled/colorless visuals, and make callbacks reentrant-safe. Restore byte-identical non-audio thunderstorm behavior, deduplicate its audio strike setup, use an O(1) pending queue, and smoke-test every registered effect, high-volume audio, live cache changes, xterm colors, and callback reentrancy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two opt-in embedding hooks for applications that drive TTFX as a library:
Live color transforms
set_color_transform(Option<ColorTransform>)for current-thread render control.CharacterVisuals are emitted, so palette changes are visible on the next frame without rebuilding an effect.38;5/48;5output in xterm mode.Rcsnapshotting and an owned pooled scratch buffer, so callbacks may replace themselves or construct nested visuals withoutRefCellborrow panics.This hook is intentionally policy-free. The embedder decides which colors are semantic and which are theme accents.
Audio hook
Adds a default no-op method to
Effect:The built-in CLI has no audio source and does not invoke it. Embedders call it immediately before
next_frame.Thunderstorm uses the hook to:
The audio strike path reuses the ordinary flash/fade setup and uses
VecDequefor queued rays.Tests and verification
cargo test --all-targets: pass.origin/master(sha256 860c234f451a005ed5c953eeec41647a3a604d5040d7e2e163ae9e4c6cbaa964).No behavior changes unless an embedder explicitly installs a transform or calls
on_audio.