soiaf / webassembly-wavpack Goto Github PK
View Code? Open in Web Editor NEWA simple decoder/player for WavPack audio files using WebAssembly.
License: BSD 3-Clause "New" or "Revised" License
A simple decoder/player for WavPack audio files using WebAssembly.
License: BSD 3-Clause "New" or "Revised" License
//////////////////////////////////////////////////////////////////////////////////////////////// // WavPack WebAssembly Decoder/Player // // Copyright (c)2021-2022 Peter McQuillan // // All Rights Reserved. // // Distributed under the BSD Software License (see wavpack_webassembly_license.txt) // //////////////////////////////////////////////////////////////////////////////////////////////// This package contains the source code for a WebAssembly decoder (and very simple player) for WavPack files. This version is built on top of the WavPack Tiny Decoder, so it will not decode (very old) version 3 files. This will also not decode DSD WavPack files. The main WebAssembly code is written in C and emscripten is used to generate the WebAssembly output. Javascript is used to communicate with the WebAssembly code. To compile the C code, you can look at the included mybuild.bat file, though obviously this would need to be modified to point at the location on your local machine to emcc (Emscripten compiler). This will generate 2 files, wavpack.js and wavpack.wasm There are 3 versions of HTML/JavaScript for interfacing with the WebAssembly code that you can try: A version where we're filling a buffer and using Web Audio to play the buffer. For this version mywavpack.htm is the HTML file, this will let you try out the decoder. This HTML file calls mywavpack.js which is the main JavaScript code, this calls the WebAssembly code. This version of the code may give small audio glitches when playing back some WavPack files. A version using an AudioWorklet interface to Web Audio For this version the HTML to load is index.htm This HTML file calls mywavpack_worklet.js which in turn calls messenger-processor.js This version is a more modern approach to Web Audio and should give more consistent results on supported browsers. There is also a very simple/basic benchmark interface. This is accessed via timer.htm With this version, there is no playback of the actual music, you simply select the file you wish to test, wait a bit and it will show you how many seconds (milliseconds) it took to decode the file. This can be interesting if you want to see the speed differences between different browsers or you want to see the speed difference between running a decoder 'natively' and decoding via a web browser. The HTML files have to be called via a web server, due to security issues it will not work by simply opening the file with your web browser - however you can call it from any webserver including one on your own machine - for development purposes I used one from python, called (in the directory where I have all these files) with: python -m http.server I use a simple 'hack' in order to allow the WebAssembly code to read the contents of the WavPack file you choose to play, it makes a copy of the file which is in the correct security context that the WebAssembly file can read from. The buffer it uses to retrieve the decoded PCM data is shared with the WebAssembly code - I use a malloc in the code to reserve a small amount of memory - I don't use a corresponding 'free' as this reserved memory gets re-used if you load/play subsequent WavPack files. My code is built on top of the WavPack tiny decoder, however this could probably be modified to use the full WavPack source code if you wanted to! Please direct any questions or comments to [email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.