Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone AudioWorkletProcessor #24

Open
Moebits opened this issue Aug 21, 2024 · 1 comment
Open

Standalone AudioWorkletProcessor #24

Moebits opened this issue Aug 21, 2024 · 1 comment

Comments

@Moebits
Copy link

Moebits commented Aug 21, 2024

Hello, using this I found it annoying how its a "psuedo-node" with it's own time scheduling, it can't be connected as part of a chain of AudioNodes. So I worked on refactoring the code into a standalone AudioWorkletProcessor.

Here is the file:
https://gist.github.com/Moebits/fc9ab7b56721e7e37d97417ed60cc2f9

Although I exposed all of "rate", "tempo", and "pitch" as parameters, only pitch will work; rate and tempo would need the buffer of the entire file.

Below is an example of using the worklet, with Tone.js library:

const context = Tone.getContext()
await context.addAudioWorkletModule(soundtouchURL, "soundtouch")
let soundtouchNode = context.createAudioWorkletNode("soundtouch-processor")
soundtouchNode.parameters.get("pitch").value = functions.semitonesToScale(state.pitch)

let gainNode = new Tone.Gain(1)
let audioNode = new Tone.ToneAudioNode()
audioNode.input = player
audioNode.output = gainNode.input
audioNode.input.chain(soundtouchNode, audioNode.output)
audioNode.toDestination()
@Mauro7b5
Copy link

Mauro7b5 commented Dec 6, 2024

Thank you, this has been useful, the pitchshifter node alone works way better than the tone.js alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants