Skip to content

Commit

Permalink
prog
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisheng Jiang committed Jul 28, 2024
1 parent d92f964 commit 73db113
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 224 deletions.
Binary file modified a.out
Binary file not shown.
20 changes: 20 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"mkspin": "file:../spin",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
Expand Down
1 change: 1 addition & 0 deletions app/public/file.sf2
53 changes: 43 additions & 10 deletions app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,51 @@ import App from './App';
import reportWebVitals from './reportWebVitals';
import mkpath from 'sf2rend/src/mkpath'
import SF2Service from 'sf2-service'
import {wasmbin as pdtawasm} from 'mkspin/pdta.wasm.js';
import {sfbkstream} from 'sf2-service/sfbk-stream.js'

mkpath(new OfflineAudioContext(2, 48000, 48000), {
sf2Service: new SF2Service(),
}).then(path => {
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
{JSON.stringify(path)}
</React.StrictMode>
);

const {pdtaBuffer, sdtaStart, infos} = await sfbkstream("file.sf2");
const root = ReactDOM.createRoot(document.getElementById('root'));
const mem = new WebAssembly.Memory({
initial: 111
})
let heap;

const wa = new WebAssembly.Instance(new WebAssembly.Module(pdtawasm), {
env: {
memory: mem,
printf: (format, ...args) => console.log(String.fromCharCode(heap[format]) + args.join(','))
},
});
heap = new Uint8Array(mem.buffer, wa.exports.__heap_base);
const {findPreset, globalZone} = wa.exports;
const pdtaLoc = wa.exports.__heap_base;
heap.set(pdtaBuffer);
wa.exports.readpdta(pdtaLoc);
for (let i = 0;i < 122;i++) {
const ph = findPreset(i, 0);
const pz = globalZone(ph);

}

root.render(
<React.StrictMode>
<pre>{JSON.stringify(pdtaBuffer.length, ",", sdtaStart)}</pre>
</React.StrictMode>
);

// mkpath(new OfflineAudioContext(2, 48000, 48000), {
// sf2Service: new SF2Service("file.sf2"),
// }).then(async path => {
// await path.loadsf2();
// const root = ReactDOM.createRoot(document.getElementById('root'));
// root.render(
// <React.StrictMode>
// <pre>{JSON.stringify(pdtaBuffer)}</pre>
// </React.StrictMode>
// );

// })


// If you want to start measuring performance in your app, pass a function
Expand Down
5 changes: 3 additions & 2 deletions spin/Makfile-safe
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ pdta.wasm:
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--no-entry \
-Wl,--allow-undefined \
-Wl,--no-entry \
-Wl,--import-memory \
-Wl,--lto-O3 -o build/pdta.wasm \
src/sf2.c



pdta.wasm.js: pdta.wasm
cat build/sf2.wasm | npx encode-wasm-uint8 > pdta.wasm.js
cat build/pdta.wasm | npx encode-wasm-uint8 > pdta.wasm.js
Binary file modified spin/build/pdta.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion spin/pdta.wasm.js

Large diffs are not rendered by default.

Loading

0 comments on commit 73db113

Please sign in to comment.