paulrosen / abcjs

javascript for rendering abc music notation
Other
1.94k stars 285 forks source link

How to loop between two measures #845

Open ehsansh opened 2 years ago

ehsansh commented 2 years ago

Hi, I am using your full-synth example. I had a look on your play on repeat example and in full synth example I changed the code:

midiBuffer
            .init({
                visualObj: visualObj[0],
                options: {
                    qpm: 100,
                    soundFontUrl: '/FluidR3_GM/',
                },
            }).
.then(function (response) {
                if (synthControl) {
                    synthControl
                        .setTune(visualObj[0], true, audioParams.options)
                        .then(function (response) {
                            synthControl.seek(4, 'beats');
                        })
                        .catch(function (error) {
                            console.warn('Audio problem:', error);
                        });
                }
            })

When I click on the play button music piece starts playing from the beat that I want and to stop this I change cursorController code:

cursorControl.onBeat = function (beatNumber) {
        var end = 8;
        if (beatNumber >= end) {
            synthControl.seek(4, 'beats');
            synthControl.pause();
        }
    };

And it works correctly it returns to the beat that starts. But when I want to play the music for the second time. Clicking the play button does not work,after clicking again it does not start from 4 beat it starts from 8 or 16 beat. I saw in some examples TimingCallbacks function but this function is not used in full-synth example. How could I solve it?

paulrosen commented 1 year ago

I'm not sure. I'd have to debug. Is there anything in the console?

paulrosen commented 1 year ago

Did you ever figure this out?