• Stars
    star
    576
  • Rank 77,502 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Web Audio metronome example to show scheduling.

Web Audio Metronome

This application shows how to use a collaboration between a setTimeout scheduler and the Web Audio scheduler to properly implement rock-solid timing for audio applications.

I added some code to this demo after writing the article on web audio scheduling that now resides at https://web.dev/audio-scheduling/.

This code was added because Chrome (and other browsers) made a power-saving change to throttle JS timers at one point, so if the page was not visible (e.g. a tab that you tabbed away from), it would only have setTimeout timers delivered once a second. Timers in worker threads were not throttled, so I set up a worker thread to ping the main thread (which does the audio scheduling).

Since that time, I believe the code I wrote is actually no longer necessary, because based on ANOTHER change audible audio should prevent the throttling, so for this application setTimeout on the main thread would work just fine. (Jake Archibald wrote an article in early 2021 outlining the current state of affairs at https://developer.chrome.com/blog/timer-throttling-in-chrome-88/.) I have not yet tested this assumption or removed the code yet, however.

Check it out, feel free to submit issues or requests, fork, submit pull requests, etc.

The live app is at https://cwilso.github.io/metronome/.

-Chris

More Repositories

1

PitchDetect

Pitch detection in Web Audio using autocorrelation
JavaScript
1,295
star
2

midi-synth

A MIDI-driven Web Audio synthesizer
HTML
584
star
3

Audio-Input-Effects

Live input Web Audio effects
JavaScript
539
star
4

WebAudio

Web Audio API Playground
JavaScript
492
star
5

volume-meter

Simple example of implementing a clip-detecting volume meter in Web Audio.
JavaScript
425
star
6

AudioRecorder

Simple live audio file recorder, based on RecorderJS
JavaScript
420
star
7

WebMIDIAPIShim

Polyfill using the Jazz NPAPI MIDI plugin to implement the Web MIDI API on Mac and Windows.
JavaScript
380
star
8

Vocoder

Naive WebAudio Vocoder
JavaScript
341
star
9

MIDIDrums

MIDI version of Shiny Drum Machine
JavaScript
339
star
10

AudioContext-MonkeyPatch

Monkeypatch to use proper AudioContext naming on prefixed/deprecated named systems.
JavaScript
144
star
11

wubwubwub

Audio experiments
JavaScript
95
star
12

webkitAudioContext-MonkeyPatch

Monkey-patching library to make apps using deprecated Web Audio syntax work in conforming implementations.
JavaScript
53
star
13

monosynth

A monophonic Web Audio synthesizer driven by Web MIDI
HTML
45
star
14

Audio-Buffer-Draw

Draws a Web Audio AudioBuffer to a canvas
JavaScript
43
star
15

web-audio-samples

Port of http://chromium.googlecode.com/svn/trunk/
31
star
16

Standard-MIDI-File-reader

A test JS/HTML app to decode Standard MIDI Files
JavaScript
29
star
17

SynthTemplate

Synthesizer template
JavaScript
26
star
18

webaudiodemos

source for webaudiodemos
JavaScript
25
star
19

conway

Conway's Game of Life
JavaScript
25
star
20

Drumr

Drumpad/drum machine project.
JavaScript
8
star
21

SMFPlayer

MIDI reader/sequencer
JavaScript
8
star
22

WebAudioSlides

CSS
7
star
23

webmusicplatform

Platform for creating Web Music
CSS
7
star
24

Lupr

Looping metronome/sampler/sequencer/appegiator
JavaScript
5
star
25

AmazonTV

Prototype Amazon interface for TV
JavaScript
4
star
26

TestRecorder

JavaScript
3
star
27

badmetronome

The WRONG way to implement timing for audio applications.
JavaScript
3
star
28

life

temp project
JavaScript
3
star
29

testpages

CSS
2
star
30

AC2023

AC2023 slides
HTML
2
star
31

TPAC_incubation

HTML
1
star