All Projects → AnthumChris → Fetch Stream Audio

AnthumChris / Fetch Stream Audio

Licence: mit
Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Fetch Stream Audio

Blazorfilereader
Library for creating read-only file streams from file input elements or drop targets in Blazor.
Stars: ✭ 278 (+81.7%)
Mutual labels:  stream, webassembly
Timidity
Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
Stars: ✭ 221 (+44.44%)
Mutual labels:  web-audio, webassembly
Fetch Progress Indicators
Progress indicators/bars using Streams, Service Workers, and Fetch APIs
Stars: ✭ 181 (+18.3%)
Mutual labels:  stream, fetch-api
Movienight
Single instance video streaming server with integrated chat.
Stars: ✭ 387 (+152.94%)
Mutual labels:  stream, webassembly
Node Fetch
A light-weight module that brings the Fetch API to Node.js
Stars: ✭ 7,176 (+4590.2%)
Mutual labels:  stream, fetch-api
Web Audio Javascript Webassembly Sdk Interactive Audio
🌐 Superpowered Web Audio JavaScript and WebAssembly SDK for modern web browsers. Allows developers to implement low-latency interactive audio features into web sites and web apps with a friendly Javascript API. https://superpowered.com
Stars: ✭ 68 (-55.56%)
Mutual labels:  web-audio, webassembly
App Media
Elements for accessing data from media input devices and visualizing that data for users
Stars: ✭ 60 (-60.78%)
Mutual labels:  stream, web-audio
Opus Stream Decoder
Instantly decode Ogg Opus audio streams in chunks with JavaScript & WebAssembly (Wasm)
Stars: ✭ 80 (-47.71%)
Mutual labels:  stream, webassembly
Wasm Crypto
A WebAssembly (via AssemblyScript) set of cryptographic primitives for building authentication and key exchange protocols.
Stars: ✭ 146 (-4.58%)
Mutual labels:  webassembly
Gulp Remember
A plugin for gulp that remembers and recalls files passed through it
Stars: ✭ 149 (-2.61%)
Mutual labels:  stream
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+8496.08%)
Mutual labels:  webassembly
Wah
a slightly higher-level language superset of webassembly
Stars: ✭ 147 (-3.92%)
Mutual labels:  webassembly
0x Mesh
A peer-to-peer network for sharing 0x orders
Stars: ✭ 149 (-2.61%)
Mutual labels:  webassembly
Rs Asteroids
A variation on the game Asteroids, written in Rust
Stars: ✭ 146 (-4.58%)
Mutual labels:  webassembly
Wasmer Java
☕ WebAssembly runtime for Java
Stars: ✭ 152 (-0.65%)
Mutual labels:  webassembly
Jaxon
Streaming JSON parser for Elixir
Stars: ✭ 145 (-5.23%)
Mutual labels:  stream
Woz
Woz is a progressive WebAssembly app (PWAA) generator for Rust.
Stars: ✭ 145 (-5.23%)
Mutual labels:  webassembly
Seed
A Rust framework for creating web apps
Stars: ✭ 3,069 (+1905.88%)
Mutual labels:  webassembly
Angular Wasm
Examples of how to use WebAssembly within Angular
Stars: ✭ 151 (-1.31%)
Mutual labels:  webassembly
Rapidcms
RapidCMS is a Blazor framework which allows you to build a responsive and flexible CMS purely from code. It provides a basic set of editors and controls, and is fully customisable.
Stars: ✭ 149 (-2.61%)
Mutual labels:  webassembly


Demo

https://fetch-stream-audio.anthum.com/



Background

This repo provides low-latency web audio playback examples for programatically decoding audio in chunks with the Web Audio API and the new Fetch & Streams APIs. Traditionally, decodeAudioData() is used for programmatic decoding but requires the complete file to be downloaded, and chunk-based decoding is not supported. These Streams examples will show how to sidestep that limitation. Media Source Extensions could also be used to play audio and that example may be integrated here one day.

The examples demonstrate:

  1. Opus Streaming opus-stream-decoder is used to decode an Opus file in a Web Worker with WebAssembly. This simulates a real-world use case of streaming compressed audio over the web with the Web Audio API. (MP3 is old and outdated for those of us who grew up with WinPlay3. Opus is the new gold standard). This example is ideal because it allows for small, high-quality files with Opus.
  2. WAV Streaming A WAV file is streamed and decoded by a Web Worker. Chunks are scheduled into a read buffer before sending to encoder to ensure decoder receives complete, decodable chunks. JavaScript (not WebAssembly) is used for decoding. This example requires a much larger file.

Opus Playback Tests

Opus file playback can be tested at throttled download speeds and varkous encoding/bitrate qualities (Issue #14 will add to UI):

opusBitrate = 96; throttle = nolimit
opusBitrate = 96; throttle = 1mbps
opusBitrate = 96; throttle = 104kbps
opusBitrate = 96; throttle = 100kbps
opusBitrate = 64; throttle = 72kbps
opusBitrate = 60; throttle = 64kbps
opusBitrate = 53; throttle = 56kbps
opusBitrate = 32; throttle = 40kbps
opusBitrate = 28; throttle = 32kbps
opusBitrate = 12; throttle = 16kbps

Back-End Nginx Server

To use the config files, create symblink fetch-stream-audio, e.g.:

$ ln -s [LOCATION_TO_THIS_REPO]/.conf/nginx /etc/nginx/fetch-stream-audio

Then, include this repo's nginx config file into your server {} block, e.g.:

server {
  ...

  disable_symlinks off;
  include fetch-stream-audio/include-server.conf;
}

Throttled Bandwidth Endpoints

All /audio/* URIs are configured to intentionally limit download speeds and control response packet sizes for testing the decoding behavior (defined in include-server.conf). For example:

https://fetch-stream-audio.anthum.com/nolimit/opus/decode-test-64kbit.opus
https://fetch-stream-audio.anthum.com/10mbps/opus/decode-test-64kbit.opus
https://fetch-stream-audio.anthum.com/1.5mbps/opus/decode-test-64kbit.opus
https://fetch-stream-audio.anthum.com/512kbps/opus/decode-test-64kbit.opus

All Throttled Endpoints
Speed Example URL
16 kbps https://fetch-stream-audio.anthum.com/16kbps/opus/decode-test-64kbit.opus
24 kbps https://fetch-stream-audio.anthum.com/24kbps/opus/decode-test-64kbit.opus
32 kbps https://fetch-stream-audio.anthum.com/32kbps/opus/decode-test-64kbit.opus
40 kbps https://fetch-stream-audio.anthum.com/32kbps/opus/decode-test-40kbit.opus
56 kbps https://fetch-stream-audio.anthum.com/32kbps/opus/decode-test-56kbit.opus
64 kbps https://fetch-stream-audio.anthum.com/64kbps/opus/decode-test-64kbit.opus
72 kbps https://fetch-stream-audio.anthum.com/72kbps/opus/decode-test-64kbit.opus
80 kbps https://fetch-stream-audio.anthum.com/80kbps/opus/decode-test-64kbit.opus
88 kbps https://fetch-stream-audio.anthum.com/88kbps/opus/decode-test-64kbit.opus
96 kbps https://fetch-stream-audio.anthum.com/96kbps/opus/decode-test-64kbit.opus
100 kbps https://fetch-stream-audio.anthum.com/100kbps/opus/decode-test-64kbit.opus
104 kbps https://fetch-stream-audio.anthum.com/104kbps/opus/decode-test-64kbit.opus
112 kbps https://fetch-stream-audio.anthum.com/112kbps/opus/decode-test-64kbit.opus
120 kbps https://fetch-stream-audio.anthum.com/120kbps/opus/decode-test-64kbit.opus
128 kbps https://fetch-stream-audio.anthum.com/128kbps/opus/decode-test-64kbit.opus
160 kbps https://fetch-stream-audio.anthum.com/160kbps/opus/decode-test-64kbit.opus
192 kbps https://fetch-stream-audio.anthum.com/192kbps/opus/decode-test-64kbit.opus
256 kbps https://fetch-stream-audio.anthum.com/256kbps/opus/decode-test-64kbit.opus
384 kbps https://fetch-stream-audio.anthum.com/384kbps/opus/decode-test-64kbit.opus
512 kbps https://fetch-stream-audio.anthum.com/512kbps/opus/decode-test-64kbit.opus
768 kbps https://fetch-stream-audio.anthum.com/768kbps/opus/decode-test-64kbit.opus
1 mbps https://fetch-stream-audio.anthum.com/1mbps/opus/decode-test-64kbit.opus
4 mbps https://fetch-stream-audio.anthum.com/4mbps/opus/decode-test-64kbit.opus
5 mbps https://fetch-stream-audio.anthum.com/5mbps/opus/decode-test-64kbit.opus
2 mbps https://fetch-stream-audio.anthum.com/2mbps/opus/decode-test-64kbit.opus
3 mbps https://fetch-stream-audio.anthum.com/3mbps/opus/decode-test-64kbit.opus
4 mbps https://fetch-stream-audio.anthum.com/4mbps/opus/decode-test-64kbit.opus
5 mbps https://fetch-stream-audio.anthum.com/5mbps/opus/decode-test-64kbit.opus
6 mbps https://fetch-stream-audio.anthum.com/6mbps/opus/decode-test-64kbit.opus
7 mbps https://fetch-stream-audio.anthum.com/7mbps/opus/decode-test-64kbit.opus
8 mbps https://fetch-stream-audio.anthum.com/8mbps/opus/decode-test-64kbit.opus
9 mbps https://fetch-stream-audio.anthum.com/9mbps/opus/decode-test-64kbit.opus
10 mbps https://fetch-stream-audio.anthum.com/10mbps/opus/decode-test-64kbit.opus
nolimit https://fetch-stream-audio.anthum.com/nolimit/opus/decode-test-64kbit.opus
https://fetch-stream-audio.anthum.com/audio/opus/decode-test-64kbit.opus

Development & Building

Please remember that this is a proof-of-concept demo intended to show developers alternative (and possibly better) ways to play web audio. Currently, there's no formal package or release (see #21), so you'll need to improvise a little to get this working in your apps or websites.

I prefer Yarn, and you'll need Yarn or NodeJS installed to build the project. app.js is the entry point for starting with the code.

# clone repo and install dependencies
$ git clone https://github.com/AnthumChris/fetch-stream-audio
$ cd fetch-stream-audio
$ yarn install
# run the development server in "watch" mode to automatically re-build your changes
$ yarn dev
# build the project formally with minification
$ yarn build

Acknowledgements

Thanks to @bjornm for pointing me to @mohayonao's WAV decoder: https://github.com/mohayonao/wav-decoder

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].