philburk / android-midisuite

Android MIDI test programs and examples.
Apache License 2.0
153 stars 53 forks source link

Kotlin version? #71

Open happypennygames opened 2 years ago

happypennygames commented 2 years ago

Good evening, Do you plan on converting these to kotlin form at any point? I've spent hours pouring over the android docs which are java centric as well as your examples, and while it seems I can get 80% of the way there with the android studio auto convert, ultimately, nothing works. I know it's software and not hardware as both the midi pairing and midi scope apps on the playstore work just fine with my keyboard. Thank you.

I've encountered everything from small unresolveable issues with work arounds e.g. this filter removes the keyboard from the list, yet in your app source code the filter exists and the app shows up. my solution: no filters but then I see every possible bluetooth device in the vicinity.

        val deviceFilter: BluetoothDeviceFilter = BluetoothDeviceFilter.Builder()
            .addServiceUuid(ParcelUuid.fromString("03B80E5A-EDE8-4B33-A751-6CE34EC4C700"), null)
            .build()

to more serious problems: I can pair to and see the bt device and even open it e.g. getting as far as this callback and null check pass- but pressing keys on the keyboard doesn't trigger any printouts.

    private fun onBluetoothDeviceOpen(
        bluetoothDevice: BluetoothDevice,
        midiDevice: MidiDevice?
    ) {
        Log.d("tok", "on bt open, open callback")

        val outputPort2: MidiOutputPort? = (midiDevice?.openOutputPort(0))
        if (outputPort2 != null) {
            Log.d("tok", "null check pass")
            outputPort2.connect(MyReceiver())
        }

    }

    internal class MyReceiver : MidiReceiver() {
        @Throws(IOException::class)
        override fun onSend(
            data: ByteArray, offset: Int,
            count: Int, timestamp: Long
        ) {
            // parse MIDI or whatever
            Log.d("tok", timestamp.toString())
            Log.d("tok", data.toString())
        }
    }
philburk commented 2 years ago

Good idea. We should start moving to Kotlin for these example programs.

happypennygames commented 2 years ago

That would be awesome! Recognizing that this is "best effort" do you have any ballpark ETA?

philburk commented 2 years ago

We have no ETA. We are focussing on framework stability.

happypennygames commented 2 years ago

Thanks for the update! Good news/bad news: I was able to mine enough knowledge from your java demo to get it working for my app, so thanks for the assist! Admittedly, it's a bit of a serious hack job, but it does work! https://play.google.com/store/apps/details?id=com.happypennygames.aimusic.sightreader as an example.

regalstreak commented 2 years ago

Same here. Can't receive midi events on android from BLE. @happypennygames how did you fix the receiver?

happypennygames commented 2 years ago

I honestly have nothing useful to say, sorry. As described above I just started hacking and hacking between the example files until it kind of worked. Apologies for the delay I kept putting off responding because I wanted to have something more substantial to say.

On Mon, Jul 4, 2022, 4:54 PM Neil Agarwal @.***> wrote:

Same here. Can't receive midi events on android from BLE. @happypennygames https://github.com/happypennygames how did you fix the receiver?

— Reply to this email directly, view it on GitHub https://github.com/philburk/android-midisuite/issues/71#issuecomment-1174337945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQIMHFZRXHEF5GWKJSRYKLLVSNFRFANCNFSM5LDDENMA . You are receiving this because you were mentioned.Message ID: @.***>

philburk commented 1 year ago

There were recent changes to MIDI+BTLE in PR #78. You would need to do the same things in Kotlin for Android S and above.