TR123e - EMCT Computing Final Project Version 1.0
Research Project Translation from gen~ to embedded Moog synth
Loading...
Searching...
No Matches
MidiHandler.h File Reference

Real-time MIDI message processing with temporal delay compensation. More...

#include <Bela.h>
#include <vector>
#include <queue>

Go to the source code of this file.

Classes

struct  MidiNoteMessage
 Encapsulates MIDI note event data with high-precision timing. More...
class  MidiHandler
 Real-time MIDI message processor with temporal delay compensation. More...

Detailed Description

Real-time MIDI message processing with temporal delay compensation.

This module implements sophisticated MIDI message handling for real-time audio applications, providing temporal buffering, delay compensation, and sample-accurate timing for musical performance applications. The system addresses timing jitter inherent in MIDI protocol and hardware interfaces.

@architectural_overview The MidiHandler employs a dual-queue architecture:

  1. Incoming message queue: Buffers raw MIDI events with timestamps
  2. Delayed message queue: Holds messages ready for audio processing

This separation allows for temporal analysis, jitter compensation, and sample-accurate event scheduling essential for professional audio applications.

@timing_theory MIDI protocol introduces variable latency due to:

  • Serial transmission at 31.25 kbaud (320μs per byte)
  • Hardware buffering in MIDI interfaces
  • Operating system scheduling jitter
  • USB packet batching in modern interfaces

The delay compensation algorithm addresses these issues by implementing configurable temporal buffering with sub-millisecond timing accuracy.

@performance_characteristics

  • Timing resolution: Microsecond-level accuracy
  • Memory efficiency: Dynamic queue sizing with bounded growth
  • Real-time safety: Lock-free queue operations
  • Computational complexity: O(1) amortized for message processing
Author
Timothy Paul Read
Date
2025/03/10 @organization AABSTRKT at play via gaialive.com
Version
1.0

@license This source code is provided as is, without warranty. You may copy and distribute verbatim copies of this document. You may modify and use this source code to create binary code for your own purposes, free or commercial.

@references For comprehensive envelope generator theory and implementation details: http://www.earlevel.com/main/2013/06/01/envelope-generators/