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 maxiSample
A sampler
Public Functions
-
inline size_t getLength()
- Returns
The length of the sample, in samples
-
inline maxiSample &operator=(const maxiSample &source)
Use the = operator to copy from one sample to another
- Parameters
source – another maxiSample instance
-
bool load(string fileName, int channel = 0)
Load a mono channel from a file in wav format
- Parameters
fileName – the file name
channel – the index of the channel to read
-
bool save()
Save the file
-
bool save(string filename)
Save the file, specifying a file name
- Parameters
filename – The file name
-
string getSummary()
- Returns
a printable summary of the wav file
-
inline bool isReady()
Check if the sample is loaded
- Returns
true if the sample is ready to play
-
inline void setSample(DOUBLEARRAY_REF _sampleData)
Set the sample from an external array
- Parameters
_sampleData – An double array (JS) or vector (C++) of data
-
inline void setSampleAndRate(DOUBLEARRAY_REF _sampleData, int sampleRate)
Set the sample from an external array, and set the sample rate
- Parameters
_sampleData – An double array (JS) or vector (C++) of data
sampleRate – the sample rate
-
inline void clear()
Clear the sample data
-
void trigger()
Trigger the sample from the start
-
inline void loopRecord(double newSample, const bool recordEnabled, const double recordMix, double start, double end)
Record into the sample buffer
- Parameters
newSample – a signal
recordEnabled – set to true to record into the loop
recordMix – the balance between existing sample and the new signal (1 = overdub, 0=no recording, 0.5=equal mix)
start – the loop start point (0-1)
end – the loop end point (0-1)
-
inline void reset()
Reset the sample to play from the start
-
double play()
Play the sample, with no modification
-
double playWithPhasor(double pha)
Play the sample, providing a phasor to control the position
- Parameters
pha – a phasor signal (from 0 to 1)
-
double playLoop(double start, double end)
Play the sample in a loop
- Parameters
start – start position (0-1)
end – end position (0-1)
-
double playOnce()
Play the sample once and stop
-
double playOnZX(double trigger)
Play the sample when a trigger is received
- Parameters
trigger – a signal
-
double playOnZXAtSpeed(double trig, double speed)
Play the sample when a trigger is received, at a modified speed
- Parameters
trigger – a signal
speed – the speed multiplier (1=no change, 2=double etc)
-
double playOnZXAtSpeedFromOffset(double trig, double speed, double offset)
Play the sample when a trigger is received, at a modified speed from a specific position
- Parameters
trigger – a signal
speed – the speed multiplier (1=no change, 2=double etc)
offset – the start position (0-1)
-
double playOnZXAtSpeedBetweenPoints(double trig, double speed, double offset, double length)
Play the sample when a trigger is received, at a modified speed beween two positions
- Parameters
trigger – a signal
speed – the speed multiplier (1=no change, 2=double etc)
offset – the start position (0-1)
length – the length of the segment (0-1)
-
double loopSetPosOnZX(double trigger, double position)
Loop the sample, and set the playback position to a specific point when a trigger is received
- Parameters
trigger – a signal
position – the position to move to when a trigger is recevied
-
double playOnceAtSpeed(double speed)
Play the samples once, at a modified speed
- Parameters
speed – a speed multiplier
-
void setPosition(double newPos)
Set the playback position
- Parameters
newPos – (0-1)
-
double playUntil(double end)
Play from the start to a specific position
- Parameters
end – the end point (0-1)
-
double playUntilAtSpeed(double end, double speed)
Play from the start to a specific position, at a modified speed
- Parameters
end – the end point (0-1)
speed – a speed multiplier
-
double playAtSpeed(double speed)
Play at a modified speed
- Parameters
speed – a speed multiplier
-
double playAtSpeedBetweenPointsFromPos(double frequency, double start, double end, double pos)
Play at a modified speed between two points, from a position
- Parameters
frequency – the playback pitch (in Hz)
start – the start point (in samples)
end – the end point (in samples)
pos – the starting position (in samples)
-
double playAtSpeedBetweenPoints(double frequency, double start, double end)
Play at a modified speed between two points
- Parameters
frequency – the playback pitch (in Hz)
start – the start point (in samples)
end – the end point (in samples)
-
double play4(double frequency, double start, double end)
Play at a modified speed between two points, using quadratic interpolation
- Parameters
frequency – the playback pitch (in Hz)
start – the start point (in samples)
end – the end point (in samples)
-
void normalise(double maxLevel)
Normalise the sample buffer
- Parameters
maxLevel – the maximum absolute level
-
void autoTrim(float alpha, float threshold, bool trimStart, bool trimEnd)
Trim the sample buffer to remove silence from the ends
- Parameters
alpha – the sensitivity
threshold – the value above which to start trimming
trimStart – true if the start should be trimmed
trimEnd – true if the end should be trimmed
-
inline size_t getLength()
-
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)
-
class maxiLine
A line generator (you can also use maxiEnvGen)
Public Functions
-
inline double play(double trigger)
Generate a line, when a trigger is received
- Parameters
trigger – a signal
-
inline void prepare(double start, double end, double durationMs, bool isOneShot)
Setup the line before it is triggered
- Parameters
start – the starting value of the line
end – the ending value of the line
durationMs – the duration of the line (in milliseconds)
isOneShot – true is the line should not play once, or false if it should loop
- Returns
a signal
-
inline void triggerEnable(double on)
- Parameters
0 – or less to protect the generator from triggering, more than 0 to enable it to be triggered
-
inline bool isLineComplete()
- Returns
true if the line generator has finished
-
inline double play(double trigger)
-
class maxiKuramotoOscillator
A kuramoto oscillator
This is an adaptive oscillator that adjusts its own phase in relation to the phases of other kuramoto oscillators
For further info, see https://tutorials.siam.org/dsweb/cotutorial/index.php?s=3&p=0 https://www.complexity-explorables.org/explorables/ride-my-kuramotocycle/
Public Functions
-
inline double play(double freq, double K, std::vector<double> phases)
Run the oscillator
- Parameters
freq – the intended frequency of the oscillator
K – the strengh of coupling between oscillators
phases – a vector of the phases of other kuramoto oscillators
- Returns
the current amplitude of the oscillator
-
inline void setPhase(double newPhase)
Set the phase of the oscillator
- Parameters
newPhase – the phase, 0 - 2PI
-
inline double getPhase()
- Returns
the current phase of the oscillator
-
inline double play(double freq, double K, std::vector<double> phases)
-
class maxiKuramotoOscillatorSet
This class managed a group of Kuramoto oscillators (see maxiKuramotoOscillator)
Subclassed by maxiAsyncKuramotoOscillator
Public Functions
-
inline maxiKuramotoOscillatorSet(const size_t N)
- Parameters
N – The number of oscillators in the group
-
inline void setPhases(const std::vector<double> &phases)
Set the phases of all of the oscillators
- Parameters
phases – a vector of phases (all 0 - 2PI)
-
inline void setPhase(const double phase, const size_t oscillatorIdx)
Set the phase of a single oscillator
- Parameters
phase – the phase, 0 - 2PI
oscillatorIdx – the index of the oscillator
-
inline double getPhase(size_t i)
Get the phase of a single oscillator
- Parameters
i – the index of the oscillator
- Returns
the oscillator’s phase
-
inline size_t size()
- Returns
the number of oscillators in the group
-
inline double play(double freq, double K)
Run all of the oscillators
- Parameters
freq – the intended frequency
K – the coupling strength between oscillators
- Returns
a mix of all of the oscillator signals in the group
-
inline maxiKuramotoOscillatorSet(const size_t N)
-
class maxiAsyncKuramotoOscillator : public maxiKuramotoOscillatorSet
Run a group of kuramoto oscillators with asynchronous updates. Instead of setting all of the phasors at once, you can set the phases or arbitrary individuals at abritrary times. This class updates the local oscillator according to best guesses of the phase of remote oscillators. This is useful if the other oscillators are not running on your computer, but are linked on a network. For example you could use this class for a shared network clock that is robust to timing jitter.
Public Functions
-
inline maxiAsyncKuramotoOscillator(const size_t N)
- Parameters
N – the number of oscillators in the group (including this one)
-
inline void setPhase(const double phase, const size_t oscillatorIdx)
Set the phase of a single oscillator, probably in response to receiving this information over your network
- Parameters
phase – the phase, 0 - 2PI
oscillatorIdx – the index of the oscillator
-
inline void setPhases(const std::vector<double> &phases)
Set the phases of all of the oscillators
- Parameters
phases – a vector of phases (all 0 - 2PI)
-
inline double play(double freq, double K)
Run all of the oscillators
- Parameters
freq – the intended frequency
K – the coupling strength between oscillators
- Returns
a mix of all of the oscillator signals in the group
-
inline double getPhase(size_t i)
Get the phase of a single oscillator
- Parameters
i – the index of the oscillator
- Returns
the oscillator’s phase
-
inline size_t size()
- Returns
the number of oscillators in the group
-
inline maxiAsyncKuramotoOscillator(const size_t N)
Filters
-
class maxiFilter
A selection of filters
Public Functions
-
double lores(double input, double cutoff1, double resonance)
A resonant low pass filter
- Parameters
input – A signal
cutoff1 – The cutoff frequency (in Hz)
resonance – The amount of resonance
-
double hires(double input, double cutoff1, double resonance)
A resonant high pass filter
- Parameters
input – A signal
cutoff1 – The cutoff frequency (in Hz)
resonance – The amount of resonance
-
double bandpass(double input, double cutoff1, double resonance)
A resonant band pass filter
- Parameters
input – A signal
cutoff1 – The cutoff frequency (in Hz)
resonance – The amount of resonance
-
double lopass(double input, double cutoff)
A simple low pass filter
- Parameters
input – A signal
cutoff1 – The cutoff frequency (between 0 and 1)
-
double hipass(double input, double cutoff)
A simple low pass filter
- Parameters
input – A signal
cutoff1 – The cutoff frequency (between 0 and 1)
-
inline void setCutoff(double cut)
\Sets the cutoff frequency
- Parameters
cut – The cutoff frequency
-
inline void setResonance(double res)
\Sets the resonance
- Parameters
res – The resonance
-
inline double getCutoff()
- Returns
the cutoff value
-
inline double getResonance()
- Returns
the resonance value
-
double lores(double input, double cutoff1, double resonance)
-
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
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)
-
class maxiSampleAndHold
Sample and hold effect: samples the input signal periodically and outputs that value
Public Functions
-
inline double sah(double sigIn, double holdTimeMs)
Process a signal
- Parameters
sigIn – a signal
holdTimeMs – The length of the sampling period
- Returns
the sampled signal
-
inline double sah(double sigIn, double holdTimeMs)
-
class maxiChorus
A chorus effect
Public Functions
-
inline double chorus(const double input, const unsigned int delay, const double feedback, const double speed, const double depth)
Apply a chorus effect to a signal
- Parameters
input – a signal
delay – the amount of delay (in milliseconds, recommended 1-1000)
feedback – the amount of feedback, 0-1
speed – the speed of the chorus, in Hz
depth – the depth of the chorus effect, 0-1
- Returns
the input signal with chorus applied
-
inline double chorus(const double input, const unsigned int delay, const double feedback, const double speed, const double depth)
-
class maxiFlanger
A flanger effect
Public Functions
-
inline double flange(const double input, const unsigned int delay, const double feedback, const double speed, const double depth)
Apply a flanger effect to a signal
- Parameters
input – a signal
delay – the amount of delay (in milliseconds, recommended 1-1000)
feedback – the amount of feedback, 0-1
speed – the speed of the flanger LFO, in Hz
depth – the depth of the LFO, 0-1
- Returns
the input signal, flanged
-
inline double flange(const double input, const unsigned int delay, const double feedback, const double speed, const double depth)
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)
-
class maxiTrigger
Generator triggers (a single 1 in a stream of 0s) according to certain conditions
Public Functions
-
inline double onZX(double input)
Generate a trigger when a signal transitions from <=0 to above 0
- Parameters
input – A signal
-
inline double onChanged(double input, double tolerance)
Generate a trigger when a signal changes beyond a certain amount
- Parameters
input – A signal
tolerance – The amount of chance allowed before a trigger is generated
-
inline double onZX(double input)
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)
-
class maxiCounter
Count triggers
Public Functions
-
inline double count(double incTrigger, double resetTrigger)
Increase each time a trigger is received
- Parameters
incTrigger – a signal that triggers the counter to increment
resetTrigger – a signal that resets the counter to zero
- Returns
the number of triggers received since the beginning or the last reset
-
inline double count(double incTrigger, double resetTrigger)
-
class maxiZXToPulse
Extend a trigger into a pulse. This is useful for making basic gates in sequences. Use maxiEnvGen for more advanced gate and envelope generation.
Public Functions
-
inline double play(double input, double holdTimeInSamples)
Extend a trigger into a pulse.
- Parameters
input – a signal
holdTimeInSamples – the length of the pulse in samples (use maxiConvert to get this value from milliseconds)
- Returns
a pulse, triggered by a zero crossing in the input
-
inline double play(double input, double holdTimeInSamples)
-
class maxiRatioSeq
Sequence triggers and numbers, using a list of modulateable ratios to control timing.
Public Functions
-
inline double playTrig(double phase, DOUBLEARRAY times)
Divide a phasor into periods according to a set o ratios, and send a trigger at the start of each period.
Examples ratios: (assuming the phasor takes the length of one bar to cycle and 4/4 timing):
{1,1,1,1} four crotchets
{2,2,2,1,1} three crotchets then two quavers
{4,4,4,1,1,1,1} three crotchets then four semi-quavers
{3,3,2} two dotted crotchets then a crotchet
{1} a semibrieve
{3,3,3,1,1,1} three crotchets followed by a triplet
{33,991,13,153} hmmm - well it might sound interesting?
{
maxiMap::linlin(osc.phasor(0.4),0,1,10,20),100} modulate the ratios- Parameters
phase – a phasor signal, rising from 0 to 1 (you could use maxiOsc::phasor)
times – a list of time ratios. The phasor will be divided up into these ratios, and a trigger will be returned at the start of each period
- Returns
a trigger at the start of each period
-
inline double playValues(double phase, DOUBLEARRAY_REF times, DOUBLEARRAY_REF values)
Take values incrementally from a list, with timing controlled by ratios
- Parameters
phase – see playTrig
times – see playTrig
values – an array of numbers. Each time a period starts, a number is returned from this list. Values are taken incrementally and with looping. The contents and length of the list are modulateable. This function is useful for sequencing pitches or controller values.
- Returns
a value taken incrementally from the list of values, updated each time a new timing period begins (according to the list of ratios)
-
inline double playTrig(double phase, DOUBLEARRAY times)
-
class maxiSelectX
Read from an array of signals or values, with linear interpolation between neighbours - like supercollider SelectX.ar
Public Functions
-
inline double play(double index, DOUBLEARRAY_REF values, bool normalised)
Read from an array with linear interpolation. This can be useful for cross-fading across sets of signals.
- Parameters
index – an index into the array
values – a modulateable array of values
normalised – if true, the index should be between 0 and 1, if false, then the index should be between 0 and length(values)-1
- Returns
an item from the array of values, according to the index, and interpolating between neighbouring values.
e.g if values = {2,3} and normalised index = 0.5, then 2.5 will be returns
-
inline double play(double index, DOUBLEARRAY_REF values, bool normalised)
-
class maxiIndex
Pull values from an array when a trigger is received, according to a modulateable index
Public Functions
-
inline double pull(const double trigSig, double indexSig, DOUBLEARRAY_REF _values)
- Parameters
trigSig – a signal
indexSig – a normalised index into the array (0-1)
_values – an array of values or signals (modulateable)
- Returns
the value at [indexSig] in the array, when a trigger is received in [trigSig]
-
inline double pull(const double trigSig, double indexSig, DOUBLEARRAY_REF _values)
Multichannel
-
class maxiMix
Functions for multichannel panning
Public Functions
-
void stereo(double input, std::vector<double> &two, double x)
Stereo panning
- Parameters
input – A mono signal
two – A vector (size 2) into which the signal is panned in-place
x – The panning level (0 to 1)
-
void quad(double input, std::vector<double> &four, double x, double y)
Quadraphonic panning
- Parameters
input – A mono signal
four – A vector (size 4) into which the signal is panned
x – Left-right panning level (0 to 1)
y – Forward-backward panning level (0 to 1)
-
void ambisonic(double input, std::vector<double> &eight, double x, double y, double z)
Ambisonic panning
- Parameters
input – A mono signal
eight – A vector (size 8) into which the signal is panned
x – Left-right panning level (0 to 1)
y – Forward-backward panning level (0 to 1)
z – Up-down panning level (0 to 1)
-
void stereo(double input, std::vector<double> &two, double x)
-
class maxiXFade
Cross-fade between two signals, using equal-power panning
Public Static Functions
-
static inline vector<double> xfade(vector<double> &ch1, vector<double> &ch2, double xfader)
Cross-fade between stereo signals
- Parameters
ch1 – a vector containing left and right components of channel 1
ch2 – a vector containing left and right components of channel 2
xfader – the cross-fader position, -1=100% ch1, 1=100% ch2, 0=an equal mix of both channels
-
static inline double xfade(double ch1, double ch2, double xfader)
Cross-fade between mono signals
- Parameters
ch1 – the signal for channel 1
ch2 – the signal for channel 2
xfader – the cross-fader position, -1=100% ch1, 1=100% ch2, 0=an equal mix of both channels
-
static inline vector<double> xfade(vector<double> &ch1, vector<double> &ch2, double xfader)
Utility Functions
-
class maxiMap
Various mapping functions
Public Static Functions
-
static inline double linlin(double val, double inMin, double inMax, double outMin, double outMax)
Map from one range to another, linearly
- Parameters
val – a signal
inMin – the lowest expected value of the signal
inMax – the highest expected value of the signal
outMin – the lowest value in the new range of the signal
outMax – the highest value in the new range of the signal
- Returns
a signal
-
static inline double linexp(double val, double inMin, double inMax, double outMin, double outMax)
Map from one range to another, converting from linear to expontial - useful from mapping control values to frequencies etc
- Parameters
val – a signal
inMin – the lowest expected value of the signal
inMax – the highest expected value of the signal
outMin – the lowest value in the new range of the signal
outMax – the highest value in the new range of the signal
- Returns
a signal
-
static inline double explin(double val, double inMin, double inMax, double outMin, double outMax)
Map from one range to another, converting from an exponential value to a linear one
- Parameters
val – a signal
inMin – the lowest expected value of the signal
inMax – the highest expected value of the signal
outMin – the lowest value in the new range of the signal
outMax – the highest value in the new range of the signal
- Returns
a signal
-
static inline double clamp(double v, const double low, const double high)
Restrict a signal to upper and lower bounds
- Parameters
v – a signal
low – the lowest value
high – the highest value
- Returns
a signal
-
static inline double linlin(double val, double inMin, double inMax, double outMin, double outMax)
-
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)