|
TR123e - EMCT Computing Final Project Version 1.0
Research Project Translation from gen~ to embedded Moog synth
|
Musical technique analyzer for intelligent portamento triggering. More...
#include <PortamentoFilter.h>
Public Member Functions | |
| PortamentoFilter () | |
| Initialize portamento filter with default state. | |
| bool | checkPortamento (int newNote, bool noteOn, float currentTimeMs) |
| Analyze note event and determine portamento requirement. | |
Private Attributes | |
| int | previousNote |
| Previous MIDI note number for comparison analysis. | |
| bool | previousNoteActive |
| Previous note activity state indicator. | |
| float | previousNoteOffTime |
| Timestamp of most recent note-off event. | |
Musical technique analyzer for intelligent portamento triggering.
The PortamentoFilter class implements real-time analysis of MIDI note patterns to determine when portamento should be applied based on legato playing technique detection. This provides musically intelligent behavior that responds appropriately to different performance styles without requiring explicit control messages.
@design_philosophy The implementation prioritizes musical accuracy over technical complexity, using simple but effective heuristics that match performer expectations from acoustic instruments. The algorithm errs toward conservative portamento triggering to avoid unwanted pitch slides during fast passages.
@state_machine_design
@musical_applications
@usage_example
| PortamentoFilter::PortamentoFilter | ( | ) |
Initialize portamento filter with default state.
Initialize portamento filter to safe default state.
Constructs filter in idle state with no previous note information. All state variables are initialized to safe default values that prevent spurious portamento triggering on first note.
@complexity O(1) - Constant time initialization @memory 12 bytes total object size (platform dependent) @thread_safety Safe for concurrent construction
Sets all state variables to values that ensure proper behavior on first note event. The initialization prevents spurious portamento triggering when no valid previous note context exists.
@implementation_details
| bool PortamentoFilter::checkPortamento | ( | int | newNote, |
| bool | noteOn, | ||
| float | currentTimeMs ) |
Analyze note event and determine portamento requirement.
Analyze note event and determine portamento application.
Processes incoming MIDI note events to determine whether portamento should be applied based on legato playing technique detection. The algorithm analyzes note overlap patterns and pitch relationships to provide musically intelligent portamento behavior.
| newNote | MIDI note number [0-127] for current note event |
| noteOn | Boolean indicating note-on (true) or note-off (false) |
| currentTimeMs | Current timestamp in milliseconds for temporal analysis |
@complexity O(1) - Constant time analysis @determinism Bounded execution time regardless of input values @realtime_safety Real-time safe (no blocking operations)
@algorithm_logic For note-on events:
For note-off events:
@musical_considerations
@edge_cases
| newNote | MIDI note number for analysis |
| noteOn | Note event type (true=on, false=off) |
| currentTimeMs | Current system timestamp |
@algorithm_implementation The algorithm implements a simple but musically effective state machine that tracks note overlap conditions and pitch relationships to determine when smooth pitch transitions are appropriate.
@performance_analysis
Local variable for portamento decision Initialized to false (conservative default)
Process note-on events for legato analysis
Check for legato condition: overlapping notes with different pitches
Conditions for portamento triggering:
This logic ensures portamento only occurs for musically appropriate transitions where the performer intends smooth pitch connection.
Notes overlap and are different: trigger portamento This represents classic legato playing technique where the performer connects notes smoothly without gaps.
Either no overlap or same note: no portamento Cases covered:
Update state for next iteration Mark new note as active and store its pitch for future comparison
Process note-off events: update state without triggering portamento
Note-off events never trigger portamento but update internal state to track note activity and timing for subsequent analysis.
|
private |
Previous MIDI note number for comparison analysis.
Stores the MIDI note number of the most recently active note for pitch comparison with incoming notes. Used to determine if portamento should be applied based on pitch interval requirements.
@range [0-127] for valid MIDI notes, -1 for uninitialized state @initialization -1 (no previous note available) @update_policy Updated on every note-on event
|
private |
Previous note activity state indicator.
Boolean flag indicating whether the previous note is still conceptually "active" from a musical perspective. This determines overlap conditions for legato detection and portamento triggering logic.
@states
@musical_significance Represents the performer's intent regarding note connection. Active state indicates potential for legato playing and portamento application.
|
private |
Timestamp of most recent note-off event.
Records the precise timing of the last note-off event for potential future use in temporal analysis algorithms. Currently used for state tracking but provides foundation for advanced timing-based heuristics.
@units Milliseconds (float precision for sub-millisecond accuracy) @range [0.0, ∞) - Monotonically increasing timestamps @precision Limited by system timer resolution and float representation
@future_applications