Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Unable to 'connect' Filter to a Player. #1105

Closed aMadReason closed 2 years ago

aMadReason commented 2 years ago

Unable to 'connect' Filter to a Player.

Referencing the docs here: https://tonejs.github.io/docs/14.7.77/Filter I should be able to 'connect' a lowpass filter to a player, but it doesn't seem to apply.

I can only apply the filter using chain. Is this a bug or am I doing something stupid?

To Reproduce

https://codesandbox.io/s/sound-player-b3ujv8?file=/src/index.js

Expected behavior I expect to be able to connect and disconnect a filter to a player while that player is started.

What I've tried I can get it working using chain, but that doesn't let me disconnect only the filter from the player.

Additional context Using 14.7.77

Sorry if I've misunderstood something.

cephasteom commented 2 years ago

Evening!

It looks like you're connecting your filter to the output, and the player itself - which results in it sounding like the filter has no effect.

This should work

const player = track2;
const filter = new Tone.Filter(300, "lowpass").toDestination(); // you've connected your filter to your destination
player.connect(filter) // so there's no need to connect your player there as well

Hope that helps!

aMadReason commented 2 years ago

Haha, had a feeling I was doing something stupid. Thanks!!