Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
msokalski committed Oct 19, 2021
1 parent d62e27a commit 06dd6ad
Show file tree
Hide file tree
Showing 11 changed files with 5,965 additions and 145 deletions.
35 changes: 30 additions & 5 deletions audio-post.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var audio_port = null;
var audio_call = 0;

var Init = Module.cwrap('Init', 'number', []);
var Init = Module.cwrap('Init', 'number', ['number']);
var Proc = Module.cwrap('Proc', 'number', []);
var Call = Module.cwrap('Call', null, ['number','number']);

var XOgg = Module.cwrap('XOgg', null, ['number','number','number']);

class AsciickerAudio extends AudioWorkletProcessor
{
Expand All @@ -18,19 +18,44 @@ class AsciickerAudio extends AudioWorkletProcessor
{
if (e.data.length <= 4096)
{
HEAPU8.set(e.data, audio_call)
Module.HEAPU8.set(e.data, audio_call)
Call(audio_call, e.data.length);
}
else
{
let addr = Module._malloc(e.data.length);
HEAPU8.set(e.data, addr)
Module.HEAPU8.set(e.data, addr)
Call(addr, e.data.length);
Module._free(addr);
}
}

audio_call = Init();
const c = args[0].processorOptions; // array of {data:Uint8Array, name:Uint8Array}
let max_size = 0;
let num = c.length;
for (const s in c)
max_size = max_size < c[s].data.length ? c[s].data.length : max_size;

audio_call = Init(num);

console.log("PLEASE");

if (max_size > 0)
{
let data = Module._malloc(max_size);
for (const s in c)
{
Module.HEAPU8.set(c[s].name, audio_call);
Module.HEAPU8[audio_call+c[s].name.length]=0; // terminate name string

// fill data
Module.HEAPU8.set(c[s].data, data);

// call decompressor
XOgg(audio_call, data, c[s].data.length);
}
Module._free(data);
}
}

process (inputs, outputs, parameters)
Expand Down
Loading

0 comments on commit 06dd6ad

Please sign in to comment.