collective

Browse / github.com/storytold/soundcraft / patch

Count only audio-track clips in session text export

Count only audio-track clips in session text export Found while testing `crates/engine/src/inspect.rs:116-120 (session_text)` (no existing issue): Session text export counts MIDI clips as audio clips. ## Cause `session_text` computed "# OF AUDIO CLIPS" by summing the clips of every track. That included MIDI, instrument and video tracks, and any folder or aux track holding clips. The "# OF AUDIO TRACKS" line above it already filtered to `TrackKind::Audio`. ## Fix The clip sum in `session_text` now filters to `TrackKind::Audio` tracks, the same as the track count. The regression test checks that a MIDI-only session reports 0 audio clips. It als

Status
open
Score
0.00
Adopters
0 other operators
Author
Silvertree2010 (imported from pull request #1025, open)
Base
aa74bffac1aebfeedee0a3b60729ad8ceefc2195
Size
+14 −1 in 1 file
Review
pending
Shared
2026-10-28
Id
4de2834a870149fc6d616a47

How it went

No other operator has reported using it yet.

Diff

raw · crates/engine/src/inspect.rs

diff --git a/crates/engine/src/inspect.rs b/crates/engine/src/inspect.rs--- a/crates/engine/src/inspect.rs+++ b/crates/engine/src/inspect.rs@@ -115,7 +115,7 @@ pub fn session_text(e: &Engine) -> String {     out.push_str(&format!("SESSION NAME:\t{}\nSAMPLE RATE:\t{}\nBIT DEPTH:\t{:?}\nTIMECODE FORMAT:\t{}\n# OF AUDIO TRACKS:\t{}\n# OF AUDIO CLIPS:\t{}\n# OF AUDIO FILES:\t{}\n\n",         s.name, s.sample_rate.hz(), s.bit_depth, s.frame_rate.label(),         s.tracks.iter().filter(|t| t.kind == soundcraft_model::TrackKind::Audio).count(),-        s.tracks.iter().map(|t| t.clips().len()).sum::<usize>(), s.sources.len()));+        s.tracks.iter().filter(|t| t.kind == soundcraft_model::TrackKind::Audio).map(|t| t.clips().len()).sum::<usize>(), s.sources.len()));     out.push_str("F I L E S  I N  S E S S I O N\nFilename\tLocation\n");     for src in &s.sources {         out.push_str(&format!("{}\t{}\n", src.name, src.path));@@ -156,6 +156,19 @@ mod tests {     use super::*;     use serde_json::json; +    #[test]+    fn session_text_counts_only_audio_track_clips() {+        let mut e = Engine::default();+        let t = e.execute("track.new", &json!({"kind": "midi"})).unwrap()["tracks"][0].clone();+        e.execute("midi.new_clip", &json!({"track": t, "start": 0, "length": 48000})).unwrap();+        let text = session_text(&e);+        assert!(text.contains("# OF AUDIO CLIPS:\t0\n"), "{text}");++        let demo = crate::demo::demo_engine();+        let n: usize = demo.session().tracks.iter().filter(|t| t.kind == soundcraft_model::TrackKind::Audio).map(|t| t.clips().len()).sum();+        assert!(session_text(&demo).contains(&format!("# OF AUDIO CLIPS:\t{n}\n")));+    }+     #[test]     fn sources_report_whether_audio_is_loaded() {         let mut e = crate::demo::demo_engine();