christosts ec08db458e MidiExtractor: mark only the first sample as key-frame
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
2023-11-21 07:39:46 -08:00
..
2023-10-18 03:42:47 -07:00

MIDI decoder module

The MIDI module provides MidiExtractor for parsing standard MIDI files, and MidiRenderer which uses the audio synthesization library JSyn to process MIDI commands and render the PCM output.

Getting the module

The easiest way to get the module is to add it as a gradle dependency:

implementation 'androidx.media3:media3-exoplayer-midi:1.X.X'

where 1.X.X is the version, which must match the version of the other media modules being used.

Alternatively, you can clone this GitHub project and depend on the module locally. Instructions for doing this can be found in the top level README.

The module depends on JSyn as a maven dependency from jitpack.io and you will need to define the maven repository in your build scripts. For example, add

repositories {
    maven { url 'https://jitpack.io' }
}

in the build.gradle of module in your app that is using the MIDI module.

Use in the demo app

Modify the demo app's build.script file and uncomment the definition of the jitpack.io maven repository, as well as uncomment the dependency to the MIDI module in the dependencies section.