Skip to content

Build threaded bridge architecture for control surface mode #19

@joaodotwork

Description

@joaodotwork

Description

Implement the three-thread architecture: mido MIDI callbacks, OSC server daemon thread, and main thread for rendering + USB display transfer.

Tasks

  • Main thread: Push2 init, render loop at 30fps, display_frame() calls
  • mido thread: encoder/button callbacks (managed by push2-python/RtMidi)
  • OSC server thread: ThreadingOSCUDPServer as daemon thread
  • Shared ParameterState object with proper locking
  • Dirty-flag rendering — only redraw when parameters change
  • Keep-alive rendering at 10fps minimum (prevent 2-second display timeout)
  • Clean shutdown across all threads on SIGINT
  • Mode switching between video bridge mode and control surface mode

Acceptance Criteria

  • All three threads run concurrently without deadlocks
  • Display updates at 30fps when parameters are changing
  • Display doesn't black out during idle periods (keep-alive)
  • Clean shutdown releases USB, stops OSC server, closes MIDI

Technical Notes

Main Thread: Push2 init → render loop (30fps) → display_frame()
mido Thread: @on_encoder_rotated → state.set_from_encoder() → osc_client.send()
OSC Thread:  ThreadingOSCUDPServer → state.set_from_osc()
  • display_frame() is blocking USB (~2-5ms)
  • Push2() must be created on main thread

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions