The sounds of JS

Four ways to play sounds

Notes from numbers

440Hz

880Hz

const scaleHeight = (
        num,
        inMax = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) //viewport height
    ) => {
    const scaleMap = num * 24 / inMax;

    const hertz = ROOT_NOTE * Math.pow(1.059463094359, scaleMap);
    return hertz; 
}
function setNote(freq) {
    // we want oscillator to be initialised when we change it
    if (isPlaying) {
        o.frequency.setValueAtTime(freq, context.currentTime);
    }
}

Numbers from Notes

Plugs

tenzhiyang.com/2020-09-30-music-in-browser-basics/

tenzhiyang.com/2020-10-13-ways-to-play-sound/

tenzhiyang.com/2019-11-15-synth-til-it-hertz/

slides.com/tzyinc

codepen.io/tzyinc

twitter.com/tzyinc

The sound of js

By tzyinc

The sound of js

  • 509