Skip to content

Seeking forward in MIDI files doesn't resend PROGRAM CHANGE events #704

Closed

Description

@loki666

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

Activity

  1. christosts commented on Nov 10, 2023

    @christosts
    Contributor

    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

  2. loki666 commented on Nov 14, 2023

    @loki666
    ContributorAuthor

    midi_tests.zip

    Here it is,
    For Doom midi, there is a overrdrive guitar that plays the "melody", which clearly switch to Piano when seeking
    For scabbmap, the melody is a flute like instrument

    I made some more tests, and sometimes it works when seeking forward, and sometimes seeking backward also revert to piano.

  3. loki666 commented on Nov 15, 2023

    @loki666
    ContributorAuthor

    to check the behavior,

    add a logging function in MidiDecoder

        private void logMidiMessage(byte[] data, int offset, int count) {
            StringBuilder text = new StringBuilder("Received: ");
            if ((data[0] & 0xf0) == 0xc0) {
                text.append("PGM CHG ");
            }
            for (int i = 0; i < count; i++) {
                text.append(String.format("0x%02X, ", data[offset + i]));
            }
            Log.i("MidiDecoder", text.toString());
        }
    

    and call it before (or after)

    add a log in resetSynthesizers()

    you clearly see that PGM CHG events are not sent when seeking forward

  4. christosts commented on Nov 17, 2023

    @christosts
    Contributor

    thank you, I can reproduce this, we'll work on a fix

  5. christosts commented on Nov 22, 2023

    @christosts
    Contributor

    the linked commit should fix this. Would you be able to checkout the main branch and give it a try too?

  6. loki666 commented on Nov 22, 2023

    @loki666
    ContributorAuthor

    seems to do the trick !
    thanks

  7. locked and limited conversation to collaborators on Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions