Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it impossible to pause when using noteon noteoff instead of player #252

Open
ysfgmissbless opened this issue Mar 26, 2020 · 3 comments
Open

Comments

@ysfgmissbless
Copy link

Is it impossible to pause when using noteon noteoff instead of player?or it can pause only when using player.load(xxx.midi)?

@hmoffatt
Copy link

Your question doesn't make any sense. If you are using noteon/noteoff then you are responsible for timing, so you can pause in your code.

@ysfgmissbless
Copy link
Author

ysfgmissbless commented Mar 27, 2020

Your question doesn't make any sense. If you are using noteon/noteoff then you are responsible for timing, so you can pause in your code.

Thanks for your reply,I didn't describe it clearly
I add two buttons in my page, play and pause, when click play button ,I put some notes to a notearray, and use noteon/noteoff to play sounds in circle, and when click pause button, I don't know how to pause these sound
Below is logic in play button:
var song = Util.convertToMidiPianoFormat(that.beatArray,that.selectedKey);
var delay = 0;
var velocity = 10; // how hard the note hits
for(let i in song){
MIDI.noteOn(0, song[i][0], velocity, delay);
delay = delay + song[i][1];
MIDI.noteOff(0, song[i][0], delay);
}

@shivrajsa
Copy link

@ysfgmissbless You may try this ugly solution :-). Call this function on click of pause button. If required you can increase the maximum loop value.

`function stop() {
    for (var i = 1; i < 9999; i++)
    {
        window.clearTimeout(i);
        window.clearInterval(i);
    }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants