// Detect It Easy: detection rule file
// Author: Kaens TG@kaens

meta("audio", "Interplay ACM waveform audio (.ACM)");

function detect() {
    //from https://github.com/dtiefling/snd2acm-portable/blob/master/src/general.h
    if (!File.compare("97280301") || File.getSize() < 0x10) return false;
    var smp = File.read_uint32(4),
        ch = File.read_uint16(8),
        r = File.read_uint16(0xA);

    if (!smp || !isWithin(ch, 1, 2) || !isWithin(r, 6000, 49716)) return false;
    bDetected = true;
    if (Binary.isVerbose()) {
        var sr = (r / 1000).toFixed(1);
        sOption('ch: ' + ch + ' s/r: ' + sr + 'kHz len: ' + secondsToTimeStr(Util.divu64(smp + (r >> 1), r * ch)));
    }

    return result();
}