DSP#
Buffers and samples#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP#
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class buffer#
Single-channel float audio buffer.
The fundamental container for sample-level audio data in libYSE. Sub-classes
drawableBuffer,fileBuffer, andwavetablelayer drawing, file I/O, and wavetable generation on top of this base.Note
Only the
getLength*accessors are thread-safe; all mutating operations and sample-level reads assume the caller has serialised access.Warning
Do not construct instances as audio-thread locals. Construction allocates from the heap, which is far too slow for a real-time callback. Allocate buffers at file scope or during setup and reuse them.
Subclassed by YSE::DSP::drawableBuffer, YSE::DSP::ramp
Public Functions
-
buffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
Construct a buffer.
- Parameters:
length – Number of samples in the buffer.
overflow – Extra samples appended past the end, used by sources that need a wrap-around copy of the first sample at the tail (wavetables). Leave at 0 for plain buffers.
-
inline UInt getLength() const#
Length in samples (frames).
-
inline UInt getLengthMS() const#
Length in milliseconds at the engine sample rate.
-
inline Flt getLengthSec() const#
Length in seconds at the engine sample rate.
-
bool isSilent() const#
Whether every sample in the buffer is zero.
-
float maxValue() const#
Peak absolute sample value.
-
inline Flt *getPtr()#
Direct write access to the underlying storage.
Warning
Bypasses every internal invariant maintained by the buffer. Prefer the operator overloads,
copyFrom, or thedrawableBufferinterface where possible.
-
buffer ©From(const buffer &s, UInt SourcePos, UInt DestPos, UInt length)#
Copy a region from
sinto this buffer.- Parameters:
s – Source buffer.
SourcePos – First sample read from
s.DestPos – First sample written in this buffer.
length – Number of samples to copy.
-
Flt getBack()#
Last sample of the buffer.
-
buffer &resize(UInt length, Flt value = 0.f)#
Resize the buffer.
- Parameters:
length – Target length in samples.
value – Value used to initialise newly added samples when
lengthexceeds the current size.
-
inline Flt getSampleRateAdjustment()#
Sample-rate adjustment factor used by the engine to play this buffer at the correct speed when its native rate differs from the engine rate.
-
inline void setSampleRateAdjustment(Flt s)#
Set the sample-rate adjustment factor.
Normally only the engine calls this.
-
inline void copyOverflow()#
Refresh the overflow tail (a copy of the first
overflowsamples).Most mutating operations already maintain this; calling it manually is rarely necessary.
Public Members
-
Flt *cursor#
Position cursor — application-owned read/write head pointer.
The buffer never mutates this on its own; it’s a parking slot for user code that needs to remember a position across calls.
-
buffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
-
class buffer#
-
namespace DSP#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class drawableBuffer : public YSE::DSP::buffer#
Buffer that can be shaped procedurally with envelopes and lines.
Extends
bufferwith drawing primitives — useful for shaping control signals, building wavetables, or constructing test signals offline. The drawing primitives target buffers used as inputs to other DSP, not buffers fed straight to the audio device, although the engine does not prevent the latter.Subclassed by YSE::DSP::fileBuffer
Public Functions
-
inline drawableBuffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
Construct a drawable buffer.
See
buffer::buffer.
-
drawableBuffer &applyEnvelope(const envelope &env, Flt length = 0)#
Multiply the buffer by an envelope shape.
- Parameters:
env – Envelope to apply.
length – Desired envelope length in seconds. If > 0 the envelope is stretched or compressed to this length; if 0 the envelope’s internal length is used as-is.
-
drawableBuffer &drawLine(UInt start, UInt stop, Flt startValue, Flt stopValue)#
Draw a linear ramp between two positions.
Writes a straight line from
(start, startValue)to(stop, stopValue)into the buffer.- Parameters:
start – First sample index (in [0, getLength()]).
stop – Last sample index (in [0, getLength()]).
startValue – Value at
start, in [-1.0, 1.0].stopValue – Value at
stop, in [-1.0, 1.0].
-
drawableBuffer &drawLine(UInt start, UInt stop, Flt value)#
Fill a region with a constant value.
- Parameters:
start – First sample index.
stop – Last sample index.
value – Value to write, in [-1.0, 1.0].
-
inline drawableBuffer &operator+=(Flt f)#
Add
fto every sample (returns drawableBuffer&).
-
inline drawableBuffer &operator-=(Flt f)#
Subtract
ffrom every sample.
-
inline drawableBuffer &operator*=(Flt f)#
Multiply every sample by
f.
-
inline drawableBuffer &operator/=(Flt f)#
Divide every sample by
f.
-
inline drawableBuffer &operator+=(const buffer &s)#
Sample-wise add.
-
inline drawableBuffer &operator-=(const buffer &s)#
Sample-wise subtract.
-
inline drawableBuffer &operator*=(const buffer &s)#
Sample-wise multiply.
-
inline drawableBuffer &operator/=(const buffer &s)#
Sample-wise divide.
-
inline drawableBuffer &operator=(const buffer &s)#
Copy-assign from a
buffer.
-
inline drawableBuffer &operator=(Flt f)#
Fill every sample with
f.
-
inline drawableBuffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
-
class drawableBuffer : public YSE::DSP::buffer#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class fileBuffer : public YSE::DSP::drawableBuffer#
Drawable buffer with built-in load and save.
Adds file-system convenience on top of
drawableBuffer: load a channel from disk, or save the contents to WAV.Subclassed by YSE::DSP::wavetable
Public Functions
-
inline fileBuffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
Construct a file buffer.
See
buffer::buffer.
-
bool load(const char *fileName, UInt channel = 0)#
Load one channel from an audio file.
- Parameters:
fileName – Path to the audio file.
channel – Channel index. For mono files this must be 0.
- Returns:
trueon success,falseif the file cannot be opened or the requested channel does not exist.
-
bool save(const char *fileName)#
Save the contents to a mono WAV file.
Note
WAV is currently the only supported output format.
-
inline fileBuffer &operator=(const buffer &s)#
Copy-assign from a
buffer.
-
inline fileBuffer &operator=(Flt value)#
Fill every sample with
value.
-
inline fileBuffer(UInt length = STANDARD_BUFFERSIZE, UInt overflow = 0)#
-
class fileBuffer : public YSE::DSP::drawableBuffer#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class wavetable : public YSE::DSP::fileBuffer#
Pre-computed single-cycle waveform table.
wavetableis afileBufferwith a one-sample overflow tail used for wrap-around interpolation, plus generators for the classic band-limited waveforms. Combine with the oscillator family inYSE::DSPfor fast playback of complex timbres without per-sample trigonometry.Public Functions
-
inline wavetable(UInt length = STANDARD_BUFFERSIZE)#
Construct an empty wavetable of
lengthsamples.
-
void createSaw(Int harmonics, Int length)#
Fill the table with a band-limited sawtooth wave.
- Parameters:
harmonics – Number of partials to sum. Higher values give a brighter timbre but risk aliasing when played at high pitches.
length – Resolution of the table in samples.
-
void createSquare(Int harmonics, Int length)#
Fill the table with a band-limited square wave.
See
createSaw.
-
void createTriangle(Int harmonics, Int length)#
Fill the table with a band-limited triangle wave.
See
createSaw.
-
void createFourierTable(const std::vector<Flt> &harmonics, Int length, Flt phase)#
Fill the table with a Fourier sum.
- Parameters:
harmonics – Amplitude per harmonic.
harmonics[0]is the fundamental,harmonics[1]is the second harmonic, and so on.length – Resolution of the table in samples.
phase – Initial phase offset in radians.
-
inline wavetable(UInt length = STANDARD_BUFFERSIZE)#
-
class wavetable : public YSE::DSP::fileBuffer#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.Functions
-
bool LoadFromFile(const char *fileName, buffer &buffer, UInt channel = 0)#
Load a single channel from an audio file into a buffer.
- Parameters:
fileName – Path to the audio file.
buffer – Destination buffer. Resized to fit.
channel – Channel index to load. For mono files this must be 0.
- Returns:
trueon success,falseif the file cannot be opened or the requested channel does not exist. < This macro is added to all public class declarations.
-
bool LoadFromFile(const char *fileName, std::vector<YSE::DSP::buffer> &buffer)#
Load every channel of an audio file into a multichannel buffer.
- Returns:
trueon success,falseon read error. < This macro is added to all public class declarations.
-
bool SaveToFile(const char *fileName, buffer &buffer)#
Save a single-channel buffer to a mono WAV file.
Note
WAV is currently the only supported output format.
- Returns:
trueon success,falseon write error. < This macro is added to all public class declarations.
-
bool LoadFromFile(const char *fileName, buffer &buffer, UInt channel = 0)#
-
namespace DSP
Math#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.Functions
-
Flt MidiToFreq(Flt note)#
Convert a MIDI note number (0-127) to a frequency in Hz.
Scalar form. < This macro is added to all public class declarations.
-
Flt FreqToMidi(Flt freq)#
Convert a frequency in Hz to a MIDI note number.
Scalar form. < This macro is added to all public class declarations.
-
class abs#
Per-sample absolute value.
-
class clip#
Hard-clipper.
Limits sample values to
[low, high]. Use to tame stray peaks or as a deliberate distortion stage.Public Functions
-
inline clip()#
-
inline clip()#
-
class dbToPow#
Per-sample dB → linear (power) conversion.
-
class dbToRms#
Per-sample dB → linear (RMS amplitude) conversion.
-
class exp#
Per-sample exponential (
e ** in[i]).
-
class freqToMidi#
Per-sample Hz → MIDI note conversion.
Buffer-rate counterpart of
FreqToMidi.
-
class inverter#
Per-sample inversion.
In
zeroToOnemode the output is1 - in[i]— useful for inverting a normalised control signal. Otherwise the output is the signed negation-in[i].Public Functions
-
class log#
Per-sample logarithm with arbitrary base (
log_{in2}(in1)).Public Functions
-
class midiToFreq#
Per-sample MIDI note → Hz conversion.
Buffer-rate counterpart of
MidiToFreq.
-
class pow#
Per-sample power:
in1[i] ** in2[i].Public Functions
-
class powToDb#
Per-sample linear (power) → dB conversion.
-
class rmsToDb#
Per-sample linear (RMS amplitude) → dB conversion.
-
class rSqrt#
Fast reciprocal square root (~8 mantissa bits of precision).
Significantly cheaper than the standard library version. Use in DSP paths where speed matters more than the last few bits of accuracy.
-
class sqrt#
Fast square root (~8 mantissa bits of precision).
Same trade-off as
rSqrt— cheaper than the standard library, less precise. Use in DSP paths where speed matters.
-
class wrap#
Fractional part —
x - floor(x)per sample.
-
Flt MidiToFreq(Flt note)#
-
namespace DSP
Generators#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class cosine#
Cosine wave oscillator.
Use as a building block for FM synthesis, modulators, or filter sweeps.
-
class noise#
White-noise generator.
Useful as a percussion source, for granular textures, or as a test signal for filters.
-
class oscillator#
Wavetable-driven oscillator.
The general-purpose oscillator — supply a
wavetableviainitializeand the oscillator plays it back at any frequency. Combine withwavetable::createSaw/createSquare/createTrianglefor band-limited classic shapes, or withcreateFourierTablefor custom timbres.Public Functions
-
oscillator()#
-
YSE::DSP::buffer &operator()(Flt frequency, UInt length = STANDARD_BUFFERSIZE)#
Generate a fresh block at
frequencyHz.
-
YSE::DSP::buffer &operator()(YSE::DSP::buffer &in)#
Generate one block driven by per-sample frequency in
in.
-
void reset()#
Reset the phase to zero.
Private Functions
-
void calc(Bool useFrequency)#
-
oscillator()#
-
class saw#
Naive (non band-limited) sawtooth oscillator.
Cheap; aliases at high pitches. Use the wavetable-driven
oscillatorwith a band-limitedwavetable::createSawtable for alias-free output.Public Functions
-
YSE::DSP::buffer &operator()(Flt frequency, UInt length = STANDARD_BUFFERSIZE)#
Generate a fresh block at
frequencyHz.
-
YSE::DSP::buffer &operator()(YSE::DSP::buffer &in)#
Generate one block driven by per-sample frequency in
in.
-
saw()#
Private Functions
-
void calc(Bool useFrequency)#
-
YSE::DSP::buffer &operator()(Flt frequency, UInt length = STANDARD_BUFFERSIZE)#
-
class sine#
Sine wave oscillator.
The fundamental building block for additive synthesis, vibrato, and test tones.
Public Functions
-
YSE::DSP::buffer &operator()(Flt frequency, UInt length = STANDARD_BUFFERSIZE)#
Generate a fresh block at
frequencyHz.
-
YSE::DSP::buffer &operator()(YSE::DSP::buffer &in)#
Generate one block driven by per-sample frequency in
in.
-
sine()#
-
void reset()#
Reset the phase to zero.
Private Functions
-
void calc(Bool useFrequency)#
-
YSE::DSP::buffer &operator()(Flt frequency, UInt length = STANDARD_BUFFERSIZE)#
-
class vcf#
Voltage-controlled (variable-cutoff) filter.
A resonant filter whose centre frequency tracks a control buffer. Use it for filter sweeps driven by an LFO, an envelope, or any other DSP buffer.
-
class cosine#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.Enums
-
enum LFO_TYPE#
Available LFO shapes for
lfoand fordspObject::lfoType.Values:
-
enumerator LFO_NONE#
No modulation.
-
enumerator LFO_SAW#
Sawtooth, rising 0 → 1.
-
enumerator LFO_SAW_REVERSED#
Reverse sawtooth, falling 1 → 0.
-
enumerator LFO_TRIANGLE#
Symmetric triangle.
-
enumerator LFO_SINE#
Sine, mapped to [0, 1].
-
enumerator LFO_SQUARE#
Square wave alternating between 0 and 1.
-
enumerator LFO_RANDOM#
Stepped random (sample-and-hold) between 0 and 1.
-
enumerator LFO_NONE#
-
enum LFO_TYPE#
-
namespace DSP
Envelopes and ramps#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class envelope#
Time-value envelope (breakpoint shape).
Extracts an amplitude envelope from a source buffer or loads one from a saved breakpoint file. The resulting envelope can be applied to other buffers via
drawableBuffer::applyEnvelopeor saved back to disk.Public Functions
-
bool create(YSE::DSP::buffer &source, Int windowSize = 15)#
Extract an envelope from an audio buffer.
- Parameters:
source – Audio data to analyse.
windowSize – Analysis window in milliseconds. Larger windows produce a smoother envelope at the cost of responsiveness.
- Returns:
trueon success.
-
bool create(const char *fileName)#
Load a previously saved breakpoint file.
-
void normalize()#
Scale every value so the peak equals 1.0.
-
bool saveToFile(const char *fileName) const#
Save the breakpoint set to a file.
- Returns:
trueon success,falseon write error.
-
UInt elms() const#
Number of breakpoints.
-
Flt getLengthSec() const#
Total envelope length in seconds.
-
const breakPoint &operator[](UInt pos) const#
Access a breakpoint by index.
Private Members
-
std::vector<breakPoint> breakPoints#
-
bool create(YSE::DSP::buffer &source, Int windowSize = 15)#
-
class envelope#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class ADSRenvelope#
Playable ADSR-style envelope with optional sustain loop.
Built from a sequence of timed breakpoints; the envelope can be driven through attack / sustain / release phases at runtime. Use to shape note amplitudes in synthesisers or to gate effects.
Public Types
Public Functions
-
void addPoint(const breakPoint &point)#
Append a breakpoint.
Warning
Breakpoints must be added in ascending time order — the class does not sort them.
-
void generate()#
Compile the breakpoints into the runtime envelope.
Call once after all
addPointcalls and before invokingoperator().
-
YSE::DSP::buffer &operator()(STATE state, UInt length = STANDARD_BUFFERSIZE)#
Produce the next envelope block for the given phase.
-
void saveToFile(const char *fileName)#
Save the breakpoints to a file.
-
inline Bool isAtEnd()#
Whether the release phase has finished playing.
Private Members
-
std::vector<breakPoint> breakPoints#
-
Flt *phase#
-
Flt *loopStart#
-
Flt *loopEnd#
-
Flt *envelopeEnd#
-
Bool looping#
-
Bool endReached#
-
struct breakPoint#
Envelope vertex.
- Param time:
Time in seconds.
- Param value:
Value at this time.
- Param coef:
Curvature toward this point (0 = linear).
- Param loopStart:
Marks the beginning of the sustain loop region.
- Param loopEnd:
Marks the end of the sustain loop region.
Public Functions
-
inline breakPoint(Flt time, Flt value, Flt coef, Bool loopStart = false, Bool loopEnd = false)#
-
void addPoint(const breakPoint &point)#
-
class ADSRenvelope#
-
namespace DSP
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.Functions
-
void FastFadeIn(YSE::DSP::buffer &s, UInt length)#
Cheap in-place fade-in over the first
lengthsamples ofs.Note
lengthmust not exceeds.getLength(). < This macro is added to all public class declarations.
-
class lint#
Scalar linear interpolator.
Like
rampbut block-rate only: advances by one step perupdate()call rather than producing a sample-accurate buffer. Cheaper when you don’t need per-sample smoothing.
-
void FastFadeIn(YSE::DSP::buffer &s, UInt length)#
-
namespace DSP
Filters#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class bandPass : public YSE::DSP::filterBase#
Resonant band-pass filter.
Passes a band centred on the chosen frequency. Higher
qproduces a narrower, more resonant band.Public Functions
-
bandPass()#
Protected Attributes
-
aFlt freq#
-
aFlt gain#
-
Flt q#
-
Flt last#
-
Flt previous#
-
aFlt coef1#
-
aFlt coef2#
-
aFlt ff1#
-
aFlt ff2#
-
aFlt ff3#
-
aFlt fb1#
-
aFlt fb2#
Private Functions
-
void calcCoef()#
Private Static Functions
-
static float qCos(Flt omega)#
-
bandPass()#
-
class biQuad : public YSE::DSP::filterBase#
Configurable biquad filter — the workhorse of DSP filtering.
Pick one of the
BQ_TYPEmodes (low-pass, high-pass, band-pass, notch, peak, low-shelf, high-shelf) and tune frequency, Q, and peak gain. Seeearlevel.com/main/2010/12/20/biquad-calculator/for an interactive parameter visualiser.Public Functions
-
biQuad &set(BQ_TYPE type, Flt frequency, Flt Q, Flt peakGain = 4)#
Configure the filter in one call.
- Parameters:
type – Filter mode (low-pass, high-pass, peak, shelf, …).
frequency – Centre / cutoff frequency in Hz.
Q – Resonance.
peakGain – Peak gain in dB. Only meaningful for
BQ_PEAKand the shelving modes.
Protected Attributes
-
aFlt freq#
-
aFlt gain#
-
Flt q#
-
Flt last#
-
Flt previous#
-
aFlt coef1#
-
aFlt coef2#
-
aFlt ff1#
-
aFlt ff2#
-
aFlt ff3#
-
aFlt fb1#
-
aFlt fb2#
Private Functions
-
void calc()#
Private Members
-
BQ_TYPE type#
-
biQuad &set(BQ_TYPE type, Flt frequency, Flt Q, Flt peakGain = 4)#
-
class filterBase#
Common state shared by the simple one-pole filters.
Not intended to be instantiated directly — use
highPass,lowPass,bandPass, orbiQuad.Subclassed by YSE::DSP::bandPass, YSE::DSP::biQuad, YSE::DSP::highPass, YSE::DSP::lowPass
-
class highPass : public YSE::DSP::filterBase#
Simple high-pass filter.
Attenuates frequencies below the cutoff. Reach for this when you need to remove low-frequency rumble or thin out a signal cheaply.
Public Functions
-
class lowPass : public YSE::DSP::filterBase#
Simple low-pass filter.
Attenuates frequencies above the cutoff. Use for darkening, occlusion fakes, or anti-aliasing.
Public Functions
-
class sampleHold#
Sample-and-hold gate.
When the control
signalrises above a threshold, the latest input sample is captured and held in the output until the next trigger. Classic for stepped-pitch effects and quantised modulation.
-
class bandPass : public YSE::DSP::filterBase#
-
namespace DSP
Delay#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.Functions
-
void readInterpolated(buffer &ctrl, buffer &out, buffer &buffer, UInt &pos)#
Read into
outat interpolated positionsctrlfrombuffer.Free function for tabular interpolation lookups — useful when reading from a buffer at fractional sample positions. < This macro is added to all public class declarations.
-
class delay#
Variable-length delay line.
Push audio in with
process, then read it back at one or more offsets withread. The read offset can be a constant (fixed delay) or another buffer (per-sample modulated delay, useful for chorus, flanger, and Doppler-style effects).Public Functions
-
delay &setSize(UInt size)#
Resize the delay line.
Longer lines use more memory but allow longer maximum delays.
-
delay &process(buffer &buffer)#
Write a block into the delay line.
Call once per audio processing tick. Must precede
readcalls for that tick.
-
delay &read(buffer &result, UInt delayTime)#
Read from the delay at a fixed offset.
- Parameters:
result – Destination buffer for the delayed audio.
delayTime – Offset in samples from the most recent write.
-
delay &read(buffer &result, buffer &delayTime)#
Read from the delay at a per-sample variable offset.
- Parameters:
result – Destination buffer for the delayed audio.
delayTime – Per-sample offsets in samples. Use this for modulated delays (chorus, flanger).
-
delay(Int size)#
Construct a delay line of the given initial size.
-
delay &setSize(UInt size)#
-
void readInterpolated(buffer &ctrl, buffer &out, buffer &buffer, UInt &pos)#
-
namespace DSP
Filter primitives#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class complexOnePole#
Complex one-pole IIR filter.
Operates on multichannel buffers: channel 0 carries the real part, channel 1 the imaginary part. Useful for building Hilbert transforms and other quadrature filters.
Public Functions
-
complexOnePole()#
-
complexOnePole()#
-
class complexOneZero#
Complex one-zero FIR filter.
See
complexOnePolefor the channel convention.Public Functions
-
complexOneZero()#
-
complexOneZero()#
-
class complexOneZeroReversed#
Complex one-zero FIR with reversed sign.
See
complexOnePolefor the channel convention.Public Functions
-
complexOneZeroReversed()#
-
complexOneZeroReversed()#
-
class realOnePole#
Real-valued one-pole IIR filter.
Building block for low-level filter design. Takes a sample buffer and a per-sample feedback coefficient buffer.
Public Functions
-
inline realOnePole()#
-
inline realOnePole()#
-
class complexOnePole#
-
namespace DSP
Interpolation#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class interpolate4#
4-point cubic interpolator.
Reads from a source
bufferat fractional positions and produces smoothly interpolated output. Used internally for pitch-shifting and wavetable lookups; expose it directly when you need to resample or re-pitch a buffer at user-defined positions.Public Functions
-
interpolate4()#
-
interpolate4 &source(buffer &data)#
Set the source buffer to read from.
-
interpolate4 &onset(Int value)#
Set the read-offset relative to the start of the source.
-
Int onset()#
Current read-offset.
-
interpolate4()#
-
class interpolate4#
-
namespace DSP
DSP base#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
namespace DSP
Audio buffers, oscillators, filters, envelopes, and effect modules.
Build chains of
DSP::dspObjectto process a sound,DSP::dspSourceObjectto feed one. Single-channel audio data lives inDSP::bufferand its drawing / file / wavetable subclasses.-
class dspObject#
Base class for chainable DSP effects.
Subclass and implement
createandprocessto define a custom effect that can be linked into a sound’s processing chain viaYSE::sound::setDSP. The base class provides bypass control, a wet/dry impact slider, and a built-in LFO that can modulate the effect’s parameters.Chain instances together with
link:a.link(b); b.link(c);.Subclassed by YSE::DSP::MODULES::bandPassFilter, YSE::DSP::MODULES::basicDelay, YSE::DSP::MODULES::difference, YSE::DSP::MODULES::granulator, YSE::DSP::MODULES::highPassFilter, YSE::DSP::MODULES::lowPassFilter, YSE::DSP::MODULES::phaser, YSE::DSP::MODULES::sweepFilter, YSE::DSP::ringModulator
Public Functions
-
dspObject()#
-
virtual ~dspObject()#
-
virtual void create() = 0#
One-time setup before processing starts.
Allocate buffers and any other heavyweight state here — never inside
process. The engine callscreatefrom a setup thread before the firstprocesscall.
-
virtual void process(std::vector<YSE::DSP::buffer> &buffer) = 0#
Process one audio block in place.
Runs on the audio thread. Must be allocation-free and reasonably bounded in time. Subclasses typically call
createIfNeeded()at the start, do their work, then callcalculateImpact()at the end to apply the wet/dry mix.
-
void link(dspObject &next)#
Insert
nextafter this object in the processing chain.If a downstream object is already linked,
nextis spliced between this object and the existing next.
-
inline dspObject &bypass(Bool value)#
Bypass this effect when
true.Bypassed effects still run but pass input through unchanged.
-
inline Bool bypass()#
Whether this effect is bypassed.
-
inline dspObject &impact(Flt value)#
Wet/dry mix in [0.0, 1.0].
0 is fully dry, 1 is fully processed.
-
inline Flt impact()#
Current wet/dry mix value.
-
inline dspObject &lfoType(LFO_TYPE type)#
Set the modulation LFO shape.
LFO_NONEdisables modulation.
-
inline Flt lfoFrequency()#
Current LFO frequency.
Protected Functions
-
void createIfNeeded()#
Subclass helper: run
createlazily on firstprocesscall.
-
dspObject()#
-
class dspSourceObject#
Base class for DSP-driven sound sources.
Where
dspObjectis an effect,dspSourceObjectis a generator — it produces audio rather than transforming it. Subclass and implementprocessandfrequencyto drive aYSE::soundfrom procedural audio (seeYSE::sound::createfor the lifetime contract).Subclassed by YSE::DSP::sineWave
Public Functions
-
dspSourceObject(Int buffers = 1)#
Construct with
buffersaudio channels (1 = mono, 2 = stereo, …).
-
virtual void process(SOUND_STATUS &intent) = 0#
Fill
sampleswith the next audio block.- Parameters:
intent – The current playback intent (start, stop, pause, etc.) — subclasses use this to drive amplitude envelopes and trigger transitions.
-
virtual void frequency(Flt value) = 0#
Set the fundamental frequency of the generator.
-
dspSourceObject(Int buffers = 1)#
-
class dspObject#
-
namespace DSP