Skip to content

Ship fix/android-midi-wire-86 - #128

Merged
danielraffel merged 1 commit into
mainfrom
fix/android-midi-wire-86
Apr 12, 2026
Merged

Ship fix/android-midi-wire-86#128
danielraffel merged 1 commit into
mainfrom
fix/android-midi-wire-86

Conversation

@danielraffel

Copy link
Copy Markdown
Collaborator

Automated by Shipyard

The MIDI JNI bridge and lock-free SPSC queue were already implemented
(android_midi.cpp) but never called from the audio thread. The FIFO
was being filled by the Kotlin MIDI receiver but nobody was draining
it — so MIDI events accumulated indefinitely without reaching the
Processor.

Fix: call pulp::midi::android::drain_into() at the start of each
Oboe onAudioReady callback, before the user audio callback. This
delivers MIDI events to the per-block MidiBuffer with sample-accurate
offsets computed from the event timestamps.

Also adds midi_buffer() accessor so the standalone Android adapter
can read the buffer and feed it to the Processor.

This completes Phase 1 (USB MIDI) of issue #86. BLE MIDI (Phase 2)
and virtual ports (Phase 3) already have Kotlin-side support in
PulpBluetoothMidi.kt and PulpMidiService.kt — they route through
the same nativeOnMidiReceived / nativeOnVirtualMidiReceived JNI
entry points and benefit from this fix automatically.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 348b24f9d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +5 to +6
#include <pulp/midi/buffer.hpp>
#include <pulp/midi/android_midi_fifo.hpp>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add MIDI include path for Android audio target

This commit adds #include <pulp/midi/buffer.hpp> and #include <pulp/midi/android_midi_fifo.hpp> in oboe_device.cpp, but the Android wiring for pulp-audio does not add core/midi/include to that target (I checked tools/cmake/PulpAndroid.cmake, where pulp-audio only gets core/platform/include). On Android builds, this will fail at compile time with missing MIDI headers, so the new wiring cannot be built until the include path (or an equivalent transitive dependency) is added.

Useful? React with 👍 / 👎.

@danielraffel
danielraffel merged commit 2a7e08c into main Apr 12, 2026
6 of 8 checks passed
danielraffel added a commit that referenced this pull request Apr 12, 2026
1. measure_text uses SkShaper when shaping is enabled (#125 review)
   - Aligned with fill_text: both now use HarfBuzz for consistent
     kerning/ligature widths. Fixes draw-vs-measure mismatch for
     strings like "AV", "ffi".

2. SDF text: UTF-8 bounds checking + missing glyph fallback (#126 review)
   - Guard multibyte decode against truncated input (no UB on malformed)
   - Fall back to fill_text() if any glyph is missing from the atlas
     rather than silently skipping characters

3. Remove duplicate accessibility JNI from gpu_surface_android.cpp (#127 review)
   - Old code had wrong role mappings (toggle=3, label=2, meter=1)
   - New code in core/view/platform/android/accessibility_android.cpp
     uses C++ enum values directly (correct)
   - Eliminates linker duplicate symbol conflict on Android

4. Add MIDI include path for Android audio target (#128 review)
   - core/midi/include added to pulp-audio's include directories in
     PulpAndroid.cmake so oboe_device.cpp can find buffer.hpp and
     android_midi_fifo.hpp
danielraffel added a commit that referenced this pull request Apr 12, 2026
1. measure_text uses SkShaper when shaping is enabled (#125 review)
   - Aligned with fill_text: both now use HarfBuzz for consistent
     kerning/ligature widths. Fixes draw-vs-measure mismatch for
     strings like "AV", "ffi".

2. SDF text: UTF-8 bounds checking + missing glyph fallback (#126 review)
   - Guard multibyte decode against truncated input (no UB on malformed)
   - Fall back to fill_text() if any glyph is missing from the atlas
     rather than silently skipping characters

3. Remove duplicate accessibility JNI from gpu_surface_android.cpp (#127 review)
   - Old code had wrong role mappings (toggle=3, label=2, meter=1)
   - New code in core/view/platform/android/accessibility_android.cpp
     uses C++ enum values directly (correct)
   - Eliminates linker duplicate symbol conflict on Android

4. Add MIDI include path for Android audio target (#128 review)
   - core/midi/include added to pulp-audio's include directories in
     PulpAndroid.cmake so oboe_device.cpp can find buffer.hpp and
     android_midi_fifo.hpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant