Search code examples
web-audio-api

How to make an input range slider span an octave(s) when triggering oscillator


I don't understand how to programmatically hitch the formula 440×2n/12 to the input range slider to set the frequency of an oscillator in 12 step western scale increments. I set the range slider from 1 to 12.

This is as far as I've made it..blah.

<input id='input' type='range' min='1' max = '12' step=''></input>

oscillator.frequency.value = ($('#input').val() //(math stuff);   

Solution

  • Answer

    <input id='input' type='range' min='100' max = '1200' step='100'></input>
    
    
        oscillator.frequency.value =  440  ;   
        oscillator.detune.value = $('#input').val();