Skip to content

skipToTick() and co. simply ignores significant intermediate changes #44

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

Open
atsushieno opened this issue Jan 22, 2019 · 2 comments
Open

Comments

@atsushieno
Copy link

I have been lurking around the web to find how to implement seek operation in my MIDI player implementation (not in JS) and found that MidiPlayerJS offers skipToTick() feature.

skipToTick(tick) {

It is cool, but it doesn't make sense if you simply ignore any intermediate MIDI events such as program changes, control changes, pitchbend and so on. They should be processed accordingly. It is most likely that only notes can be simply ignored.

(I'm not a user of your library ATM, but wanted to share my findings.)

@grimmdude
Copy link
Owner

Hi @atsushieno,

Thanks for your message. I agree, that approach might not be the best way to go. I think that was an attempt at seek functionality that I couldn't get to work quite properly. I haven't had time lately to tackle again, but would like to when I'm available.

Best of luck to you on getting something similar working in your implementation. Send a link if you got it.

-Garrett

@atsushieno
Copy link
Author

I have my own MIDI player in C# https://github.com/atsushieno/managed-midi/blob/master/lib/base/MidiPlayer.cs - It is designed in very similar mindset to MidiPlayerJS, leaving any platform-specific backend parts to MIDI player "events". (There is a handful of nasty workarounds and known issues, so I wouldn't recommend it as a reference material so far.)

A hacky way to achieve that is to break current play, send "all sound off" (CC 120) and restart from scratch, and skip wait operation for delta time with any MIDI message except for note on/off ones, until it passes beyond the specified ticks.

A decent way is to do above plus preserve "last changed" messages to each MIDI messages and flush the last ones at the end (so that you can skip a lot of pitchbend, expression, and so on). However it may result in unexpected messaging for MIDI player adapters like MidiPlayerJS (for example what if we have a "event-logging player backend", it wouldn't like skipped events).

I only have hacky implementation so far, but it seems to work without glitch.

Just my two cents :-)

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

2 participants