Tonejs / Tone.js

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

How to run a frequency sweep? #1208

Closed lane711 closed 5 months ago

lane711 commented 1 year ago

What is the proper way to run a frequency sweep? For example, I want to input: start frequency: 100Hz end frequency: 200Hz sweep rate: 1 Hz per second

and then generate a tone that goes from the start to end frequency at a rate of 1 Hz per second. So the above sweep would run for 100 seconds.

tambien commented 5 months ago

Something like this should work:

const oscillator = new Tone.Oscillator(100).toDestination()
oscillator.start();
// ramp to 200hz over 100 seconds
oscillator.frequency.rampTo(200, 100);