Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::MusicalTypingController Class Reference

#include <musical_typing.hpp>

Public Member Functions

void set_base_note (int note)
 MIDI note for the first key ('a').
int base_note () const
bool handle_key (const KeyEvent &e)
 Feed a key event.
int octave_shift () const
 Current octave shift (in octaves; z/x decrement/increment).
void set_octave_shift (int s)
 Set the octave shift directly.
void all_notes_off ()
 Release every held note (focus loss / capture disabled).
bool any_held () const

Static Public Member Functions

static int semitone_for_key (KeyCode k)
 QWERTY key -> semitone offset within the layout, or -1 if not a note key.

Public Attributes

std::function< void(int note, float velocity)> on_note_on
std::function< void(int note)> on_note_off
float velocity = 0.8f

Static Public Attributes

static constexpr float kVelStep = 1.0f / 16.0f

Member Function Documentation

◆ all_notes_off()

void pulp::view::MusicalTypingController::all_notes_off ( )
inline

Release every held note (focus loss / capture disabled).

Safe to call any time; a no-op when nothing is held.

◆ any_held()

bool pulp::view::MusicalTypingController::any_held ( ) const
inline

◆ base_note()

int pulp::view::MusicalTypingController::base_note ( ) const
inline

◆ handle_key()

bool pulp::view::MusicalTypingController::handle_key ( const KeyEvent & e)
inline

Feed a key event.

Returns true iff it was a mapped note/octave key with no Cmd/Ctrl/Alt/Meta modifier (i.e. consumed). Everything else returns false so the host keeps its shortcuts and other keys.

◆ octave_shift()

int pulp::view::MusicalTypingController::octave_shift ( ) const
inline

Current octave shift (in octaves; z/x decrement/increment).

Lets a view compute the MIDI note a typing key maps to for non-keyboard input (clicks).

◆ semitone_for_key()

int pulp::view::MusicalTypingController::semitone_for_key ( KeyCode k)
inlinestatic

QWERTY key -> semitone offset within the layout, or -1 if not a note key.

◆ set_base_note()

void pulp::view::MusicalTypingController::set_base_note ( int note)
inline

MIDI note for the first key ('a').

Default 60 (middle C). For a slice sampler set this to the slice root so 'a' triggers slice 0, 'w' slice 1, …

◆ set_octave_shift()

void pulp::view::MusicalTypingController::set_octave_shift ( int s)
inline

Set the octave shift directly.

BOTH bounds are BASE-RELATIVE so the play-window reaches the true range edges (C-2 … G8) regardless of base note. Low bound = the most-negative shift that lands base+shift*12 on MIDI 0 (base C2 → −4, C3 → −5). High bound = at least +5 (the 18-key typing play-window's top reaches G8 from a normal base), AND enough to bring the window low up to the piano's G8 saturation point (MIDI 92) for LOW roots — a fixed +5 left a root ≤ C0 short of G8 because the overview strip's base-relative top exceeded what this clamp honored. Lets an on-screen octave −/+ control, the z/x keys, and the overview-strip drag all agree.

Member Data Documentation

◆ kVelStep

float pulp::view::MusicalTypingController::kVelStep = 1.0f / 16.0f
staticconstexpr

◆ on_note_off

std::function<void(int note)> pulp::view::MusicalTypingController::on_note_off

◆ on_note_on

std::function<void(int note, float velocity)> pulp::view::MusicalTypingController::on_note_on

◆ velocity

float pulp::view::MusicalTypingController::velocity = 0.8f

The documentation for this class was generated from the following file: