File: convert.sh

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 62,416 kB
  • sloc: ansic: 192,636; cpp: 14,151; javascript: 9,654; objc: 9,181; java: 3,337; python: 3,333; sh: 1,783; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 126
file content (48 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

rm libcsound-worklet.base64.js

echo "AudioWorkletGlobalScope.WAM = { ENVIRONMENT: \"WEB\" };" >> libcsound-worklet.base64.js

echo "AudioWorkletGlobalScope.WAM.wasmBinary = \"$(base64 -w 0 libcsound-worklet.wasm)\";" >> libcsound-worklet.base64.js

cat << EOF >> libcsound-worklet.base64.js
AudioWorkletGlobalScope.WAM.atob = function (sBase64, nBlocksSize)
{
        
    var sB64Enc = sBase64.replace(/[^A-Za-z0-9+/]/g, "");
    var nInLen = sB64Enc.length;
    var nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2;
    var taBytes = new Uint8Array(nOutLen);
    
    for (var nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {
        nMod4 = nInIdx & 3;
        nUint24 |= AudioWorkletGlobalScope.WAM.b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4;
        if (nMod4 === 3 || nInLen - nInIdx === 1) {
            for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {
                taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;
            }
            nUint24 = 0;
        }
    }
    return taBytes.buffer;
}

AudioWorkletGlobalScope.WAM.b64ToUint6 = function (nChr)
{
    return nChr > 64 && nChr < 91 ?
        nChr - 65
        : nChr > 96 && nChr < 123 ?
        nChr - 71
        : nChr > 47 && nChr < 58 ?
        nChr + 4
        : nChr === 43 ?
        62
        : nChr === 47 ?
        63
        :
        0;
}

AudioWorkletGlobalScope.WAM.wasmBinary = AudioWorkletGlobalScope.WAM.atob(AudioWorkletGlobalScope.WAM.wasmBinary);
EOF