~/talk

Play Them Off, Keyboard App: Building a virtual piano in JavaScript

Talkat JSCAMP Virtual 2021 · 2021-07-15..07-16· [creative-coding]
slides:none on file

A browser-based virtual piano uses the Web Audio API with createPeriodicWave and multiple oscillators to play chords, scales and sustain; frequencies come from a calculation anchored to A4 = 440 Hz and semitone steps, arrays generate octaves and scale intervals, playback staggers notes with half-second timeouts, UI is a React port of piano‑svg with per‑key event handlers, accessibility adds role=button and manual tabindex ordering, audio quirks include using a promise to wait for oscillator initialization because oscillators sometimes fail to stop, and the waveform is a piano-like periodic wave lifted from Chrome Labs.

AI-written summary · about

  1. 0:00Start
  2. 2:56Sound waves and frequency
  3. 5:40Octaves and pitch
  4. 8:47What can the API do?
  5. 9:32What do we need to build?
  6. 9:55Setting up the Audio Context
  7. 10:25Creating a waveform
  8. 11:32Creating an oscillator
  9. 12:18Calculating the frequency
  10. 13:15Intervals
  11. 14:48Example: finding the frequency
  12. 15:30Building the piano
  13. 16:37Playing the notes
  14. 18:10Generating a scale
  15. 19:23Playing the scale
  16. 20:00Teething problems
  17. 22:23Let's play!
  18. 23:17Learn more about Web Audio
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.