Skip to content

feat(tui): bring back the pitch visualizer - #759

Merged
LargeModGames merged 1 commit into
mainfrom
feat/analysis-view
Oct 12, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
feat/analysis-view

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Second half: the Spotify Pitch view on the analysis screen, drawn from the audio analysis that #758 fetches.

  • While a Spotify track plays, v opens Spotify Pitch: the 12 pitch classes (C to B) of the segment playing now, with a row of note names, and the tempo, key and time signature of the current section with their confidence. Every other source opens on the saved capture style, as before. "Spotify track" means what plays now, so it also works when Spotify plays on another Connect device.
  • It looks and moves like Cava: the 12 values glide between segments, are scaled by the segment's loudness envelope (-40 dB empty, 0 dB full), and feed the same render_cava renderer through a small meter that rises in about 30 ms and falls with gravity. My first versions drew the raw data and looked jumpy; this is the version I tested and kept.
  • A local clock moves the position on between the native player's 1 s PositionChanged updates, and blends a correction under 1 s in over 400 ms, so the bars do not jump each second. A seek still applies at once.
  • V cycles Cava, Bar Graph and Spotify Pitch while a Spotify track plays. Pitch is never written to config.yml, so the config stays readable by older releases, and leaving Pitch with V holds until the screen is opened again. Audio capture is closed while Pitch shows.
  • The analysis stays while its track plays, so the help overlay or leaving the screen does not fetch it again.
  • Compared with the old spotify-tui view: the bars show the segment playing now instead of the next one, the last section no longer blanks the screen, and an undetected key shows "?" instead of C.

Testing

  • cargo fmt --all -- --check: ok
  • cargo clippy -- -D warnings, and the same with --no-default-features --features telemetry,tui, telemetry, and telemetry,gui,streaming,discord-rpc,self-update,scripting,mcp-server,mpris: all Finished
  • cargo test --no-default-features --features telemetry,tui: test result: ok. 1502 passed; 0 failed; 0 ignored
  • cargo test: test result: ok. 1950 passed; 0 failed; 6 ignored
  • Manual on Windows with native streaming: Pitch opens for a Spotify track, V cycles through the three styles, a Qobuz track opens on Cava. A temporary log probe (not committed) confirmed that the clock moves 16 ms per frame between position updates.

Additional notes

Stacked on #758. Not covered: the GUI frontend has no analysis screen, so it never asks for an analysis. The view needs no audio capture, so it also works in builds without audio-viz.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • New Features
    • Added a Spotify Pitch visualizer that shows pitch-class levels for the current section, along with tempo, key, time signature, and confidence.
    • Press v during Spotify playback to open Spotify Pitch. Press V to cycle among Cava, Bar Graph, and Spotify Pitch; other audio sources continue to use the saved visualizer style.
    • Pitch levels now respond to playback timing, and the view displays distinct states when analysis is loading, unavailable, or unsuccessful.
  • Documentation
    • Updated the feature guide and changelog with Spotify Pitch controls and details.

@LargeModGames
LargeModGames added this pull request to stack #760 October 12, 2026 09:33
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3e8f2198-e9e5-4ebb-a8ed-1a40b2fb918e

📥 Commits

Reviewing files that changed from the base of the PR and between 19da7a9 and 0ae9d3d.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b53a717-222d-446e-92b1-760851802a0e

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba3b37 and 19da7a9.


📒 Files selected for processing (12)
  • CHANGELOG.md
  • README.md
  • docs/roadmap.md
  • src/core/app/audio_analysis.rs
  • src/core/app/construction.rs
  • src/core/app/mod.rs
  • src/core/app/route.rs
  • src/core/app/settings_apply.rs
  • src/core/app/view.rs
  • src/core/driver/mod.rs
  • src/core/driver/plan.rs
  • src/tui/ui/audio_analysis.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The audio-analysis screen now offers a Spotify Pitch view with pitch-class bars and current-section metadata. The app synchronizes Spotify analysis with playback and provides controls to switch between the pitch view and configured visualizer styles.

Changes

Spotify Pitch View

Layer / File(s) Summary
Pitch data and playback state
src/core/app/mod.rs, src/core/app/construction.rs, src/core/app/audio_analysis.rs
App state now tracks Spotify playback, an analysis clock, and pitch levels. Pitch utilities interpolate segment data, select sections, format key labels, and update pitch levels over time. Tests cover interpolation, section selection, clock behavior, and pitch-level transitions.
Playback synchronization and view selection
src/core/driver/plan.rs, src/core/driver/mod.rs, src/core/app/audio_analysis.rs, src/core/app/view.rs, src/core/app/route.rs, src/core/app/settings_apply.rs
The driver identifies eligible Spotify track IDs and synchronizes analysis with playback. Routing and visualizer cycling control pitch-view visibility. Tests cover track selection, analysis state, and style cycling.
Pitch view rendering and documentation
src/tui/ui/audio_analysis.rs, README.md, CHANGELOG.md, docs/roadmap.md
The screen renders pitch bars, note labels, section metrics, and analysis status. Tests cover screen text and labels. Project documentation describes the view, controls, and audio-analysis coverage.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Driver
  participant App
  participant AudioAnalysisScreen
  Driver->>App: Synchronize analysis for the playing Spotify track
  Driver->>App: Record playback timing and update pitch levels
  AudioAnalysisScreen->>App: Read pitch-view state and analysis data
  App-->>AudioAnalysisScreen: Provide pitch levels and section metadata
Loading

Merge Risk: ⚪ Minimal · up to 19da7

The pitch view retains its position when playback is paused. No confirmed issue remains that should block merging after normal checks.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the allowed conventional-commit prefix feat(tui):, clearly describes the Spotify Pitch visualizer change, and remains concise.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

✨ Simplify code
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LargeModGames LargeModGames changed the title feat(tui): bring back the spotify-tui pitch visualizer feat(tui): bring back the pitch visualizer Oct 12, 2026
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.56840% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/driver/mod.rs 0.0% 17 Missing ⚠️
src/core/app/audio_analysis.rs 99.0% 3 Missing ⚠️
src/tui/ui/audio_analysis.rs 98.0% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Base automatically changed from feat/analysis-data to main October 12, 2026 09:52
While a Spotify track plays, the analysis screen opens on a Spotify Pitch view: the twelve pitch classes of the segment playing now, scaled by its loudness envelope and drawn with the cava renderer and cava-like rise and gravity, plus the tempo, key and time signature of the current section. A local clock blends the native 1 s position updates. V cycles Cava, Bar Graph and Spotify Pitch; the pitch view is never saved, and capture is closed while it shows.
LargeModGames added a commit that referenced this pull request Oct 12, 2026
# Summary

First half of bringing back the spotify-tui visualizer that read
Spotify's audio analysis. Since #752 we have a Spotify session, and
spclient `/audio-attributes/v1/audio-analysis/{base62}` returns the same
JSON the Web API used to. This PR adds the data path only; #759 draws
it. Nothing asks for an analysis in this PR, so users see no change.

- `infra/spotify`: a router route `GET audio-analysis/{id}` answered
from spclient on the app side with `request_as_json`, like the playlist
reads, so no fork release is needed.
- `infra/network/mapping.rs`: `track_analysis` maps the JSON into a slim
`TrackAnalysis` (sections with tempo, key, mode and time signature;
segments with their 12 pitches and loudness envelope). No rspotify type:
its `AudioAnalysis` needs the fingerprint strings and rejects key `-1`.
- `core/app/audio_analysis.rs`: `AnalysisState` with a stale-reply guard
and one fetch per track. A 404 or an unreadable body is "no analysis";
any other failure (a 429, a timeout) is tried again after 10 s.
- `IoEvent::GetAudioAnalysis` passes the auth gate on the pump and runs
the fetch as a detached task through `spotify_api_request_json_for`, so
a DJ library crawl cannot hold it up. It never opens the error screen.
- `want_audio_analysis` and the `audio_analysis()` getter carry
`#[cfg_attr(not(test), allow(dead_code))]` until #759 uses them.

# Testing

- `cargo fmt --all -- --check`: ok
- `cargo clippy -- -D warnings`, and the same with
`--no-default-features --features telemetry,tui`, `telemetry`, and
`telemetry,gui,streaming,discord-rpc,self-update,scripting,mcp-server,mpris`:
all `Finished`
- `cargo test --no-default-features --features telemetry,tui`: `test
result: ok. 1480 passed; 0 failed; 0 ignored`
- `cargo test`: `test result: ok. 1928 passed; 0 failed; 6 ignored`
- Live, `cargo test --lib infra::spotify::live_tests::audio_analysis --
--ignored --test-threads=1 --nocapture`: `sections: 14, segments: 1512,
peak loudness -60.0 to -1.1 dB` for "One More Time"

# Additional notes

Stacked under #759. Merge both with `gh stack merge`.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added Spotify audio-analysis data fetching for tracks, including
musical sections, tempo, key, time signature, loudness, and pitch
information.
* Analysis results are reused while available, and failed requests can
be retried after a short delay.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@LargeModGames
LargeModGames merged commit dba6332 into main Oct 12, 2026
35 checks passed
@LargeModGames
LargeModGames deleted the feat/analysis-view branch October 12, 2026 10:00
LargeModGames added a commit that referenced this pull request Oct 12, 2026
# Summary

Version bump and changelog for v0.45.0, the first release with the
desktop app. No application code changes.

- `Cargo.toml`, `Cargo.lock`, `desktop/Cargo.toml` and
`desktop/Cargo.lock` go to 0.45.0. The desktop version must match the
root package, a desktop test pins that.
- `CHANGELOG.md`: `## [Unreleased]` is now `## [v0.45.0] 2026-10-12`. I
checked every PR merged since v0.44.0 against it: #757, #758 (in the
pitch visualizer entry), #759, #734, #751 and #763 have entries; #622,
#755 and #762 are docs only. The four desktop entries got the empty line
between them that the other entries have.
- `SECURITY.md` names 0.45 as the supported version.

# Testing

```
cargo metadata --locked --format-version 1 > /dev/null
root metadata --locked: ok
cargo metadata --locked --manifest-path desktop/Cargo.toml --format-version 1 > /dev/null
desktop metadata --locked: ok
cargo check --locked
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 31.36s
cargo package --list --allow-dirty
394 files; none under desktop/ or gui/
```

# Additional notes

This tag is the first run of the `desktop` and `desktop-manifest`
release jobs. The updater signing secrets are set and the public key is
in `desktop/tauri.conf.json`, so the release attaches signed installers
and `latest.json`, and installed desktop apps update themselves from
then on.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant