android-midisuite icon indicating copy to clipboard operation
android-midisuite copied to clipboard

Kotlin version?

Open happypennygames opened this issue 3 years ago • 7 comments

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())
        }
    }

happypennygames avatar Jan 02 '22 01:01 happypennygames

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

philburk avatar Jan 02 '22 21:01 philburk

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

happypennygames avatar Jan 03 '22 01:01 happypennygames

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

philburk avatar Feb 28 '22 01:02 philburk

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.

happypennygames avatar Feb 28 '22 01:02 happypennygames

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

regalstreak avatar Jul 04 '22 20:07 regalstreak

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: @.***>

happypennygames avatar Jul 11 '22 10:07 happypennygames

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.

philburk avatar Jul 16 '23 18:07 philburk