const isIntEncodedAsFloat = (v) => v > 0 && v < 1e-6 && Number.isFinite(v) && (v / 1.401298464324817e-45) % 1 === 0;
export const migrateAudioFileBox = async (boxGraph, box, loadAudioData) => {
    const { startInSeconds, endInSeconds, fileName } = box;
    if (isIntEncodedAsFloat(startInSeconds.getValue()) || isIntEncodedAsFloat(endInSeconds.getValue()) || endInSeconds.getValue() === 0) {
        const audioData = await loadAudioData(box.address.uuid);
        const seconds = audioData.numberOfFrames / audioData.sampleRate;
        console.debug(`Migrate 'AudioFileBox' to float sec (${fileName.getValue()})`, seconds.toFixed(3));
        boxGraph.beginTransaction();
        startInSeconds.setValue(0);
        endInSeconds.setValue(seconds);
        boxGraph.endTransaction();
    }
};
