Repository navigation
feat(spotify): fetch the audio analysis - #758
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to This change adds the data path for fetching Spotify audio analysis. Nothing requests an analysis yet, so users see no behavior change. No merge-blocking risk was identified. Pre-merge checks |
|
GET audio-analysis/{id} is answered from spclient audio-attributes, mapped into a slim TrackAnalysis with the segment loudness envelope, and fetched by a detached task into App state. A 404 is no analysis; any other failure is tried again after 10 s. Nothing asks for it yet.
5e79940 to
7ba3b37
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
# 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`. --- <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 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
# 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>
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 routeGET audio-analysis/{id}answered from spclient on the app side withrequest_as_json, like the playlist reads, so no fork release is needed.infra/network/mapping.rs:track_analysismaps the JSON into a slimTrackAnalysis(sections with tempo, key, mode and time signature; segments with their 12 pitches and loudness envelope). No rspotify type: itsAudioAnalysisneeds the fingerprint strings and rejects key-1.core/app/audio_analysis.rs:AnalysisStatewith 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::GetAudioAnalysispasses the auth gate on the pump and runs the fetch as a detached task throughspotify_api_request_json_for, so a DJ library crawl cannot hold it up. It never opens the error screen.want_audio_analysisand theaudio_analysis()getter carry#[cfg_attr(not(test), allow(dead_code))]until feat(tui): bring back the pitch visualizer #759 uses them.Testing
cargo fmt --all -- --check: okcargo clippy -- -D warnings, and the same with--no-default-features --features telemetry,tui,telemetry, andtelemetry,gui,streaming,discord-rpc,self-update,scripting,mcp-server,mpris: allFinishedcargo test --no-default-features --features telemetry,tui:test result: ok. 1480 passed; 0 failed; 0 ignoredcargo test:test result: ok. 1928 passed; 0 failed; 6 ignoredcargo test --lib infra::spotify::live_tests::audio_analysis -- --ignored --test-threads=1 --nocapture:sections: 14, segments: 1512, peak loudness -60.0 to -1.1 dBfor "One More Time"Additional notes
Stacked under #759. Merge both with
gh stack merge.💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit