Tonejs / Tone.js

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

How to get the number of examples being processed? #207

Closed edap closed 7 years ago

edap commented 7 years ago

Hello. I'm using your library to make a 3d visualization of a song. I'm trying to implement onset detection on multiple frequencies looking at the spectral flux, like explained here http://www.badlogicgames.com/wordpress/?p=161. I've already implemented it in the past using Maximilian.

The thing that is not clear to me is how to get the number of the examples processed in tone.js.

tambien commented 7 years ago

To do onset detection, you'll want to take a look at the ScriptProcessorNode which has been deprecated, in favor of the AudioWorkerNode (which is not yet implemented in any browsers). This lets you set the block size (the number of samples that are processed in each chunk).

Otherwise the block size is fixed by the Web Audio API at 128 samples.