mirror of
https://github.com/datajerk/sendalo.git
synced 2024-06-01 16:41:35 +00:00
Initial commit of source code.
This commit is contained in:
parent
942102a2b2
commit
fcc720beb3
23
Makefile
Normal file
23
Makefile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
all: obj/c2t-96h.so link
|
||||||
|
|
||||||
|
c2t:
|
||||||
|
@if [ -z "${C2TDIR}" ]; then echo "Please set C2TDIR environment variable to the path of c2t source tree."; exit 1; fi
|
||||||
|
cd ${C2TDIR}; make
|
||||||
|
touch c2t
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f c2t
|
||||||
|
rm -rf bin/
|
||||||
|
rm -rf obj/
|
||||||
|
|
||||||
|
obj/c2t-96h.so: c2t
|
||||||
|
mkdir -p obj
|
||||||
|
emcc -c -Wall -Wno-strict-aliasing -Wno-misleading-indentation -Wno-unused-value -Wno-unused-function -I${C2TDIR} -O3 -o obj/c2t-96h.so ${C2TDIR}/c2t-96h.c -lm
|
||||||
|
|
||||||
|
link:
|
||||||
|
mkdir -p bin
|
||||||
|
emcc --shell-file sendalo.html.tpl -s INVOKE_RUN=0 -s EXIT_RUNTIME=0 -s ALLOW_MEMORY_GROWTH=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=['callMain'] -o bin/sendalo.html obj/c2t-96h.so
|
||||||
|
|
||||||
|
test:
|
||||||
|
cd bin; python3 -m http.server 65020
|
||||||
|
|
69
sendalo.html.tpl
Normal file
69
sendalo.html.tpl
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Sendalo</title>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function downloadFile() {
|
||||||
|
var file = document.getElementById('upload').files[0];
|
||||||
|
if (file) {
|
||||||
|
var fr = new FileReader();
|
||||||
|
fr.onloadend = function() {
|
||||||
|
downloadComplete(this.result);
|
||||||
|
};
|
||||||
|
fr.readAsArrayBuffer(file);
|
||||||
|
} else {
|
||||||
|
requestURL = document.getElementById('url').value;
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', requestURL);
|
||||||
|
xhr.responseType = 'arraybuffer';
|
||||||
|
|
||||||
|
xhr.onload = function () {
|
||||||
|
downloadComplete(this.response);
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function downloadComplete(what) {
|
||||||
|
FS.writeFile('/tmp/c2t.dsk', new Uint8Array(what));
|
||||||
|
Module.callMain(['-n8', '/tmp/c2t.dsk', '/tmp/c2t.wav']);
|
||||||
|
fd = FS.readFile('/tmp/c2t.wav', {encoding: 'binary'});
|
||||||
|
b = new Blob([fd], { type: 'audio/wav' });
|
||||||
|
u = URL.createObjectURL(b);
|
||||||
|
audio = document.getElementById('audio');
|
||||||
|
source = document.getElementById('source');
|
||||||
|
source.src = u;
|
||||||
|
audio.load();
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileSelected(ev) {
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
var Module = {
|
||||||
|
print: (function(text) {
|
||||||
|
console.log(text);
|
||||||
|
}),
|
||||||
|
printErr: (function(text) {
|
||||||
|
console.log(text);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="text" value="Misc_Apple_Programs_1.dsk" id="url"/>
|
||||||
|
<input type="file" id="upload" />
|
||||||
|
<input type="button" onclick="downloadFile()"/>
|
||||||
|
|
||||||
|
<audio controls="controls" id="audio">
|
||||||
|
<source id="source" src="" type="audio/wav" />
|
||||||
|
</audio>
|
||||||
|
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user