moinejf / abc2svg

project moved to https://chiselapp.com/user/moinejf/repository/abc2svg
GNU Lesser General Public License v3.0
48 stars 7 forks source link

play-1.js: add support for metronome + count-in #28

Open joaocc opened 7 years ago

joaocc commented 7 years ago

Hi, Do you have anything lined up to (optionally) play a metronome sound on top of the current generated sound? If this is the case, it would also be great to have a count-in of 1 or 2 bars (ie, just the metronome sound for 1 or 2 bars before starting the visual and audio). Thx

moinejf commented 7 years ago

I have no use of a metronome, but you can do it yourself: just replace play.js and add the metronome before the call to toaudio5.play (the audiocontext is in 'ac' in the 'conf' object ).

joaocc commented 7 years ago

How would you suggest we sync the metronome beats with the note outputs? Is there any callback that is being triggered on the tempo? Thx

moinejf commented 7 years ago

A simple solution: add a 'metronome' voice. In your version of play.js, wrap the AbcPlay method 'add()'. In add(), you get the symbol list which is sorted by time and the voice table. Then, add a voice, insert the metronome notes in this voice and lnsert these notes at the right time in the symbol list. For the metronome to start before the tune, shift all the 'time's of the symbols.

joaocc commented 7 years ago

Thx! We will look into that.

bwl21 commented 7 years ago

@joaocc did you implement @moinejf's proposal?

joaocc commented 7 years ago

Not yet. At this moment we have a "plain" metronome playing a bit before. However, we will probably do a "silent" count-in (1 or 1/2 bar), followed by a 1 bar with metronome, and then start the playalong. Also, at the moment, we don't know if we have the js-fu to implement it the way @moinejf suggested.