Git Product home page Git Product logo

Comments (5)

guest271314 avatar guest271314 commented on August 24, 2024 1

This is not a proposal to get rid of module loading AudioWorklet, only to provide alternative methods of initiating AudioWorklet - the inline code will still be in, or create AudioWorkletGlobalScope - just not using (Ecmascript/JavaScript) modules.

from web-audio-api-v2.

padenot avatar padenot commented on August 24, 2024 1

This should be talked about at the EcmaScript and Worklet level before considering using it in Web Audio, this is not really a Web Audio API issue.

Using AudioWorklet without multiple source file and without doing any fetch is possible today however:

<script type="worklet">
registerProcessor('test-param', class param extends AudioWorkletProcessor {
  constructor() {
    super();
    console.log("ctor");
  }
  process(input, output, parameters) {
    return true;
  }
});
</script>
<script>
var ac = new AudioContext;
var source = document.querySelector("script[type=worklet]")
var text = source.innerText;
const blob = new Blob([text], {type: "application/javascript"});

var url = URL.createObjectURL(blob);
ac.audioWorklet.addModule(url).then(() => {
  var node = new AudioWorkletNode(ac, 'test-param');
});
</script>

Here I'm using a separate script tag, with a type of "worklet". If it's not a JavaScript MIME type (or is not omitted, like here), it's treated as a simple data block that is not executed, but using a simple string also works well.

from web-audio-api-v2.

guest271314 avatar guest271314 commented on August 24, 2024 1

This should be talked about at the EcmaScript and Worklet level before considering using it in Web Audio

@padenot I am banned from both WHATWG/HTML and TC39 so I will not be able to file issues at those entities.

Using AudioWorklet without multiple source file and without doing any fetch is possible today however:

If you run the code you posted at console at this page or any on github.com you will get CSP errors. I used Chromium DevTools Local Overrides to workaround the issue. However, there should be a means to load AudioWorklet without making a fetch request if we have the inline code already.

It is a Web Audio issue because in this case using Ecmascript module restricts the ability of AudioWorklet usage at the outset.

from web-audio-api-v2.

guest271314 avatar guest271314 commented on August 24, 2024

This should be talked about at the EcmaScript and Worklet level

I do not see how those specifications are controlling as to Web Audio.

Using AudioWorklet without multiple source file and without doing any fetch

A fetch request is made in the code example you posted at

var url = URL.createObjectURL(blob);
ac.audioWorklet.addModule(url)

what I propose is that an option exist to initiate AudioWorklet using inline code, without making any request.

from web-audio-api-v2.

guest271314 avatar guest271314 commented on August 24, 2024

What happens when a user tries to create an AudioWorklet instance on github.com for example this page using the code at #109 (comment)?

from web-audio-api-v2.

Related Issues (20)

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.