|
TR123e - EMCT Computing Final Project Version 1.0
Research Project Translation from gen~ to embedded Moog synth
|
Implements keyboard tracking for filter frequency modulation. More...
#include <KeyFollow.h>
Public Member Functions | |
| KeyFollow (float keyFollowAmount=0.01f) | |
| Construct KeyFollow processor with specified tracking intensity. | |
| void | setKeyFollowAmount (float amount) |
| Update keyboard tracking intensity in real-time. | |
| float | process (int midiNote) |
| Process MIDI note number and generate frequency offset. | |
Private Attributes | |
| float | keyFollowAmount |
| Keyboard tracking intensity coefficient. | |
Implements keyboard tracking for filter frequency modulation.
The KeyFollow class provides real-time keyboard tracking functionality, generating frequency offset values based on MIDI note numbers. The implementation uses a linear mapping with configurable intensity to maintain musical relationships while allowing artistic control over tracking behavior.
@design_pattern
@usage_example
| KeyFollow::KeyFollow | ( | float | amount = 0.01f | ) |
Construct KeyFollow processor with specified tracking intensity.
Initialize KeyFollow processor with tracking intensity.
| keyFollowAmount | Tracking intensity coefficient [0.0-1.0] 0.0 = no tracking (constant filter frequency) 1.0 = full tracking (maximum frequency scaling) Default: 0.01f (subtle tracking, typical for bass/lead sounds) |
@complexity O(1) - Constant time initialization @memory Single float storage for tracking coefficient
| amount | Initial tracking intensity coefficient Stored directly without validation for performance |
@implementation_notes
| float KeyFollow::process | ( | int | midiNote | ) |
Process MIDI note number and generate frequency offset.
Generate frequency offset from MIDI note number.
Converts MIDI note number to proportional frequency offset using linear scaling with configurable intensity. The algorithm provides musically appropriate tracking behavior consistent with classic analog synthesizer implementations.
| midiNote | MIDI note number [0-127] Note 36 (C2) serves as reference point (0 offset) Values below 36 are clamped to 0 for stability |
@complexity O(1) - Constant time processing @precision Maintains full floating-point precision for smooth tracking @realtime_safety Real-time safe (deterministic execution time)
@algorithm_details
| midiNote | Input MIDI note number for tracking calculation |
@algorithm_analysis The algorithm implements a three-stage transformation:
@mathematical_justification The 0.33 scaling factor is derived from perceptual studies showing that approximately 1/3 octave filter tracking per octave played provides optimal timbre consistency across keyboard ranges in subtractive synthesis applications.
@performance_characteristics
Calculate note offset from reference point (C2 = MIDI note 36) Cast to float for subsequent floating-point arithmetic efficiency
Clamp negative values to prevent filter frequency reduction below reference point, ensuring stable filter behavior in lowest octaves where tracking could cause instability
Apply frequency scaling factor (0.33) for musical tracking response This provides approximately 1/3 octave tracking per octave played, matching traditional analog synthesizer keyboard tracking behavior
Restore absolute note reference by adding back reference point This maintains proper frequency relationships while preserving the scaled tracking response for musical predictability
Apply user-configurable tracking intensity to final result Allows real-time artistic control over tracking strength while maintaining linear scaling relationship
| void KeyFollow::setKeyFollowAmount | ( | float | amount | ) |
Update keyboard tracking intensity in real-time.
Update keyboard tracking intensity parameter.
| amount | New tracking intensity coefficient [0.0-1.0] Values outside this range are not validated but may produce unexpected results |
@complexity O(1) - Constant time parameter update @thread_safety Thread-safe for single writer, multiple readers @realtime_safety Real-time safe (no blocking operations)
| amount | New tracking intensity value |
@thread_safety Safe for concurrent read/write from different threads @atomic_behavior Float assignment is atomic on most architectures
@implementation_notes
|
private |
Keyboard tracking intensity coefficient.
Controls the proportional amount of filter frequency change relative to note number variation. Higher values create more dramatic filter opening in upper registers, while lower values provide subtle tracking.
@range [0.0-1.0] typical, though implementation accepts any float value @default 0.01f (1% tracking intensity) @units Dimensionless coefficient (ratio)