Tone.js – A framework for making interactive music in the browser
11–20 of 27 posts
Re: Tone.js – A framework for making interactive music in the browser
#12I was thinking earlier today of creating an F1 engine note simulator. I would want to play with the number of cylinders, v angle, crank offset (v8 normal crank/180 crank) and maybe some kind of exhaust system variables (tuned length, crossover pipe), and of course RPM. I don't know where to start, could you point me at the type of programming I would want to look at to figure out how to do this?
Here is an f1 car engine playing God Save the Queen [1], sounds atrocious, but still cool.
Re: Tone.js – A framework for making interactive music in the browser
#13One interesting thing to me about Tone.js has always been that their “Transport” API is a more reliable interval/timer tool than any of the native JS APIs or even libraries/polyfills designed around more accurate interval timing. I’d almost be surprised if I wasn’t wrong about this but I searched and couldn’t find anything quite comparable.
It has sample-level precision, just like the Web Audio API provided by the browser (which is what's used under the hood). It's pretty much independent of non-audio time APIs.
Re: Tone.js – A framework for making interactive music in the browser
#14Re: Tone.js – A framework for making interactive music in the browser
#15Re: Tone.js – A framework for making interactive music in the browser
#16Earlier quoted context omitted.
It has sample-level precision, just like the Web Audio API provided by the browser (which is what's used under the hood). It's pretty much independent of non-audio time APIs.
Interesting, makes sense. I wonder — is setInterval not as precise because it doesn’t really need to be (and thus it’d be a waste of complexity to be that precise)?
That is, if you set up a Tone transport to fire events every 100ms, it's not like your event handler gets called precisely 100ms later. Rather, it gets called early - say 85ms later - with a parameter saying "hey that event you wanted is precisely 14.7803ms away". Then you can call an API saying "okay, play a tone 14.7803ms from now", and Tone passes that along to web audio, and the end result is that your note plays with sample-level precision.
But if you used Tone's transport to do something other than calling web audio APIs it wouldn't be any more precise than setInterval. (IIRC Tone actually uses setInterval to fire its events.)
Re: Tone.js – A framework for making interactive music in the browser
#17Earlier quoted context omitted.
Interesting, makes sense. I wonder — is setInterval not as precise because it doesn’t really need to be (and thus it’d be a waste of complexity to be that precise)?
It's not that Tone is more precise than setInterval, it's that the web audio APIs underneath are precisely scheduled, and Tone provides an interface to them. That is, if you set up a Tone transport to fire events every 100ms, it's not like your event handler gets called precisely 100ms later. Rather, it gets called early - say 85ms later - with a parameter saying "hey that event you wanted is precisely 14.7803ms away…
Re: Tone.js – A framework for making interactive music in the browser
#18I used Tone.js to create my music theory website https://www.lightnote.co/ Using recordings from my guitar (of each and every note) I was able to build an interactive fretboard that could play guitar tabs/chords. Also the Transport API made it simple to build a drum looping machine very quickly. Ableton has built something similar, also using Tone.js: https://learningmusic.ableton.com/make-beats/make-beats.html Perfo…
Just tried https://www.lightnote.co/ . Thank you for making it, I really love it.