-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from JohnDog3112/dev2
Audio Library
- Loading branch information
Showing
19 changed files
with
1,690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,5 +77,9 @@ cd ../lib | |
$make clean | ||
$make | ||
|
||
cd ../tests-audio | ||
$make clean | ||
$make | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ $make clean | |
cd ../tests-d2d | ||
$make clean | ||
|
||
cd ../tests-audio | ||
$make clean | ||
|
||
cd .. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CC := clang | ||
TWRCFLAGS := --target=wasm32 -nostdinc -nostdlib -isystem ../../include | ||
CPPLIB := ../twr-cpp | ||
CFLAGS := -c -Wall -O3 $(TWRCFLAGS) -I $(CPPLIB) | ||
CFLAGS_DEBUG := -c -Wall -g -O0 $(TWRCFLAGS) -I $(CPPLIB) | ||
|
||
|
||
|
||
.PHONY: default | ||
|
||
default: tests-audio.wasm tests-audio-a.wasm clearIODiv.js | ||
|
||
clearIODiv.js: index.html clearIODiv.ts | ||
tsc | ||
|
||
tests-audio.o: tests-audio.c | ||
$(CC) $(CFLAGS) $< -o $@ | ||
|
||
tests-audio-a.o: tests-audio.c | ||
$(CC) $(CFLAGS) $< -o $@ -DASYNC | ||
|
||
tests-audio.wasm: tests-audio.o | ||
wasm-ld tests-audio.o ../../lib-c/twr.a -o tests-audio.wasm \ | ||
--no-entry --initial-memory=4063232 --max-memory=4063232 \ | ||
|
||
tests-audio-a.wasm: tests-audio-a.o | ||
wasm-ld tests-audio-a.o ../../lib-c/twr.a -o tests-audio-a.wasm \ | ||
--no-entry --shared-memory --no-check-features --initial-memory=4063232 --max-memory=4063232 \ | ||
|
||
clean: | ||
rm -f *.o | ||
rm -f *.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {IWasmModule, IWasmModuleAsync, twrLibrary, keyEventToCodePoint, TLibImports, twrLibraryInstanceRegistry} from "twr-wasm" | ||
|
||
// Libraries use default export | ||
export default class clearIODivLib extends twrLibrary { | ||
id: number; | ||
|
||
imports:TLibImports = { | ||
clearIODiv: {}, | ||
}; | ||
|
||
// every library should have this line | ||
libSourcePath = new URL(import.meta.url).pathname; | ||
|
||
constructor() { | ||
// all library constructors should start with these two lines | ||
super(); | ||
this.id=twrLibraryInstanceRegistry.register(this); | ||
} | ||
|
||
clearIODiv(mod: IWasmModule|IWasmModuleAsync) { | ||
const ioDiv = document.getElementById("twr_iodiv"); | ||
if (!ioDiv) throw new Error("clearIODiv couldn't find twr_iodiv!"); | ||
|
||
ioDiv.innerText = ""; | ||
} | ||
|
||
} | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Audio Tests</title> | ||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"twr-wasm": "../../lib-js/index.js" | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<select id="test_select"></select> | ||
<button id="test_button">Test</button> | ||
<button id="test_all_button">Test All</button> | ||
<div id="twr_iodiv"></div> | ||
<canvas id="twr_d2dcanvas" width="600" height="600"></canvas> | ||
|
||
<script type="module"> | ||
"use strict"; | ||
let test_select = document.getElementById("test_select"); | ||
let test_button = document.getElementById("test_button"); | ||
let test_all_button = document.getElementById("test_all_button"); | ||
let io = document.getElementById("twr_iodiv"); | ||
|
||
import {twrWasmModule, twrWasmModuleAsync} from "twr-wasm"; | ||
import clearIODivLib from "./out/clearIODiv.js"; | ||
|
||
// const timerLibInit = new timerLib(); | ||
const clearIODivLibInit = new clearIODivLib; | ||
|
||
const is_async = window.location.hash=="#async"; | ||
|
||
const mod = is_async ? new twrWasmModuleAsync() : new twrWasmModule(); | ||
await mod.loadWasm(is_async ? "./tests-audio-a.wasm" : "./tests-audio.wasm"); | ||
|
||
const numTests = await mod.callC(["getNumTests"]); | ||
console.log("tests: ", numTests); | ||
for (let i = 0; i < numTests; i++) { | ||
let option = document.createElement("OPTION"); | ||
const testName = mod.getString(await mod.callC(["getTestName", i])); | ||
option.innerText = testName; | ||
option.value = testName; | ||
test_select.appendChild(option); | ||
} | ||
|
||
test_all_button.onclick = async () => { | ||
await mod.callC(["testAll"]); | ||
}; | ||
|
||
test_button.onclick = async () => { | ||
await mod.callC(["testCase", test_select.selectedIndex]); | ||
} | ||
|
||
// const numTests = await mod.callC(["get_num_tests"]) | ||
// for (let i = 0; i < numTests; i++) { | ||
// let option = document.createElement("OPTION"); | ||
// const testName = mod.getString(await mod.callC(["get_test_name", i])); | ||
// option.innerText = testName; | ||
// option.value = testName; | ||
// test_select.appendChild(option); | ||
// } | ||
|
||
// await mod.callC(["test_all"]); | ||
|
||
// test_all_button.onclick = async () => { | ||
// io.innerHTML = ""; | ||
// await mod.callC(["test_all"]); | ||
// }; | ||
|
||
// test_button.onclick = async () => { | ||
// io.innerHTML = ""; | ||
// await mod.callC(["test_specific", test_select.selectedIndex]); | ||
// } | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IWasmModule, IWasmModuleAsync, twrLibrary, TLibImports } from "twr-wasm"; | ||
export default class clearIODivLib extends twrLibrary { | ||
id: number; | ||
imports: TLibImports; | ||
libSourcePath: string; | ||
constructor(); | ||
clearIODiv(mod: IWasmModule | IWasmModuleAsync): void; | ||
} | ||
//# sourceMappingURL=clearIODiv.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { IWasmModule, IWasmModuleAsync, twrLibrary, TLibImports } from "twr-wasm"; | ||
export default class timerLib extends twrLibrary { | ||
imports: TLibImports; | ||
setTimeout(mod: IWasmModule | IWasmModuleAsync, eventID: number, time: number, args: number): void; | ||
} | ||
//# sourceMappingURL=timerLib.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"@parcel/resolver-default": { | ||
"packageExports": true | ||
}, | ||
"alias": { | ||
"twr-wasm": "../../lib-js/index.js" | ||
}, | ||
"dependencies": { | ||
"twr-wasm": "^2.0.0" | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.