atsushieno / ktmidi

Kotlin multiplatform library for MIDI access abstraction and data processing for MIDI 1.0, MIDI 2.0, SMF, SMF2 (MIDI Clip File), and MIDI-CI.
MIT License
70 stars 7 forks source link

revamp the device change detection events #43

Closed atsushieno closed 7 months ago

atsushieno commented 1 year ago

Regarding #38, we need a working mechanism for device change detection. I mean, it is not working now. Here is the current API definition:

abstract class MidiAccess {
    open val canDetectStateChanges = false
    var stateChanged : (MidiPortDetails) -> Unit = {}

This API structure is taken from Web MIDI API. However, their MidiPort and our MidiPortDetails are quite different. Namely, our MidiPortDetails is not "live". We do not have their state property which can be "disconnected" or "connected".

Passing only MidiPortDetails means that we cannot really report "device added" and "device removed". Or it can be even "device changed" (of some properties), but I have no right idea what could change, on each platform.

In either way, we will have to deprecate this stateChanged and introduce another property.

atsushieno commented 7 months ago

It is finally taken care at 2bfe412.