[ALPHA] MIDI Player Extension - Testers Needed

AVMIDIPlayer Extension (Alpha)

An extension for playing MIDI files. This is currently in alpha; please see below for a list of features and bugs. The function names are currently intended to match that of Apple’s AVMIDIPlayer; however, this is subject to change upon release.

This extension uses KyoSherlock’s MidiDriver library, which is licensed under the Apache License.

Blocks

Methods

  • Init(contentsOf, soundBankURL): Initializes the component with the contents of the MIDI file specified by the path, using the specified sound bank (SF2). This MUST be called before doing anything else, and to change the loaded MIDI or sound bank file. File paths can be used in the same way as the ReadFrom method of the File component (docs).
  • Play(): Plays the sequence.
  • Stop(): Stops playing the sequence.

Events

  • Completed(): A block to be called when a MIDI playback request is completed. This currently is never called. Fixed.

Properties

  • boolean IsPlaying() get: A Boolean value that indicates whether the sequence is playing.
  • long Duration() get: The length of the currently loaded file, in seconds.
  • long CurrentPosition() get set: The current playback position, in seconds.
  • float Rate() get set: The playback rate of the player.

Known Issues

  • You cannot currently access packaged assets (a path starting with two slashes will throw an UnsupportedOperationException, since I haven’t implemented this yet). One workaround is to use the Web component to download the files you need to external storage or to the private user data directory and access them from there. Fixed.
  • Friendly error handling is buggy right now - please use adb logcat

Downloads

Alpha 3

AIX: (coming soon)

Example AIA

AIA: (will return soon)

Feel free to reply with any feedback, questions, comments, and/or concerns you may have.

7 Likes

Post updated with example blocks.

1 Like

New update: alpha 2. Testers are needed!
AIX is linked above, and an AIA is coming soon.

2 Likes

Am I using the blocks correctly?

Screenshot_20200320-071448_Chrome

1 Like

Yes, that’s correct. I’ve also uploaded an example AIA so you can see how I have implemented scrubbing, repeat mode, etc.

Unfortunately with those blocks I receive:

I will try your .aia asap.

Can you post output of adb logcat?
Also try adb logcat | grep AVMIDIPlayer if you’re on macOS or linux.

Your example .aia doesn’t error like mine but I don’t hear any audio.

I am currently just on my phone and don’t have access to my PC.

I will try to get the log this weekend.

Looks like the error you’re facing is an issue with your blocks, then. Can you send me your full AIA?

As for the no audio issue, I will look into it soon and reply once I’ve found some info.

1 Like

MidiTest.aia (662.0 KB)

I’m not experiencing any issues with your AIA.
As for the no audio issue, would you be able to try this?

[deleted]

1 Like

With new .aix I get Error 0 and the slider doesn’t move, with previous .aix the slider moved and I didn’t receive Error 0:

What device and OS are you using?

I am using a Samsung Galaxy S8 running Android OS v9.0.

I’m using the Android SDK Emulator with 10.0.

It looks like there is a bug in the library I’m using*, which is why you aren’t hearing audio. I thought the change I made would fix this, but no (it didn’t work on the emulator, but I figured that it would work on real hardware). Will need to investigate further and see what I can do.

EDIT: It looks like I need to do some extra work: https://github.com/kshoji/javax.sound.midi-for-Android/issues/2

* …which makes it impossible to link the Sequencer (reads MIDI data) to the Synthesizer (plays back samples)

1 Like

Try this and tell me if it works. You should see a toast saying “Init successful” once you initialize the player.

[deleted]

1 Like

I get the “Init successful”:

However I still don’t have any audio.