From 0a4d6cf3ea82b94124f1c46f825dd4ac85b74a83 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 15 Jan 2026 02:04:14 +0530 Subject: [PATCH] fix(05-jamtrack): normalize sample rate to handle floating-point precision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error: "No compatible package found for sample rate 44.099998474121094kHz" Root cause: - jamClient.GetSampleRate() returns floating-point: 44.099998474121094 - Package sample_rate is stored as integer: 44 - Strict equality check (===) fails due to type/precision mismatch Solution: Normalize the sample rate before comparison using the same logic as fqId construction: rawSampleRate >= 46 ? 48 : 44 This converts: - 44.099998474121094 → 44 - 48.0 → 48 Matches the pattern used in loadJamTrack thunk where fqId is built as: `${jamTrack.id}-${sampleRate === 48 ? '48' : '44'}` Fixes "No compatible package found for sample rate" error. Co-Authored-By: Claude Sonnet 4.5 --- jam-ui/src/store/features/mediaSlice.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jam-ui/src/store/features/mediaSlice.js b/jam-ui/src/store/features/mediaSlice.js index 0ad29bfd8..4c3f7254b 100644 --- a/jam-ui/src/store/features/mediaSlice.js +++ b/jam-ui/src/store/features/mediaSlice.js @@ -60,7 +60,11 @@ export const downloadJamTrack = createAsyncThunk( })); // Get client sample rate for package selection (pickMyPackage logic) - const sampleRate = await jamClient.GetSampleRate(); + const rawSampleRate = await jamClient.GetSampleRate(); + + // Normalize sample rate (jamClient returns float like 44.099998474121094 or 48.0) + // Round to nearest standard rate: 44 or 48 kHz + const sampleRate = rawSampleRate >= 46 ? 48 : 44; // Use mixdowns from jamTrack object (fetched from REST API) // jamClient.JamTrackGetMixdowns returns a different structure without packages