fix(05-jamtrack): normalize sample rate to handle floating-point precision

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 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-01-15 02:04:14 +05:30
parent e4339fb54b
commit 0a4d6cf3ea
1 changed files with 5 additions and 1 deletions

View File

@ -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