Tonejs / Tone.js

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

Apply a filter to a subsection of a AudioBuffer #1217

Closed KevinXZX closed 2 months ago

KevinXZX commented 7 months ago

Hello,

I was wondering if there's a way to apply a filter e.g. low-pass filter only on a specific interval of an audio buffer. For instance, an example would be having a low-pass filter from 0s to 5s then a high-pass filter from 5 to 10s and lastly shifting the pitch for the last 5s.

Is this possible/a supported functionality?

One of the ways I was considering doing this was splitting the audiobuffer myself using the slice method and using multiple Player objects to play them one after the other using the onstop callback however this results in a noticeable gap in the audio.

Thanks.

dirkk0 commented 7 months ago

To my knowledge this is out of scope for ToneJS. If I were to tackle this problem, I would try to access the WebAudio buffers 'under the hood' directly and slice them there. This could be a starting point, but I didn't try this myself yet: https://miguelmota.com/bytes/slice-audiobuffer/

On Thu, Nov 16, 2023 at 12:53 PM KevinXZX @.***> wrote:

Hello,

I was wondering if there's a way to apply a filter e.g. low-pass filter only on a specific interval of an audio buffer. For instance, an example would be having a low-pass filter from 0s to 5s then a high-pass filter from 5 to 10s and lastly shifting the pitch for the last 5s.

Is this possible/a supported functionality?

One of the ways I was considering doing this was manually splitting the audiobuffer myself and using multiple Player objects to play them one after the other using the onstop callback however this results in a noticeable gap in the audio.

Thanks.

— Reply to this email directly, view it on GitHub https://github.com/Tonejs/Tone.js/issues/1217, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEYV4UAAYUDJB6HJRYVHHLYEX5CLAVCNFSM6AAAAAA7OAW5Q6VHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TMNRYHA4TONI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

tambien commented 2 months ago

Another way to do it would be to render the audio file with Offline. Create two audio sources, one connected to a lowpass filter and another connected to a highpass filter. Then schedule both audio files to play with a matching offset/start time so that they play one after the other. the resulting audio will have the affect as if the first 5 seconds are lowpassed and the second 5 seconds are highpassed.