I'm trying to create a metronome with Typescript.
I have this javascript code:
(function theLoop (i) {
setTimeout(function () {
metronome.play();
if (--i) {
theLoop(i);
}
}, 3000); // interval set to 3000
})(10); // play it 10 times
And I wanted to convert it into Typescript code. Unfortunately I don't know how to do this (espacially regarding the last line => })(10);
Can someone help me with this?
metronome.changeTempo(bpm); metronome.onTick(function () { if (...) metronome.stop(); }); metronome.play();. You could also have a built-in feature specific to ticking a number of times.metronome.tick(10).classkeyword and examples on how to use it. Metronome would be a class here, not an Audio file. It could take an audio as a constructor parameter though..let metronome = new Metronome(new Audio('tick.mp3')).