Giter Club home page Giter Club logo

webaudio-examples's Issues

Bug: Step-Sequencer Noise Duration 0 causes uncaught DOM exception

What information was incorrect, unhelpful, or incomplete?

TLDR: Noise Dur slider positions left of the midpoint break the step sequencer app

Noise Dur slider positions left of the midpoint cause the noiseBuffer AudioBuffer to be initialized with a length of 0 resulting in the following error:

Uncaught DOMException: Failed to construct 'AudioBuffer': The number of frames provided (0) is less than or equal to the minimum bound (0).

What did you expect to see?

Non-breaking functionality of the Noise Dur slider in the Step Sequencer

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

No response

Do you have anything more you want to share?

No response

change the output on mobile device

Hello,

I have the following question. For example, when I call the "Voice-change-O-matic" demo with an IPhone, the output is routed only to the phone speaker. But I would like to have the output to the "normal" speaker. The problem seems to occur only when the microphone is also enabled in the application. Is there a solution for this?

Thanks

Greetings Henri

Make headers in README.md consistent

I realized that the headers I added for the directory descriptions in #38 are not consistent.

(e.g. the header for the "audio-basics" directory is "Audio Basics" and the header for the "decode-audio-data" is "decodeAudioData"). I did this because some directory names are associated with a specific method, whereas others are more of a description.

For consistency purposes, I think it makes sense for all headers to be capital letters separated by spaces. If there is a method name associated with the directory, then it will appear in the description.

Thoughts on this, @chrisdavidmills?

[step-sequencer] The slider inputs to set the envelope of the "Sweep" sound are not working as expected

What information was incorrect, unhelpful, or incomplete?

The two sliders to set the envelope of the "Sweep" sound are not working as expected.
image

What did you expect to see?

There are actually 2 issues:

  1. For both inputs, the values are not updated properly. The input should update the value progressively with a 0.1 step, but it only updates to 0 or 1. The problem comes from that the value is cast into an int in the event listener callback.
const attackControl = document.querySelector("#attack");
    attackControl.addEventListener(
        "input",
        (ev) => {
             attackTime = parseInt(ev.target.value, 10);
        },
        false
);

Since their value are between 0 and 1 with a step of 0.1, the usage of "parseInt" is inadecuate.

<section class="controls">
  <label for="attack">Att</label>
  <input
    name="attack"
    id="attack"
    type="range"
    min="0"
    max="1"
    value="0.2"
    step="0.1"
  />
  <label for="release">Rel</label>
  <input
    name="release"
    id="release"
    type="range"
    min="0"
    max="1"
    value="0.5"
    step="0.1"
  />
</section>
  1. The way the release input works is not correct. When the slider is set to left, the release should be 0, whereas when it's set to the right, we should be able to hear the release.
    Your can try for yourself here:
    If you set the values like this you hear a sound that is plucked:
image

When you set it like this you hear a longer release:

image

It should be the other way around

The problem comes from the implementation of the envelope:

sweepEnv.gain.linearRampToValueAtTime(
  0,
  time + attackTime - releaseTime // here it shouldn't be a "-" operator
);

I'm currently going through the Web API guide where this step sequencer is used: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Advanced_techniques

Since I identified the 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

white noise live demo throws error

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/createBuffer

What specific section or headline is this issue about?

white noise live demo throws error in Chrome

What information was incorrect, unhelpful, or incomplete?

The white noise demo at https://mdn.github.io/webaudio-examples/audio-buffer/ produces an error: on the js console

Uncaught TypeError: Failed to construct 'AudioBuffer': Failed to read the 'length' property from 'AudioBufferOptions': Required member is undefined.
    at button.onclick ((index):35:22)

as a result, it plays no noise :(

What did you expect to see?

no error, white noise played

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

Chrome: Version 105.0.5195.52 (Official Build) beta (64-bit)
Windows 11 build : 22000.856

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Multi track example could have mixing capabilities

The Multi track example looks like it has potential for some mixing board features to be added. I'm looking for an example to contribute to, so I would be happy to add some functionality here if it would be helpful.

Some possible additions for the individual tracks:

  1. Volume faders
  2. Solo buttons
  3. Bypass buttons

Screen Shot 2020-12-02 at 3 24 22 PM

The mobile-responsiveness aspect makes it somewhat tricky to fit everything though:

Screen Shot 2020-12-02 at 3 34 06 PM

Perhaps it's best to keep it simple and start with just the volume faders and then add new issues for the additional features once this is complete? I can refer to the Boombox example for how to implement the faders using the same styling, functionality and responsiveness settings.

I think it makes sense to shrink the text and/or play button on page resize so the faders will all fit (mostly needed for the 'Lead Guitar' and 'Bass Guitar' tracks).

Example for cleanup

Hey there.
Thanks for all the nice examples.

Could you add an example for an <audio> element, how to unregister all the webaudio nodes, to get back to a normal audio element? Like to be able to register all that stuff again?

Chrome: missing audioCtx.resume()

I've noticed problem here: https://mdn.github.io/webaudio-examples/audio-buffer/

When I click button, nothing happens (using Chrome). I see error message:
The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page. https://goo.gl/7K7WLu.

I think, the click handler should start with audioCtx.resume() at

button.onclick = function() {
// Fill the buffer with white noise;
//just random values between -1.0 and 1.0

Some directories are missing in README.md

The "multi-track", "output-timestamp", and "spacialization" directories are missing from the README.md. I would like to write descriptions for these directories.

Voice-change-O-matic does not work on Safari iOS

Using an iPhone 14 Pro
iOS version: 16.1.2

I've attached a screenshot from the console output from the iPhone.
Screenshot 2022-12-25 at 23 40 29

I'm also attaching a screen recording to show what I did

RPReplay_Final1672008158.mov

Uncaught (in promise) DOMException: The element has no supported sources. line 101 in index.html in audio-basics.

What information was incorrect, unhelpful, or incomplete?

The audio-basics example does not work . Uncaught (in promise) DOMException: The element has no supported sources. line 101 in index.html in audio-basics.

What did you expect to see?

I was expecting the example to work.

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

No response

Do you have anything more you want to share?

No response

The element has no supported sources.

example of the example of basics stops at line 109: audioElement.play();
Web Tools of Chrome states: the element has no supported sources.
Something "basic" is missing. What could it be?

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

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 #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

python3 -m http.server returns wrong MIME type for javascript files causing samples not to work

in README.md it's suggested to run the samples with

python3 -m http.server

However this server returns the text/html MIME type for .js and .css files. Therefore, on Chrome the audioworklet sample does not work.

I now use this Python script, providing the correct MIME type for javascript and css files.

try:
    from http import server # Python 3
except ImportError:
    import SimpleHTTPServer as server # Python 2

if __name__ == '__main__':
    server.SimpleHTTPRequestHandler.extensions_map['.js'] = 'application/javascript'
    server.SimpleHTTPRequestHandler.extensions_map['.css'] = 'text/css'
    server.test(port=8114, HandlerClass=server.SimpleHTTPRequestHandler, protocol="HTTP/1.1")

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

How to preserve an audio's pitch after changing AudioBufferSourceNode.playbackRate?

I changed AudioBufferSourceNode.playbackRate using the code here https://github.com/mdn/webaudio-examples/blob/master/offline-audio-context-promise/index.html but found out that the pitch was not preserved.
I looked up the documentation and found out that there is no pitch correction when using AudioBufferSourceNode.playbackRate.

If we change an audio's playbackRate using HTML audio element, the pitch would be preserved. Is there a way that I can obtain the same effect?

https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode
Screen Shot 2021-09-21 at 5 57 37 PM

audioCtx.decodeAudioData(audioData, function(buffer) {
      myBuffer = buffer;
      source.buffer = myBuffer;
      source.connect(offlineCtx.destination);
      source.playbackRate = 1.5; // <<<<<<<<< added this to change playbackRate
      source.start();
      //source.loop = true;
      offlineCtx.startRendering().then(function(renderedBuffer) {
        console.log('Rendering completed successfully');
        
        let song = audioCtx.createBufferSource();
        song.buffer = renderedBuffer;

        song.connect(audioCtx.destination);

        play.onclick = function() {
          song.start();
        }
      }).catch(function(err) {
          console.log('Rendering failed: ' + err);
          // Note: The promise should reject when startRendering is called a second time on an OfflineAudioContext
      });
    });

decodeAudioData example does not work on Safari

-> https://mdn.github.io/webaudio-examples/decode-audio-data/

does not work on safari (Version 11.0.2 (11604.4.7.1.6) on OSX 10.11.6)

Steps to reproduce

  request.onload = function() {
    var audioData = request.response;

    audioCtx.decodeAudioData(audioData, function(buffer) {
        myBuffer = buffer;
        songLength = buffer.duration;
        source.buffer = myBuffer;
        source.playbackRate.value = playbackControl.value;
        source.connect(audioCtx.destination);
        //source.loop = true;

        loopstartControl.setAttribute('max', Math.floor(songLength));
        loopendControl.setAttribute('max', Math.floor(songLength));
      },

      function(e){"Error with decoding audio data" + e.err});   //<-- null is not an object

  }

In fact the error callback gets a null parameter.

audio-basics fails out of the box

pushing the play button results in:

index.html:81 Uncaught (in promise) DOMException: The element has no supported sources.

here:

audioElement.play();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.