Skip to content

Commit

Permalink
assemblyscript 0.27.14 (#99)
Browse files Browse the repository at this point in the history
update assemblyscript to 0.27.14
remove wasi export ( since removed from AssemblyScript )
revert compressor breaking change
replace karma with Web Test runner
petersalomonsen authored Jan 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d9aa076 commit 83c68e6
Showing 30 changed files with 6,100 additions and 7,856 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"postCreateCommand": "./.devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions"
]
}
}
}
8 changes: 8 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
sudo apt-get install -y pulseaudio
pulseaudio -D --exit-idle-time=-1
cd wasmaudioworklet
yarn install
yarn playwright install-deps
yarn playwright install

39 changes: 16 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -14,38 +14,31 @@ jobs:
run: |
grep -rq --include '*.spec.js' \.only\( . && echo 'You have .only() in your tests!' && exit 1
exit 0
chromeheadless:
name: Chrome headless
web-test-runner:
name: Web Test Runner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Chrome headless
- name: Web Test Runner
run: |
cd wasmaudioworklet
npm install
npm test
firefoxxvfb:
name: Firefox xvfb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Firefox xvfb
run: |
sudo apt-get install pulseaudio
sudo apt-get install -y pulseaudio
pulseaudio -D --exit-idle-time=-1
cd wasmaudioworklet
npm install
xvfb-run npm run test-firefox
yarn install
yarn playwright install
yarn playwright install-deps
yarn createbrowsersourcebundle
xvfb-run yarn wtr
assemblyscriptsynth:
name: AssemblyScript synth
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Assemblyscript synth
run: |
cd wasmaudioworklet/synth1
npm install
npm run test:ci
cd wasmaudioworklet
yarn install
yarn test-asc-synth:ci
bundle-pianorolldemo:
name: Bundle pianorolldemo
runs-on: ubuntu-latest
@@ -54,8 +47,8 @@ jobs:
- name: Bundle pianorolldemo
run: |
cd wasmaudioworklet
npm install
npm run bundle-pianorolldemo
yarn install
yarn bundle-pianorolldemo
bundle-songcompiler:
name: Bundle songcompiler
runs-on: ubuntu-latest
@@ -64,5 +57,5 @@ jobs:
- name: Bundle songcompiler
run: |
cd wasmaudioworklet
npm install
npm run bundle-songcompiler
yarn install
yarn bundle-songcompiler
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: |
cd wasmaudioworklet
6 changes: 3 additions & 3 deletions wasmaudioworklet/audioworkletnode.js
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ export function initAudioWorkletNode(componentRoot) {
response.arrayBuffer()
) : window.WASM_SYNTH_BYTES;

await context.audioWorklet.addModule('./audioworkletprocessor.js');
await context.audioWorklet.addModule(new URL('audioworkletprocessor.js', import.meta.url));
audioworkletnode = new AudioWorkletNode(context, 'pattern-seq-audio-worklet-processor', {
outputChannelCount: [2]
});
@@ -102,7 +102,7 @@ export function initAudioWorkletNode(componentRoot) {
let currentTimePromiseResolve;

audioworkletnode.port.onmessage = msg => {
if (msg.data.channelvalues) {
if (msg.data.channelvalues) {
const channelvalues = msg.data.channelvalues;
for (let n = 0; n < channelvalues.length; n++) {
const note = channelvalues[n];
@@ -138,7 +138,7 @@ export function initAudioWorkletNode(componentRoot) {
);
}
audioworkletnode.connect(context.destination);
}
}
recordAudioNode(audioworkletnode);
componentRoot.getElementById('startaudiobutton').style.display = 'none';
componentRoot.getElementById('stopaudiobutton').style.display = 'block';
1 change: 0 additions & 1 deletion wasmaudioworklet/editorcontroller.js
Original file line number Diff line number Diff line change
@@ -349,7 +349,6 @@ export async function initEditor(componentRoot) {
<h3>Select WASM module type to export</h3>
<p>
<form>
<label><input type="radio" name="exporttype" value="wasimain" checked="checked">Self executable WASI module</label><br />
<label><input type="radio" name="exporttype" value="libmodule">Library module</label><br />
</form>
</p>
39 changes: 0 additions & 39 deletions wasmaudioworklet/editorcontroller.spec.js
Original file line number Diff line number Diff line change
@@ -153,45 +153,6 @@ export function mixernext(leftSampleBufferPtr: usize, rightSampleBufferPtr: usiz
expect(errorMessagesContentElement.innerText).contains(`ERROR TS1005: ')' expected`);
expect(errorMessagesContentElement.innerText).contains(`hello`);
});
it('should compile and export song to wasm with WASI main entry point', async () => {
songsourceeditor.doc.setValue(songsource);
synthsourceeditor.doc.setValue(synthsource);
const appElement = document.getElementsByTagName('app-javascriptmusic')[0].shadowRoot;
let audioWorkletMessage;
window.audioworkletnode = {
port: {
postMessage: msg => audioWorkletMessage = msg
},
context: {
sampleRate: 44100
}
};
const downloadPromise = new Promise(resolve => {
document._createElement = document.createElement;
document.createElement = function (elementName, options) {
const elm = this._createElement(elementName, options);
if (elementName === 'a') {
elm.click = () => resolve(elm.href);
} else if (elementName === 'common-modal') {
elm.shadowRoot.result('wasimain');
}
return elm;
}
});

appElement.querySelector('#exportbutton').click();
const url = await downloadPromise;

const wasmbinary = await fetch(url).then(r => r.arrayBuffer());

assert.isAbove(wasmbinary.byteLength, 1000);
assert.isDefined((await WebAssembly.instantiate(wasmbinary, {
wasi_snapshot_preview1: {
fd_write: () => 0
}
})).instance.exports._start);
document.createElement = document._createElement;
});
it('should compile and export song to wasm with lib functions exported', async () => {
songsourceeditor.doc.setValue(songsource);
synthsourceeditor.doc.setValue(synthsource);
6 changes: 3 additions & 3 deletions wasmaudioworklet/karma.conf.cjs
Original file line number Diff line number Diff line change
@@ -78,12 +78,12 @@ module.exports = function (config) {
},
ChromeHeadless_NoUserGestureRequired: {
base: 'Chrome',
flags: ['--autoplay-policy=no-user-gesture-required','--headless=new']
flags: ['--autoplay-policy=no-user-gesture-required', '--headless=new']
},
FirefoxAutoplay: {
base: 'FirefoxHeadless',
prefs: {
'media.autoplay.block-webaudio': false
'media.autoplay.block-webaudio': false
}
}
},
@@ -94,6 +94,6 @@ module.exports = function (config) {

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
concurrency: Infinity,
})
}
2 changes: 1 addition & 1 deletion wasmaudioworklet/midisequencer/songcompiler.spec.js
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ loopHere();
try {
await compileSong(`createTrack(5).steps(4,[controlChange(91, 100)]);`);
} catch (e) {
assert.equal('controlChange is not defined', e.message);
assert.isTrue(e.message === 'controlChange is not defined' || e.message === "Can't find variable: controlChange");
hasError = true;
}
assert.equal(hasError, true);
Loading

0 comments on commit 83c68e6

Please sign in to comment.