Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::midi::SynthesiserVoice Class Referenceabstract

Abstract base for one synth voice. More...

#include <synthesiser.hpp>

Public Member Functions

virtual ~SynthesiserVoice ()=default
virtual void on_note_on (const SynthesiserNote &note)
 Activate this voice for note.
virtual void on_note_off ()
 Begin release.
virtual void on_choke (float fade_ms)
 Choke this voice with the caller's requested fade time.
virtual void on_pitch_bend (float bend_semitones)
 Channel-level pitch bend (semitones, already scaled by the configured bend range).
virtual void on_aftertouch (float pressure)
 Channel-level aftertouch (0..1). Default no-op.
virtual void on_cc (uint8_t cc_number, uint8_t value)
 Channel-level CC (raw 0–127 value). Default no-op.
virtual void render (float *out, int num_samples)=0
 Render num_samples of audio into out.
virtual float peak_level () const
 Reported by the voice for the Quietest steal strategy and for caller-side metering.
virtual void reset ()
 Hard-reset (clear state, drop note).
bool active () const
bool releasing () const
const SynthesiserNote & note () const
void defer_note_off_for_sustain ()
 Mark this voice as waiting for sustain-pedal release.
void release_sustained_note ()
 Release a note whose note-off was deferred by CC64 sustain.
void capture_for_sostenuto ()
 Capture this voice for sostenuto.
void release_sostenuto_note ()
 Release a note captured by CC66 sostenuto if no sustain hold remains.
void set_soft_pedal (bool down)
 Update note metadata for soft-pedal state.

Protected Member Functions

void mark_inactive ()
 Subclasses call this from render() once their release tail finishes so the synth can reclaim the voice on the next note_on.

Protected Attributes

SynthesiserNote note_ {}
bool active_ = false
bool releasing_ = false

Detailed Description

Abstract base for one synth voice.

Subclasses implement render and may override on_choke / on_pitch_bend / on_aftertouch / on_cc / peak_level to participate in voice groups, channel-level controllers, and voice-stealing. The owning Synthesiser handles sustain/sostenuto pedal state before calling on_note_off(): note-off is deferred while CC64 is down or the note is captured by CC66, then delivered through the normal note-off hook when the relevant pedal state clears.

Constructor & Destructor Documentation

◆ ~SynthesiserVoice()

virtual pulp::midi::SynthesiserVoice::~SynthesiserVoice ( )
virtualdefault

Member Function Documentation

◆ active()

bool pulp::midi::SynthesiserVoice::active ( ) const
inline

◆ capture_for_sostenuto()

void pulp::midi::SynthesiserVoice::capture_for_sostenuto ( )
inline

Capture this voice for sostenuto.

Unlike sustain, only notes already active when CC66 is pressed are held by the pedal.

◆ defer_note_off_for_sustain()

void pulp::midi::SynthesiserVoice::defer_note_off_for_sustain ( )
inline

Mark this voice as waiting for sustain-pedal release.

The voice remains active and non-releasing; release_sustained_note() later invokes the normal note-off path when CC64 is lifted and no other pedal holds it.

◆ mark_inactive()

void pulp::midi::SynthesiserVoice::mark_inactive ( )
inlineprotected

Subclasses call this from render() once their release tail finishes so the synth can reclaim the voice on the next note_on.

◆ note()

const SynthesiserNote & pulp::midi::SynthesiserVoice::note ( ) const
inline

◆ on_aftertouch()

virtual void pulp::midi::SynthesiserVoice::on_aftertouch ( float pressure)
inlinevirtual

Channel-level aftertouch (0..1). Default no-op.

◆ on_cc()

virtual void pulp::midi::SynthesiserVoice::on_cc ( uint8_t cc_number,
uint8_t value )
inlinevirtual

Channel-level CC (raw 0–127 value). Default no-op.

◆ on_choke()

virtual void pulp::midi::SynthesiserVoice::on_choke ( float fade_ms)
inlinevirtual

Choke this voice with the caller's requested fade time.

The default preserves ordinary synth behavior by entering the normal release path; one-shot voices can override this to apply a short, click-free fade.

◆ on_note_off()

virtual void pulp::midi::SynthesiserVoice::on_note_off ( )
inlinevirtual

Begin release.

Subclasses typically schedule envelope release here; when the envelope tail completes they should call mark_inactive() so the synth's free-voice scan can reclaim the slot. Keeps note_.releasing in sync with the releasing_ member so subclasses reading either path see the same state.

◆ on_note_on()

virtual void pulp::midi::SynthesiserVoice::on_note_on ( const SynthesiserNote & note)
inlinevirtual

Activate this voice for note.

Called by the synth when the pool finds (or steals) a slot. Subclasses can override to schedule envelope attack etc.; the base records the note and sets active_ = true.

◆ on_pitch_bend()

virtual void pulp::midi::SynthesiserVoice::on_pitch_bend ( float bend_semitones)
inlinevirtual

Channel-level pitch bend (semitones, already scaled by the configured bend range).

Default no-op — override to apply.

◆ peak_level()

virtual float pulp::midi::SynthesiserVoice::peak_level ( ) const
inlinevirtual

Reported by the voice for the Quietest steal strategy and for caller-side metering.

Default 0 (matches "no audio level info available"); subclasses with an envelope should return the envelope's current level.

◆ release_sostenuto_note()

void pulp::midi::SynthesiserVoice::release_sostenuto_note ( )
inline

Release a note captured by CC66 sostenuto if no sustain hold remains.

◆ release_sustained_note()

void pulp::midi::SynthesiserVoice::release_sustained_note ( )
inline

Release a note whose note-off was deferred by CC64 sustain.

◆ releasing()

bool pulp::midi::SynthesiserVoice::releasing ( ) const
inline

◆ render()

virtual void pulp::midi::SynthesiserVoice::render ( float * out,
int num_samples )
pure virtual

Render num_samples of audio into out.

The synth calls render ADDITIVELY — voices sum into the existing buffer contents — so the caller should zero out before calling Synthesiser::process if they want a fresh block.

◆ reset()

virtual void pulp::midi::SynthesiserVoice::reset ( )
inlinevirtual

Hard-reset (clear state, drop note).

Called when a voice is stolen and reused.

◆ set_soft_pedal()

void pulp::midi::SynthesiserVoice::set_soft_pedal ( bool down)
inline

Update note metadata for soft-pedal state.

Sound design remains a voice concern; this metadata lets a voice choose whether and how to apply it.

Member Data Documentation

◆ active_

bool pulp::midi::SynthesiserVoice::active_ = false
protected

◆ note_

SynthesiserNote pulp::midi::SynthesiserVoice::note_ {}
protected

◆ releasing_

bool pulp::midi::SynthesiserVoice::releasing_ = false
protected

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