mdn / webaudio-examples

Code examples that accompany the MDN Web Docs pages relating to Web Audio.
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
Creative Commons Zero v1.0 Universal
1.28k stars 433 forks source link

[step-sequencer] The slider input to set the DTMF rate is not working as expected #118

Closed ManuLintz closed 8 months ago

ManuLintz commented 11 months ago

What information was incorrect, unhelpful, or incomplete?

This input doesn't behave as it should: image

What did you expect to see?

When setting the slider like this, we don't hear anything anymore (here):

image

The problem comes from that the value is cast into an int in the event listener callback (also happens in https://github.com/mdn/webaudio-examples/issues/117).

rateControl.addEventListener(
  "input",
  (ev) => {
    playbackRate = parseInt(ev.target.value, 10);
  },
  false
);

It was written to have a 0.1 step:

<section class="controls">
  <label for="rate">Rate</label>
  <input
    name="rate"
    id="rate"
    type="range"
    min="0.1"
    max="2"
    value="1"
    step="0.1"
  />
</section>

Since I identified what causes the issue in the code I'd be happy to work on a fix + updating the doc.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

bsmth commented 10 months ago

Thanks a lot for reporting it! There's a PR open which should fix this

Since I identified what causes the issue in the code I'd be happy to work on a fix + updating the doc.

Sorry I missed this, would you like to update the doc after this is merged?

ManuLintz commented 10 months ago

Yes sure, I'd love to

bsmth commented 10 months ago

Great, feel free to ping me on the PR when you get around to it.