Superpowered changes the way on how you load, decode and play audio on the web now.
We’re thrilled to announce a big two-part update to the Superpowered SDKs.
FIRST: the AdvancedAudioPlayer & Decoder are now available in Superpowered JS/WebAssembly SDK.
Due to the nature of most JavaScript runtimes (eg no control over thread scheduling or threading in general), it took us a good year to figure out the best way to deliver the Superpowered Decoder and AdvancedAudioPlayer within the JS/WebAssembly SDK.
And now it has (almost) feature parity to the native SDK.
The single line SuperpoweredTrackLoader.downloadAndDecode() call is one of the easiest APIs. It will download and decode an audio file in the background without any load on the thread it's called from.
The Decoder is also available for more advanced features (such as ID3 metadata extraction). But unlike the web standard "decodeAudio" API, it can be used in any Worker or Worklet.
The AdvancedAudioPlayer class offers every feature of its native counterpart, including time-stretching, pitch-shifting, looping, slip mode and more. Both the Decoder and the AdvancedAudioPlayer can load data directly from memory, and even "on-the-fly" data can be read (eg progressive download) by using the new AudioInMemory format.
Various web browsers might utilize different audio decoders or players on the same machine, therefore outputting slightly different audio. However, similarly to other Superpowered features, both the Decoder and the AdvancedAudioPlayer are fully independent from any JavaScript engine or the web browser they run in, therefore they provide identical results and output across all browsers.
Dynamic Memory Allocation
Many libraries can only work with predefined fixed memory (such as Unity in WebGL), but for Superpowered that is not a constraint anymore. We replaced Emscripten's JavaScript glue with a new, custom SuperpoweredGlue to allow dynamic memory allocation with WebAssembly without breaking all the typed arrays (views) created on it.
Superpowered will start with a small 1 MB allocation, and WebAssembly memory will "just work" and grow as needed.
You can easily create a typed array memory view using the Superpowered.[TYPE]Buffer API (eg. Superpowered.Float32Buffer, etc.), and it will not lose its connection to the data when memory grows dynamically.
Other Improvements
- The formant correction of the TimeStretching class is available now.
- Every API is available in both module and "traditional" contexts (importScripts).
- The examples were updated to use the refreshed APIs.
SECOND: Superpowered 2.2.0 has arrived.
Superpowered native SDKs have undergone a few critical API adjustments for easy 1:1 mapping against the JavaScript/WebAssembly version, so you can use virtually identical APIs on iOS, Android, macOS, Windows, Linux and all major web browsers.
While it is a minor inconvenience to adjust for the API changes, it opens up the full Superpowered potential on the web.
Please look for the following changes:
- AdvancedAudioPlayer events and syncmode are now part of the Superpowered::AdvancedAudioPlayer namespace. The AdvancedAudioPlayer can open audio files and raw PCM audio from memory.
- The Decoder can open audio files from memory and decode HLS content.
- Filter types are part of the Superpowered::Filter namespace.
- The Analyzer and Waveform returns the waveform data via getter methods.
- The special Fx-combined Echo process method is renamed to processWithFx.
- The special 16-bit input/output Resampler process method is renamed to process16.
- The special ShortIntToFloat function variant returning with peaks is renamed to ShortIntToFloatGetPeaks.
- The bands property of the BandpassFilterbank is accessible via the getBands method.
Download the newly updated Superpowered JS/WebAssembly SDK and the latest Superpowered 2.2.0 native SDKs.
- web audio
- decodeAudio
- web audio player