-
Notifications
You must be signed in to change notification settings - Fork 433
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
Seeking forward in MIDI files doesn't resend PROGRAM CHANGE events #704
Comments
Can you please share a specific MIDI file that we can reproduce the issue? I've tried several MIDI files but can't repro. I hear all the instruments regardless of seeking forwards or backwards. Thanks |
Here it is, I made some more tests, and sometimes it works when seeking forward, and sometimes seeking backward also revert to piano. |
to check the behavior, add a logging function in MidiDecoder
and call it before (or after) media/libraries/decoder_midi/src/main/java/androidx/media3/decoder/midi/MidiDecoder.java Line 163 in 35219ee
add a log in resetSynthesizers() you clearly see that PGM CHG events are not sent when seeking forward |
thank you, I can reproduce this, we'll work on a fix |
This change fixes a bug with seeking forward in MIDI. When seeking forward, the progressive media period attempts to seek within the sample queue, if a key-frame exists before the seeking position. With MIDI, however, we can only skip Note-On and Note-Off samples and all other samples must be sent to the MIDI decoder. When seeking outside the sample queue, the MidiExtractor already instructs the player to start from the beginning of the MIDI input. With this change, only the first output sample is a key-frame, thus the progressive media period can no longer seek within the sample queue and is forced to seek from the MIDI input start always. Issue: #704 #minor-release PiperOrigin-RevId: 584321443
This change fixes a bug with seeking forward in MIDI. When seeking forward, the progressive media period attempts to seek within the sample queue, if a key-frame exists before the seeking position. With MIDI, however, we can only skip Note-On and Note-Off samples and all other samples must be sent to the MIDI decoder. When seeking outside the sample queue, the MidiExtractor already instructs the player to start from the beginning of the MIDI input. With this change, only the first output sample is a key-frame, thus the progressive media period can no longer seek within the sample queue and is forced to seek from the MIDI input start always. Issue: androidx/media#704 #minor-release PiperOrigin-RevId: 584321443
the linked commit should fix this. Would you be able to checkout the main branch and give it a try too? |
seems to do the trick ! |
This change fixes a bug with seeking forward in MIDI. When seeking forward, the progressive media period attempts to seek within the sample queue, if a key-frame exists before the seeking position. With MIDI, however, we can only skip Note-On and Note-Off samples and all other samples must be sent to the MIDI decoder. When seeking outside the sample queue, the MidiExtractor already instructs the player to start from the beginning of the MIDI input. With this change, only the first output sample is a key-frame, thus the progressive media period can no longer seek within the sample queue and is forced to seek from the MIDI input start always. Issue: #704 PiperOrigin-RevId: 584321443 (cherry picked from commit ec08db4)
Version
Media3 pre-release (alpha, beta or RC not in this list)
More version details
release-1.2.0-alpha01
Devices that reproduce the issue
Not device specific, so emulator, Pixel etc...
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
Using demo app with MidiExtract and MidiRenderer
Open a MIDI file
Seek forward in the file, and all channels are reset to default program (usually Piano)
Seek backward in the file, and all channels are properly configured back.
I've put some logs, and it seems indeed, that when seeking forward, MidiDecoder reset the Synthesizer but never sends the PROGRAM CHANGES events, but does so when seeking backward.
Expected result
MIDI channels are properly configured back after seeking forward
Actual result
MIDI channels are reset to default program (Piano) after seeking forward
Media
Not applicable, any MIDI file should expose the issue
The text was updated successfully, but these errors were encountered: