abcjs icon indicating copy to clipboard operation
abcjs copied to clipboard

Select bars to loop them in player

Open airdev-web opened this issue 2 years ago • 3 comments

Hi @paulrosen ,

Here is a nice challenging feature

https://daily-drum.com/drum-notation-editor/editor So I upgraded the editor to be more efficient (clicking on bars show them in the grid editor, when adding a note, it highlight the concerned bar, autosave, history, fullscreen, ...)

With these new info (when clicking on bar, so I do now the bar index to select), I want to make a system that will allow users to select one or more bars to play them in loop. I saw on docs that you can do that with Synth, but I can't make it work with SynthController.

My idea was to re-create the abc notation with an hidden visualobj that I would use to generate the played, but I hope there is a cleaner way to do it :)

Also, I would like user to select a note, so the player will directly start from this note.

Any idea for these 2 features ?

Thanks a lot again for this awesome package Romain

airdev-web avatar Apr 25 '23 18:04 airdev-web

Hi @airdev-web I am doing same challenges in my JS file. I am using below code for start playing 1st beat of particular bar. currentActiveBarIndex index have your current active bar-index (start from 0, and till totalBar-1) ` let beatNumber = (currentActiveBarIndex * 4); let progressPercent = beatNumber / ((totalBars * 4) - 1); let totalTimeOfMusicSheet = ((totalBars * 4) - 1) * 1000;

console.log("progressPercent :-->", progressPercent); synthControl.setProgress(progressPercent, totalTimeOfMusicSheet); synthControl.play(); `

pandya293 avatar Apr 28 '23 07:04 pandya293

Hi @pandya293 ,

I tried your solution but i'm facing severals issues :

  • It's not really selecting the first beat of a bar? For a 2 bars with 16 notes per bar, it sets the % to around 57%, which should be 50% right?
  • When it finish playing the end of the notes, it's looping (because I set it like that), and playing notes twice with a small decay

I don't why know why this is happening, maybe @paulrosen will light us on that!

airdev-web avatar Apr 29 '23 19:04 airdev-web

Do you have prep beats? That will change the percentages a little - for instance if you have 8 measures, but 2 measures of intro then bar 4 is actually bar 6 of 10 measures.

Did you mean "delay" instead of "decay"?

@pandya293 's approach is the same approach I've used. It works pretty good but there is always the chance for latency. I find it is very reliable on my fast computer but we get reports from the field of delays. I don't think there is anything to do about that except make sure that the setProgress call is in the beat callback function with as little other code as possible.

It is true that I do this without the visual control. That shouldn't make any difference but if that adds any latency then that could be the delay you are seeing. I don't think that is related, though.

So, if the problem is the wrong thing is repeated, double check your calculations. If the problem is there is a delay before it repeats, do some performance testing and see if you have some javascript that can be moved.

paulrosen avatar May 06 '23 16:05 paulrosen