Module src.systems.note_system
Manages a 12-note system, syncing MIDI‐driven note activation to joint visuals.
Supports circular shifts, and both “instant” and “offset” activation modes. Also computes and caches fundamental root information from active MIDI notes.
Class Note
| Note:new (idx, name, jointObj) | Construct a new Note object. |
Class NoteSystem
| NoteSystem:toggleNoteMode () | Toggle between “instant” and “offset” note modes. |
| NoteSystem:new (scene) | Create a new NoteSystem bound to a scene. |
| NoteSystem:shift (offset) | Shift all note slots by a given offset. |
| NoteSystem:update (dt) | Update note, bass, and topVoice states based on MIDI input. |
| NoteSystem:getFundamentalInfo () | Accessor for fundamental info. |
Class Note
Single‐note abstraction, tracking its slot, name, visual joint, and state.
Class NoteSystem
The main note system, managing 12 Note instances and their state.
- NoteSystem:toggleNoteMode ()
-
Toggle between “instant” and “offset” note modes.
Returns:
-
nil
- NoteSystem:new (scene)
-
Create a new NoteSystem bound to a scene.
Initializes 12 Note objects and their previous‐state tables.
Parameters:
- scene
table
Scene containing
scene.joints
Returns:
- scene
table
Scene containing
- NoteSystem:shift (offset)
-
Shift all note slots by a given offset.
Positive values rotate slots right; negative rotate left.
Rebinds each Note to the correct joint object afterward.
Parameters:
- offset number Number of slots to shift
Returns:
-
nil
- NoteSystem:update (dt)
-
Update note, bass, and topVoice states based on MIDI input.
In “offset” mode, uses timers to delay deactivation for notes.
Bass uses its own offset duration. TopVoice respects the general offset (no separate timer).
Also computes fundamental info from current active notes.
Parameters:
- dt number Delta time in seconds since last frame
Returns:
-
boolean
True if any note, bass, or topVoice state changed
- NoteSystem:getFundamentalInfo ()
-
Accessor for fundamental info.
Returns:
-
table
{hasFundamental, fundamental, y}