You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello i'm trying to put together an audio input example so i could calculate the BPM of a track playing through my line in ( or even microphone input ).
Unfortunately i didn't understand exactly how the "time" parameter from the "process" method is supposed to be used ( specially in that case, where i don't necessarily know when the track changes, etcs ).
Here is some code i put together trying to solve this puzzle using the lovely p5.js library, please let me know how i could tweak this to achieve the desired effect.
Thank you for such amazing project,
<script src="js/p5-zip/p5.js"></script>
<script src="js/p5-zip/addons/p5.sound.js"></script>
<script src="js/beatdetektor-master/beatdetektor.js"></script>
<script>
// beatdetektor stuff
bd_med = new BeatDetektor(85,169);
vu = new BeatDetektor.modules.vis.VU();
kick_det = new BeatDetektor.modules.vis.BassKick();
// p5 stuff
mic = new p5.AudioIn();
mic.start();
fft = new p5.FFT();
fft.setInput(mic);
funk = function(){
spectrum = fft.analyze();
bd_med.process( (new Date).getTime(), spectrum)
}
// analyse with 60 frames, we could maybe use requestAnimationFrame here
setInterval( funk, 1000/60 )
</script>
The text was updated successfully, but these errors were encountered:
@h2o- sorry didn't catch this issue til now -- the time is just the time in seconds (floating point) for the current spectrum frame.
For the microphone you'd probably want to use the time since recording started (sample_time - start_time) and for an audio track you can use the current playback time for the given sample. If you move the time backwards just remember to call reset() first, and starting at 0 is not necessary.
There's no built-in track change detection but it will follow tempo changes -- though it follows more slowly when it's recently had a solid BPM match and tempo changes abruptly.
If you know you're going to want to reset detection (such as a playlist change event) just use the bd_med.reset() function to reset state and start again.
Hello i'm trying to put together an audio input example so i could calculate the BPM of a track playing through my line in ( or even microphone input ).
Unfortunately i didn't understand exactly how the "time" parameter from the "process" method is supposed to be used ( specially in that case, where i don't necessarily know when the track changes, etcs ).
Here is some code i put together trying to solve this puzzle using the lovely p5.js library, please let me know how i could tweak this to achieve the desired effect.
Thank you for such amazing project,
The text was updated successfully, but these errors were encountered: