Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod > Class Template Reference

Detailed Description

template<typename Exciter, typename Load, uint16_t MaxPeriod = 1536>
class sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >
Template Parameters
Exciterwhat plays the string (contracts.hpp: Exciter)
Loadwhat end b terminates on (contracts.hpp: Load)
MaxPeriodlongest loop in samples, which sets the lowest pitch. The default covers C1 at 48 kHz (a 1469-sample period); each of the two segments gets a buffer this size. The widget owns its buffers: it is the black box, the loop inside it is not.
Note
All public methods are ISR-safe — bounded computation, no I/O.

Definition at line 75 of file string_base.hpp.

#include <string_base.hpp>

Inheritance diagram for sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >:
[legend]

Public Member Functions

 StringBase (Exciter &exciter, Load &load, const char *name="String")
 
void use_load (bool on)
 End b terminates on the load (true) or on a wall (false). The junction starts at rest.
 
bool loaded () const
 
Exciter & exciter ()
 The parts, for whoever owns them and for tools.
 
Load & load ()
 
const StringLoop & loop () const
 
const LoadJunction< Load > & end_b () const
 
void set_pitch_su (float su)
 Pitch across C1..C9 (math::note_of_su). Smoothed.
 
void set_position_su (float su)
 Where the exciter sits along the string.
 
void set_damping_su (float su)
 Loss filter cutoff: how fast the high partials give up. Smoothed.
 
void set_pickup_su (float su)
 What is heard: 0 the load, 1 the bare string, a crossfade between.
 
void process (float *out, uint16_t n)
 
void reset ()
 The string at rest, its ports already at their targets rather than gliding to them.
 
void describe (diagram::Graph &g) const
 The whole string as wired: exciter, loop, end b, pickup (AP-037)
 
float period_samples () const
 The loop period the string is currently tuned to, in samples.
 
float energy () const
 Energy in the loop, the load and the exciter. Never called from audio code.
 

Static Public Attributes

static constexpr float DEFAULT_PITCH_SU = 0.375f
 
static constexpr float DEFAULT_POSITION_SU = 0.556f
 junction 0.3
 
static constexpr float DEFAULT_DAMPING_SU = 0.6f
 
static constexpr float DEFAULT_PICKUP_SU = 0.0f
 all load
 

Protected Member Functions

void update_period (float pitch_su)
 
void apply_position (float position_su)
 
void apply_damping (float damping_su)
 

Protected Attributes

const char * name_
 
float buf_a_ [MaxPeriod] = {}
 the loop's segment to end a
 
float buf_b_ [MaxPeriod] = {}
 and to end b
 
StringLoop loop_
 
Exciter & exciter_
 
Load & load_
 
LoadJunction< Load > end_b_
 
bool loaded_ = true
 
primitives::SmoothedPort pitch_
 
primitives::SmoothedPort position_
 
primitives::SmoothedPort damping_
 
primitives::SmoothedPort pickup_
 
primitives::CrossfadeRamp mix_
 
primitives::BlockGuard guard_
 
float last_period_ = -1.0f
 
float last_junction_ = -1.0f
 
float last_damping_ = -1.0f
 

Static Protected Attributes

static constexpr float SMOOTH_MS = 20.0f
 
static constexpr float MIN_JUNCTION = 0.05f
 
static constexpr float MAX_JUNCTION = 0.5f
 
static constexpr float LOOP_GAIN = 0.999f
 energy lost at end b each trip
 
static constexpr float PERIOD_MARGIN = 4.0f
 headroom under MaxPeriod for the split
 
static constexpr float RETUNE_THRESHOLD = 1e-4f
 samples of period change worth a retune
 

Friends

struct StringTestAccess
 

Constructor & Destructor Documentation

◆ StringBase()

Member Function Documentation

◆ use_load()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::use_load ( bool  on)
inline

End b terminates on the load (true) or on a wall (false). The junction starts at rest.

Definition at line 101 of file string_base.hpp.

References sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::end_b_, and sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::loaded_.

Referenced by sbl::dsp::pm::BowedString< Bow, Body, MaxPeriod >::use_body().

◆ loaded()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
bool sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::loaded ( ) const
inline

◆ exciter()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
Exciter & sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::exciter ( )
inline

◆ load()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
Load & sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::load ( )
inline

◆ loop()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
const StringLoop & sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::loop ( ) const
inline

◆ end_b()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
const LoadJunction< Load > & sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::end_b ( ) const
inline

◆ set_pitch_su()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::set_pitch_su ( float  su)
inline

◆ set_position_su()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::set_position_su ( float  su)
inline

Where the exciter sits along the string.

0 is near an end, 1 is the middle. Positions mirror about the middle, so this spans the distinct ones. Near an end the string locks onto upper modes — an octave or more up — which is the real instrument's behaviour, not a fault (AP-032 Phase 1 finding 3). Smoothed.

Definition at line 126 of file string_base.hpp.

References sbl::dsp::math::clamp01(), sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::position_, and sbl::dsp::primitives::SmoothedPort::set().

Referenced by sbl::dsp::pm::BowedString< Bow, Body, MaxPeriod >::set_bow_position_su().

◆ set_damping_su()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::set_damping_su ( float  su)
inline

Loss filter cutoff: how fast the high partials give up. Smoothed.

Definition at line 129 of file string_base.hpp.

References sbl::dsp::math::clamp01(), sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::damping_, and sbl::dsp::primitives::SmoothedPort::set().

◆ set_pickup_su()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::set_pickup_su ( float  su)
inline

What is heard: 0 the load, 1 the bare string, a crossfade between.

Smoothed and ramped across each block, so turning it never steps. It changes the output only, not the string. Without the load it has no effect.

Definition at line 137 of file string_base.hpp.

References sbl::dsp::math::clamp01(), sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::pickup_, and sbl::dsp::primitives::SmoothedPort::set().

Referenced by sbl::dsp::pm::BowedString< Bow, Body, MaxPeriod >::set_body_mix_su().

◆ process()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
void sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::process ( float *  out,
uint16_t  n 
)
inline

◆ reset()

◆ describe()

◆ period_samples()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::period_samples ( ) const
inline

The loop period the string is currently tuned to, in samples.

Definition at line 226 of file string_base.hpp.

References sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::loop_, and sbl::dsp::pm::StringLoop::period_samples().

◆ energy()

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::energy ( ) const
inline

◆ update_period()

◆ apply_position()

◆ apply_damping()

Friends And Related Symbol Documentation

◆ StringTestAccess

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
friend struct StringTestAccess
friend

Definition at line 232 of file string_base.hpp.

Member Data Documentation

◆ DEFAULT_PITCH_SU

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::DEFAULT_PITCH_SU = 0.375f
staticconstexpr

◆ DEFAULT_POSITION_SU

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::DEFAULT_POSITION_SU = 0.556f
staticconstexpr

junction 0.3

Definition at line 83 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::StringBase().

◆ DEFAULT_DAMPING_SU

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::DEFAULT_DAMPING_SU = 0.6f
staticconstexpr

◆ DEFAULT_PICKUP_SU

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::DEFAULT_PICKUP_SU = 0.0f
staticconstexpr

all load

Definition at line 85 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::StringBase().

◆ SMOOTH_MS

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::SMOOTH_MS = 20.0f
staticconstexprprotected

◆ MIN_JUNCTION

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::MIN_JUNCTION = 0.05f
staticconstexprprotected

◆ MAX_JUNCTION

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::MAX_JUNCTION = 0.5f
staticconstexprprotected

◆ LOOP_GAIN

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::LOOP_GAIN = 0.999f
staticconstexprprotected

energy lost at end b each trip

Definition at line 237 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::StringBase().

◆ PERIOD_MARGIN

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::PERIOD_MARGIN = 4.0f
staticconstexprprotected

headroom under MaxPeriod for the split

Definition at line 238 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::update_period().

◆ RETUNE_THRESHOLD

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
constexpr float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::RETUNE_THRESHOLD = 1e-4f
staticconstexprprotected

◆ name_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
const char* sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::name_
protected

◆ buf_a_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::buf_a_[MaxPeriod] = {}
protected

the loop's segment to end a

Definition at line 270 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::StringBase().

◆ buf_b_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::buf_b_[MaxPeriod] = {}
protected

and to end b

Definition at line 271 of file string_base.hpp.

Referenced by sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::StringBase().

◆ loop_

◆ exciter_

◆ load_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
Load& sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::load_
protected

◆ end_b_

◆ loaded_

◆ pitch_

◆ position_

◆ damping_

◆ pickup_

◆ mix_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
primitives::CrossfadeRamp sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::mix_
protected

◆ guard_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
primitives::BlockGuard sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::guard_
protected

◆ last_period_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::last_period_ = -1.0f
protected

◆ last_junction_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::last_junction_ = -1.0f
protected

◆ last_damping_

template<typename Exciter , typename Load , uint16_t MaxPeriod = 1536>
float sbl::dsp::pm::StringBase< Exciter, Load, MaxPeriod >::last_damping_ = -1.0f
protected

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