Core
Generators
-
class maxiOsc
Public Functions
-
double square(double frequency)
Square wave oscillator
- Parameters
frequency – in Hz
-
double sinewave(double frequency)
Sine wave oscillator
- Parameters
frequency – in Hz
-
double coswave(double frequency)
Cosine wave oscillator
- Parameters
frequency – in Hz
-
double saw(double frequency)
Saw wave oscillator
- Parameters
frequency – in Hz
-
double phasor(double frequency)
A ramp rising from 0 to 1
- Parameters
frequency – in Hz
-
double phasorBetween(double frequency, double startphase, double endphase)
A ramp rising from 0 to 1
- Parameters
frequency – in Hz
startPhase – the start point of the phasor (0-1)
endPhase – the end point of the phasor (0-1)
-
double triangle(double frequency)
Triangle oscillator
- Parameters
frequency – in Hz
-
double pulse(double frequency, double duty)
Pulse wave oscillator
- Parameters
frequency – in Hz
duty – Pulse width (0-1)
-
double impulse(double frequency)
Impulse generator
- Parameters
frequency – in Hz
-
double sinebuf(double frequency)
Fast sine wave oscillator, generated from a wavetable with linear interpolation
- Parameters
frequency – in Hz
-
double noise()
White noise generator
-
double sinebuf4(double frequency)
Fast sine wave oscillator, generated from a wavetable with quadratic interpolation
- Parameters
frequency – in Hz
-
double sawn(double frequency)
Anti-aliases saw wave oscillator
- Parameters
frequency – in Hz
-
void phaseReset(double phaseIn)
Set the phase of the oscillator
- Parameters
phaseIn – The phase, from 0 to 1
-
double square(double frequency)
-
class maxiPolyBLEP
Anti-aliased oscillators;
Public Types
-
using Waveform = PolyBLEP::Waveform
Waveform types: SINE, COSINE, TRIANGLE, SQUARE, RECTANGLE, SAWTOOTH, RAMP, MODIFIED_TRIANGLE, MODIFIED_SQUARE, HALF_WAVE_RECTIFIED_SINE, FULL_WAVE_RECTIFIED_SINE, TRIANGULAR_PULSE, TRAPEZOID_FIXED, TRAPEZOID_VARIABLE
-
using Waveform = PolyBLEP::Waveform
-
class maxiEnvGen
An envelope generator.
Public Functions
-
inline double play(double trigger)
Get the latest value of the envelope
- Parameters
trigger – A positive zero crossing (or constant 1) starts the envelope
-
inline bool setup(DOUBLEARRAY levels, DOUBLEARRAY times, DOUBLEARRAY curves, bool looping, bool allowRetrigger = false)
Configure the envelope generator
- Parameters
levels – An array of levels
times – An array of times between the levels, in milliseconds. To make the envelope hold until the first negative zero crossing, use maxiEnvGen::HOLD as the time. Only one hold segment is allowed.
curves – An array of exponential curve values to shape each segment (1 = straight, 2= squared, 0.5 = square root etc)
looping – True if the envelope should infinitely repeat
allowRetrigger – Set to true if the envelope should allow retriggering before it is finished, or false if the envelope should always reach the end before being allowed to restart Example C++ usage env.setup({0,1,0},{100,400}, {0.5,1}, false). levels should be one element longer than times and curves
- Returns
True if the configuration was successful
-
inline void reset()
Restart the envelope immeadiately
-
inline void resetAndArm()
Stop the envelope and wait for a new trigger to start it
-
inline bool setLevel(size_t index, double value)
Set the level of a segment of the envelope
- Parameters
index – The index of the level
value – The new level
-
inline bool setCurve(size_t index, double value)
Set the curve of a segment of the envelope
- Parameters
index – The index of the segment
value – The new curve value
-
inline bool setTime(size_t index, double value)
Set the length of a segment of the envelope
- Parameters
index – The index of the segment
value – The new length (in ms)
-
inline void setupAR(const double attack, const double release)
Helper function to create a triangular envelope
- Parameters
attack – Rise time in ms
release – Fall time in ms
-
inline void setupASR(const double attack, const double release)
Helper function to create a triangular(ish) envelope with sustain section at peak The sustain section will end when the trigger input drops below 0
- Parameters
attack – Rise time in ms
release – Fall time in ms
-
inline void setupADSR(const double attack, const double decay, const double sustain, const double release)
Helper function to create an attack-decay-sustain-release envelope The sustain section will end when the trigger input drops below 0 The envelope will rise from 0 to 1 in the attack segment, then drop to the sustain level before falling to 0.
- Parameters
attack – Rise time in ms
decay – Decay time in ms
sustain – Sustain level
release – Fall time in ms
-
inline void setRetrigger(const bool val)
Set the envelope to retrigger or not
- Parameters
val – True is the envelope should retrigger, false if not
-
inline bool getRetrigger()
Find out if the envelope retriggers
-
inline void setLoop(const bool val)
Set the envelope to loop or not
- Parameters
val – True is the envelope should loop, false if not
-
inline bool getLoop()
Find out if the envelope loops
-
inline double play(double trigger)
Filters
-
class maxiSVF
State Variable Filter
algorithm from http://www.cytomic.com/files/dsp/SvfLinearTrapOptimised.pdf usage:
filter.setCutoff(param1); filter.setResonance(param2);
w = filter.play(w, 0.0, 1.0, 0.0, 0.0);
Public Functions
-
inline void setCutoff(double cutoff)
Set the cutoff frequency
- Parameters
cutoff – Cuttoff frequency (20 < cutoff < 20000)
-
inline void setResonance(double q)
Set the resonance of the filter
- Parameters
q – From 0 upwards, starts to ring from 2-3ish, cracks a bit around 10
-
inline double play(double w, double lpmix, double bpmix, double hpmix, double notchmix)
run the filter, and get a mixture of lowpass, bandpass, highpass and notch outputs
- Parameters
w – The signal to be filtered
lpmix – the amount of low pass filtering (0-1)
bpmix – the amount of bandpass pass filtering (0-1)
hpmix – the amount of high pass filtering (0-1)
notchmix – the amount of notch filtering (0-1)
-
inline void setCutoff(double cutoff)
-
class maxiBiquad
Biquad filters based on http://www.earlevel.com/main/2011/01/02/biquad-formulas/ and https://ccrma.stanford.edu/~jos/fp/Direct_Form_II.html
Public Types
Public Functions
-
inline double play(double input)
Process a signal through the filter
- Parameters
input – A signal
-
inline void set(filterTypes filtType, double cutoff, double Q, double peakGain)
Configure the filter
- Parameters
filtType – The type of filter, set from maxiBiquad::filterTypes
cutoff – The filter cutoff frequency in Hz
Q – The resonance of the filter
peakGain – The gain of the filter (only used for PEAK, HIGHSHELF and LOWSHELF)
-
inline double play(double input)
Dynamics
-
class maxiDynamics
The class provides a range of dynamics processing: downward and upward compression, downward and upward expansion, sidechaining, attack and release, lookahead and peak or RMS detection
Public Functions
-
inline double play(double sig, double control, double thresholdHigh, double ratioHigh, double kneeHigh, double thresholdLow, double ratioLow, double kneeLow)
This functions compands the signal, providing download compression or upward expansion above an upper thresold, and upward compression or downward expansion below a lower threshold.
- Parameters
sig – The input signal to be companded
control – This signal is used to trigger the compander. Use it for sidechaining, or if no sidechain is needed, use the same signal for this and the input signal
thresholdHigh – The high threshold, in Dbs
ratioHigh – The ratio for companding above the high threshold
kneeHigh – The size of the knee for companding above the high threshold (in Dbs)
thresholdLow – The low threshold, in Dbs
ratioLow – The ratio for companding below the low threshold
kneeLow – The size of the knee for companding below the low threshold (in Dbs)
- Returns
a companded signal
-
inline double compress(double sig, double threshold, double ratio, double knee)
Compress a signal (using downward compression)
- Parameters
sig – The input signal to be compressed
threshold – The threshold, in Dbs
ratio – The compression ratio (>1 provides compression, <1 provides expansion)
knee – The size of the knee (in Dbs)
- Returns
a compressed signal
-
inline double sidechainCompress(double sig, double control, double threshold, double ratio, double knee)
Compress a signal with sidechaining (using downward compression)
- Parameters
sig – The input signal to be compressed
control – The sidechain signal
threshold – The threshold, in Dbs
ratio – The compression ratio (>1 provides compression, <1 provides expansion)
knee – The size of the knee (in Dbs)
- Returns
a compressed signal
-
inline double compandAbove(double sig, double control, double threshold, double ratio, double knee)
Compand a signal, using detection above a threshold (provides downward compression or upward expansion)
- Parameters
sig – The input signal to be compressed
control – The sidechain signal
threshold – The threshold, in Dbs
ratio – The compression ratio (>1 provides compression, <1 provides expansion)
knee – The size of the knee (in Dbs)
- Returns
a companded signal
-
inline double compandBelow(double sig, double control, double threshold, double ratio, double knee)
Compand a signal, using detection below a threshold (provides upward compression or downward expansion)
- Parameters
sig – The input signal to be compressed
control – The sidechain signal
threshold – The threshold, in Dbs
ratio – The compression ratio (>1 provides compression, <1 provides expansion)
knee – The size of the knee (in Dbs)
- Returns
a companded signal
-
inline void setAttackHigh(double attack)
Set the attack time for the high threshold. This is the amount of time over which the ratio moves from 1 to its full value, following the input analyser going over the threshold.
- Parameters
attack – The attack time (in milliseconds)
-
inline void setReleaseHigh(double release)
Set the release time for the high threshold. This is the amount of time over which the ratio moves from its full value to 1, following the input analyser going under the threshold.
- Parameters
release – The release time (in milliseconds)
-
inline void setAttackLow(double attack)
Set the attack time for the low threshold. This is the amount of time over which the ratio moves from 1 to its full value, following the input analyser going under the threshold.
- Parameters
attack – The attack time (in milliseconds)
-
inline void setReleaseLow(double release)
Set the release time for the low threshold. This is the amount of time over which the ratio moves from its full value to 1, following the input analyser going over the threshold.
- Parameters
release – The release time (in milliseconds)
-
inline void setLookAhead(double length)
The look ahead creates a delay on the input signal, meaning that that the signal is compressed according to event that have already happened in the control signal. This can be useful for limiting and catching fast transients.
- Parameters
length – The amount of time the compressor looks ahead (in milliseconds)
-
inline double getLookAhead()
- Returns
the look ahead time (in milliseconds)
-
inline void setRMSWindowSize(double winSize)
Set the size of the RMS window. Longer times give a slower response
- Parameters
winSize – The size of the window (in milliseconds)
-
inline void setInputAnalyser(ANALYSERS mode)
Set the method by which the compressor analyses the control input \mode maxiDynamics::PEAK for peak analysis, maxiDynamics::RMS for rms analysis
-
inline double play(double sig, double control, double thresholdHigh, double ratioHigh, double kneeHigh, double thresholdLow, double ratioLow, double kneeLow)
Effects
-
class maxiDelayline
A delay line
Public Functions
-
double dl(double input, int size, double feedback)
Apply a delay to a signal
- Parameters
input – a signal,
size – the size of the delay in samples
feedback – the amount of feedback
-
double dlFromPosition(double input, int size, double feedback, int position)
Apply a delay to a signal, reading from a specific position in the buffer
- Parameters
input – a signal,
size – the size of the delay in samples
feedback – the amount of feedback
position – the position in the buffer (in samples)
-
double dl(double input, int size, double feedback)
-
class maxiNonlinearity
Various ways to distort signals
Public Functions
-
inline double atanDist(const double in, const double shape)
atan distortion, see http://www.musicdsp.org/showArchiveComment.php?ArchiveID=104
- Parameters
in – A signal
shape – from 1 (soft clipping) to infinity (hard clipping)
-
inline double fastAtanDist(const double in, const double shape)
Faster but ‘lower quality’ version of atan distortion
- Parameters
in – A signal
shape – from 1 (soft clipping) to infinity (hard clipping)
-
inline double softclip(double x)
Cliping with nicer harmonics
- Parameters
x – A signal
-
inline double hardclip(double x)
Cliping with nastier harmonics
- Parameters
x – A signal
-
inline double asymclip(double x, double a, double b)
asymmetric clipping: chose the shape of curves for both positive and negative values of x try it here https://www.desmos.com/calculator/to6eixatsa
- Parameters
x – A signal
a – Exponent for the positive curve
b – Exponent for the negative curve
-
inline double fastatan(double x)
Fast atan distortion
- Parameters
x – A signal
-
inline double atanDist(const double in, const double shape)
Analysis
-
class maxiZeroCrossingDetector
Detect positive zero-crossings: the point in time when a signal transitions from 0 or less, to above zero
Public Functions
-
inline bool zx(double x)
Returns true when a positive zero-crossing occurs, othersize false
- Parameters
x – A signal
-
inline bool zx(double x)
-
class maxiZeroCrossingRate
Calculate the zero crossing rate of a signal This is a fairly crude measure of frequency, which is confounded by complex waveforms and noise
Public Functions
-
inline double play(double signal)
Calculate the zero cross rate
- Parameters
signal – a signal
- Returns
the zero crossing rate in Hz
-
inline double play(double signal)
-
class maxiRMS
Calculate the Root Mean Square of a signal over a window of time This is a good measurement of the amount of power in a signal
Public Functions
-
inline void setup(double maxLength, double windowSize)
Configure the analyser
- Parameters
maxLength – The maximum length of time to analyse (ms)
windowSize – The size of the window of time to analyse initially (ms, <= maxLength)
-
inline void setWindowSize(double newWindowSize)
Set the size of the analysis window
- Parameters
newWindowSize – the size of the analysis window (in ms). Large values will smooth out the measurement, and make it less responsive to transients
-
inline double getWindowSize()
Find out the size of the analysis window (in ms)
-
inline void setup(double maxLength, double windowSize)
Sequencing
-
class maxiStep
Pull sequential values from an array
Public Functions
-
inline double pull(const double trigSig, DOUBLEARRAY values, double step)
Take values from the array when triggered
- Parameters
trigSig – A signal to trigger a new value on a positive zero crossing
values – An array of values \step The amount that the array index should increase after pulling a new value. This wraps around to zero at the end of the array
-
inline double getIndex()
Get the current array index
-
inline double pull(const double trigSig, DOUBLEARRAY values, double step)
Utility Functions
-
class maxiPoll
Poll values to stdout at regular intervals
Public Functions
-
inline double poll(double val, double frequency = 4, string txt = "", string end = "\n")
- Parameters
val – The value to poll
frequency – How often to print this value (Hz)
txt – Additional text to br printed before the value
- Returns
the value being polled, so this can used as a pass-through function e.g. filter.play(obj.poll(osc.saw(2)),0.5)
-
inline double poll(double val, double frequency = 4, string txt = "", string end = "\n")
-
class maxiConvert
Conversion functions
Public Static Functions
-
static double mtof(int midinote)
Convert from MIDI note number to frequency (Hz)
- Parameters
midinote – A MIDI note number
-
static inline size_t msToSamps(double timeMs)
Convert from milliseconds to samples
- Parameters
timeMs – The number of milliseconds
-
static inline double sampsToMs(size_t samples)
Convert from samples to milliseconds
- Parameters
samples – The number of samples
-
static inline double ampToDbs(double amp)
Convert from amplitude to decibels
- Parameters
amp – Amplitude
-
static inline double dbsToAmp(double dbs)
Convert from decibels to amplitude
- Parameters
dbs – Decibels
-
static double mtof(int midinote)
-
class maxiRingBuf
A ring buffer. This enables you to look at the last N values in a time series.
Public Functions
-
inline void setup(size_t N)
Allocate memory for the buffer
- Parameters
N – The maximum length of the buffer
-
inline void push(double x)
Add the latest value to the buffer
- Parameters
x – A value
-
inline size_t size()
- Returns
The size of the buffer
-
inline double head()
- Returns
the value at the front of the buffer
-
inline double tail(size_t N)
- Parameters
N – The size of the window, N < the size of the buffer
- Returns
the oldest value in the buffer, for a particular window size
-
inline double reduce(size_t N, reduceFunction func, double initval)
Apply a function of the previous N values in the buffer
- Parameters
N – The number of values in the window
func – A function in the form double func(double previousResult, double nextValue)
initval – The initial value to pass into the function (usually 0)
- Returns
The last result of the function, after passing in all values from the window Example: this function will sum the values in the window: auto sumfunc = [](double val, double n) {return val + n;};
-
inline void setup(size_t N)