Acidized Wav file column (for music producers)

Magix Acid (formerly Sony Acid, and before that Sonic Foundry Acid) creates loop wav files also called "acidized" wav files.
This script allows you to add a column under details view that will show if a wav file is acidized or not, and thus, a loop.

Useful when you have lots of wav files and need to see which ones have been "acidized".

// Directory Opus Script: Acidized WAV Detector v3 (Robust Binary)
// Detects if a WAV file contains the proprietary "acid" RIFF chunk

function OnInit(initData) {
    initData.name = "Acidized WAV Detector v3";
    initData.desc = "Adds a column showing if a WAV file is acidized (contains 'acid' chunk) - robust version";
    initData.copyright = "Public Domain / Community";
    initData.version = "3.0";
    initData.default_enable = true;

    var col = initData.AddColumn();
    col.name = "Acidized";
    col.method = "OnAcidized";
    col.label = "Acidized";
    col.justify = "left";
    col.autogroup = true;
    col.multicol = false;
}

function OnAcidized(scriptColData) {
    var ext = scriptColData.item.ext.toLowerCase();
    if (ext != ".wav" && ext != ".wave") {
        return;
    }

    var path = scriptColData.item.realpath;
    if (!path) return;

    var stream = new ActiveXObject("ADODB.Stream");
    stream.Type = 1; // adTypeBinary
    stream.Open();
    try {
        stream.LoadFromFile(path);
    } catch (e) {
        return; // Can't load file
    }

    if (stream.Size < 20) { // Too small for RIFF WAVE + at least one chunk
        stream.Close();
        return;
    }

    stream.Position = 0;
    var data = stream.Read(-1); // Read entire file as binary (variant/byte array)
    stream.Close();

    var bytes = new VBArray(data).toArray(); // Convert to JS array of bytes (0-255)

    // Check RIFF WAVE header
    if (bytes[0] != 0x52 || bytes[1] != 0x49 || bytes[2] != 0x46 || bytes[3] != 0x46 || // "RIFF"
        bytes[8] != 0x57 || bytes[9] != 0x41 || bytes[10] != 0x56 || bytes[11] != 0x45) { // "WAVE"
        return;
    }

    var found = false;
    var pos = 12; // Start after RIFF header

    while (pos < bytes.length - 8) {
        var id = String.fromCharCode(bytes[pos], bytes[pos+1], bytes[pos+2], bytes[pos+3]);

        if (id == "acid") {
            found = true;
            break;
        }

        // Get chunk size (little-endian uint32)
        var size = bytes[pos+4] | (bytes[pos+5] << 8) | (bytes[pos+6] << 16) | (bytes[pos+7] << 24);

        pos += 8 + size;
        if (size % 2 == 1) pos++; // Padding for odd-sized chunks
        if (pos > bytes.length) break;
    }

    scriptColData.value = found ? "Yes" : "No";
}

how to install:

  1. go to Settings > Preferences > Toolbars > Scripts.
  2. Click New > Script Add-In (JScript).

how to show column:
in details view, right click on column headers, and choose:
Columns->Script->Acidized

2 Likes