|
TR123e - EMCT Computing Final Project Version 1.0
Research Project Translation from gen~ to embedded Moog synth
|
MIDI velocity threshold processor for note-on/note-off discrimination. More...
#include <VelocityParser.h>
Public Member Functions | |
| VelocityParser (int threshold=64) | |
| Construct velocity parser with configurable threshold. | |
| bool | isNoteOn (int velocity) |
| Analyze velocity value and determine note-on status. | |
Private Attributes | |
| int | velocityThreshold |
| Velocity threshold for note-on discrimination. | |
MIDI velocity threshold processor for note-on/note-off discrimination.
The VelocityParser class provides intelligent MIDI velocity analysis with configurable threshold-based discrimination between note-on and note-off events. It handles MIDI protocol ambiguities and controller variations to ensure reliable note triggering behavior across diverse hardware and software configurations.
@design_principles
@threshold_selection_guidelines Optimal threshold values depend on MIDI controller characteristics:
@musical_applications
@usage_example
| VelocityParser::VelocityParser | ( | int | threshold = 64 | ) |
Construct velocity parser with configurable threshold.
Initialize velocity parser with threshold configuration.
| threshold | Velocity threshold for note-on discrimination Values above threshold trigger note-on events Values at or below threshold are interpreted as note-off Default: 64 (middle MIDI range, balanced sensitivity) Range: [1-126] practical limits for musical applications |
@complexity O(1) - Constant time initialization @memory 4 bytes object size (single integer member) @thread_safety Safe for concurrent construction
@threshold_rationale Default value of 64 provides balanced behavior suitable for most musical applications and MIDI controllers. This represents 50% of the MIDI velocity range, offering good sensitivity while preventing false triggering from light touches or controller noise.
@boundary_considerations
| threshold | Velocity discrimination threshold |
Simple initialization storing threshold value for subsequent velocity analysis. No validation performed for maximum real-time performance, relying on caller to provide musically appropriate threshold values.
| bool VelocityParser::isNoteOn | ( | int | velocity | ) |
Analyze velocity value and determine note-on status.
Perform threshold-based velocity discrimination.
Performs threshold-based analysis of MIDI velocity values to determine whether the velocity represents a note-on or note-off event. Provides consistent discrimination behavior essential for reliable musical performance.
| velocity | MIDI velocity value for analysis Range: [0-127] per MIDI specification Values outside range processed without validation |
@complexity O(1) - Single integer comparison @determinism Identical output for identical inputs @realtime_safety Real-time safe (no allocation or blocking)
@discrimination_logic The method implements strict threshold comparison:
This provides clean binary discrimination without hysteresis or complex state tracking, ensuring predictable behavior for musical applications requiring consistent note triggering.
@musical_implications Threshold-based discrimination affects musical expression:
@edge_case_behavior
@controller_compatibility Different MIDI controllers exhibit varying velocity characteristics:
| velocity | MIDI velocity value for analysis |
@implementation_efficiency Single integer comparison provides optimal performance for real-time MIDI processing. No complex logic or state tracking required, ensuring deterministic execution time suitable for low-latency audio applications.
@precision_analysis Integer comparison eliminates floating-point precision concerns and provides exact threshold behavior. Binary discrimination ensures consistent results across processor architectures and compiler optimizations.
|
private |
Velocity threshold for note-on discrimination.
Integer threshold value used for binary velocity discrimination. Values above this threshold are interpreted as note-on events, while values at or below are interpreted as note-off events.
@range [0-127] per MIDI velocity specification @default 64 (balanced sensitivity for most applications) @units MIDI velocity units (dimensionless integer)