Automatic range control UGen.
An affine transformation UGen for image rotation, scaling, translation, shearing.
An affine transformation UGen for image rotation, scaling, translation, shearing.
It uses either a sinc-based band-limited resampling algorithm, or
bicubic interpolation, depending on the zeroCrossings
parameter.
All window defining parameters (widthIn
, heightIn
, widthOut
, heightOut
)
are polled once per matrix. All matrix and filter parameters are polled one per
output pixel.
the signal to resample
the width (number of columns) of the input matrix
the height (number of rows) of the input matrix
the width (number of columns) of the output matrix.
the special value zero (default) means it is the same as widthIn
.
the height (number of rows) of the output matrix.
the special value zero (default) means it is the same as heightIn
.
coefficient of the first column of the first row (scale-x)
coefficient of the first column of the second row (shear-y)
coefficient of the second column of the first row (shear-x)
coefficient of the second column of the second row (scale-y)
coefficient of the third column of the first row (translate-x)
coefficient of the third column of the second row (translate-y)
if non-zero, wraps coordinates around the input images boundaries.
TODO: currently wrap = 0
is broken if using sinc interpolation!
the FIR anti-aliasing roll-off width. Between zero and one.
the FIR windowing function's parameter
the number of zero-crossings in the truncated and windowed sinc FIR. If zero, algorithm uses bicubic interpolation instead.
A UGen that produces an arithmetic sequence of values.
A UGen that produces an arithmetic sequence of values.
If both start
and step
are of integer type (Int
or Long
),
this produces an integer output, otherwise it produces a floating point output.
E.g. ArithmSeq(start = 1, step = 2)
will produce a series 1, 3, 5, 7, ...
.
the first output element
the amount added to each successive element
the number of elements to output
A UGen that reads in an audio file.
A UGen that reads in an audio file. The output signal
is the monotonously increasing number of frames written,
which can be used to monitor progress or determine the
end of the writing process. The UGen keeps running until
the in
signal ends.
the signal to write.
the file to write to
the spec for the audio file, including numbers of channels and sample-rate
A binary operator UGen, for example two sum or multiply two signals.
A binary operator UGen, for example two sum or multiply two signals.
The left or a
input is "hot", i.e. it keeps the UGen running,
while the right or b
input may close early, and the last value will
be remembered.
the identifier of the operator (e.g. BinaryOp.Times.id
)
the left operand which determines how long the UGen computes
the right operand.
A second order filter section (biquad) UGen.
A second order filter section (biquad) UGen. Filter coefficients are given directly rather than calculated for you. The formula is equivalent to:
y(n) = b0 * x(n) + b1 * x(n-1) + b2 * x(n-2) - a1 * y(n-1) - a2 * y(n-2)
where x
is in
, and y
is the output. Note the naming and signum of the coefficients
differs from SuperCollider's SOS
.
A blob detection UGen.
A blob detection UGen. It is based on the meta-balls algorithm by Julien Gachadoat (http://www.v3ga.net/processing/BlobDetection/).
Currently, we output four channels:
- 0 - numBlobs
- flushes for each window one element with the number of blobs detected
- 1 - bounds
- quadruplets of xMin
, xMax
, yMin
, yMax
- for each blob
- 2 - numVertices
- the number of vertices (contour coordinates) for each blob
- 3 - vertices
- tuples of x
and y
for the vertices of each blob
the image(s) to analyse
the width of the image
the height of the image
the threshold for blob detection between zero and one
size of "border" to put around input matrices. If greater than zero, a border of that size is created internally, filled with the threshold value
Inserts a buffer into the stream of up to size
frames.
Straight outta ScalaCollider.
Concatenates two signals.
A UGen that performs a constant Q spectral analysis, using an already FFT'ed input signal.
A UGen that performs a constant Q spectral analysis, using an already FFT'ed input signal.
For each input window, the output signal consists of numBands
filter output values.
These values are squared, since further processing might need to decimate them again
or take the logarithm. Otherwise the caller needs to add .sqrt
to get the actual filter outputs.
The default settings specify a range of nine octaves and numBands = 432
thus being 48 bands
per octave. At 44.1 kHz, the default minimum frequency would be 35.28 Hz, the maximum would be
18063.36 Hz.
the input signal which has already been windowed and FFT'ed using Real1FFT
in mode 0 or 2.
The windows should have been rotated prior to the FFT so that the time
signal starts in the middle of the window and then wraps around.
the fft size which corresponds with the window size of the input
the normalized minimum frequency (frequency in Hz, divided by the sampling rate). should be greater than zero and less than or equal to 0.5.
the normalized maximum frequency (frequency in Hz, divided by the sampling rate). should be greater than zero and less than or equal to 0.5.
the number of bands or kernels to apply, spreading them evenly (logarithmically) across the range from minimum to maximum frequency.
A scalar constant used as an input to a UGen.
A scalar information UGen that reports the control block size.
A UGen that convolves an input signal with a fixed or changing filter kernel.
A UGen that convolves an input signal with a fixed or changing filter kernel.
kernelUpdate
is read synchronous with in
, and while it is zero the most
recent kernel is reused (making it possible to use more efficient calculation
in the frequency domain). When kernelUpdate
becomes 1
, a new kernel
is polled.
For example, if you want to update the kernel every ten sample frames, then
kernelUpdate
could be given as Metro(10).tail
or Metro(10, 1)
. If the kernel is never updated,
then kernelUpdate
could be given as constant zero. If a new kernel is provided
for each input sample, the value could be given as constant one.
the signal to be filtered
the filter kernel. This is read in initially and when
kernelUpdate
is one.
the filter length in sample frames. One value is polled whenever a new kernel is required.
a gate value read synchronous with in
, specifying whether
a new kernel is to be read in (non-zero) after the next frame, or if the previous
kernel is to be reused (zero, default).
currently unused; leave at zero
Creates a constant infinite signal.
A UGen for type II discrete cosine transform.
A UGen for type II discrete cosine transform.
input signal
input signal window size
number of coefficients output
if zero (default), the zero'th coefficient is
_skipped_ in the output, if
non-zero, the zero'th coefficient is
included. In any case, the output
window size is numCoeffs
.
An envelope generator UGen similar to SuperCollider's DemandEnvGen.
An envelope generator UGen similar to SuperCollider's DemandEnvGen.
For each parameter of the envelope (levels, durations and shapes), values are polled every time a new segment starts. The UGen keeps running as long as level inputs are provided. If any of the other inputs terminate early, their last values will be used for successive segments (e.g. one can use a constant length or shape).
Note that as a consequence of having a "hot" levels
input,
the target level of the last segment may not be reached, as the UGen would
terminate one sample earlier. As a workaround one can duplicate the last
level value with a length of 1.
The difference to DemandEnvGen
is that this UGen does not duplicate functionality in the form
of levelScale
, levelBias
, timeScale
, and it does not provide reset
and gate
functionality. Durations are given as lengths in sample frames.
A debugging UGen that completes a promise with the input values it sees.
A debugging UGen that completes a promise with the input values it sees.
the signal to monitor
A debugging UGen that completes a promise with the input values it sees.
A debugging UGen that completes a promise with the input values it sees.
the signal to monitor
A UGen that simply consumes a signal and keeps running until
the in
signal ends.
A UGen that simply consumes a signal and keeps running until
the in
signal ends.
the signal to keep 'alive'.
A UGen that prints snapshots of its input to the console.
A UGen that prints snapshots of its input to the console. Note that arguments have different order than in ScalaCollider!
the input to be pulled. If this is a constant,
the UGen will close after polling it. This is to
prevent a dangling DebugPoll
whose trigger is
infinite (such as Impulse
). If you want to avoid
that, you should wrap the input in a DC
.
an identifying label to prepend to the printing.
A debugging UGen that installs a persistent no-op sink,
allowing the in
UGen to remain in the graph even if
it does not have a side-effect and it is not connected
to any other graph element.
A debugging UGen that installs a persistent no-op sink,
allowing the in
UGen to remain in the graph even if
it does not have a side-effect and it is not connected
to any other graph element.
the element to keep inside the graph
A UGen that passes through its input, and upon termination prints the number of frames seen.
A UGen that passes through its input, and upon termination prints the number of frames seen.
For convenience, import DebugThrough._
allows to write
val sin = SinOsc(freq) <| "my-sin"
the input to be pulled.
an identifying label to prepend to the printing.
A UGen that outputs triggers for local maxima within a sliding window.
A UGen that outputs triggers for local maxima within a sliding window. If multiple local maxima occur within the current window, only the one with the largest value will cause the trigger.
By definition, the first and last value in the input stream cannot qualify for local maxima.
the signal to analyze for local maxima
the sliding window size. Each two
emitted triggers are spaced apart at least
by size
frames.
A UGen that outputs the differences between adjacent input samples.
A UGen that outputs the differences between adjacent input samples.
The length of the signal is the length of the input. The first output will the the first input (internal x1 state is zero).
A UGen that outputs a single frame of 1
when the input
is finished.
XXX TODO --- not implemented yet.
XXX TODO --- not implemented yet. A UGen that cycles over a list of values.
sequence of values to be returned
the number of repetitions of the sequence
Inserts a buffer into the stream of num
blocks.
A single channel UGen of zero length.
A UGen that filters its input, retaining only those elements in the output sequence
for which the predicate gate
holds.
A UGen that filters its input, retaining only those elements in the output sequence
for which the predicate gate
holds.
You can think of it as Gate
but instead of
outputting zeroes when the gate is closed, no values are output at all. Consequently,
the length of the output stream will differ from the length of the input stream.
A graph element that flattens the channels from a nested multi-channel structure.
A graph element that flattens the channels from a nested multi-channel structure.
the element to flatten
Disk-buffered (large) Fourier transform.
Disk-buffered (large) Fourier transform.
Output windows will have a complex size of (size + padding).nextPowerOfTwo
input signal to transform. This must be complex (Re, Im interleaved)
the (complex) window size
the (complex) zero-padding size for each window
the direction is 1
for forward and -1
for backward transform.
other numbers will do funny things.
the amount of frames (chunk size) to buffer in memory. this should be a power of two.
A UGen that generates a signal that incrementally counts the frames of its input.
A UGen that generates a signal that incrementally counts the frames of its input.
The first value output will be 1
, and the last will correspond to the number
of frames seen, i.e. Length(in)
.
A UGen that passes through its input while the gate is open, and outputs zero while the gate is closed.
A repeated window generator UGen.
A repeated window generator UGen. It repeats the same window again and again (unless parameters are modulated). The parameters are demand-rate, polled once per window.
the window size
the identifier of the window shape, such as GenWindow.Hann
.
parameter used by some window shapes, such as GenWindow.Kaiser
A UGen that produces a geometric sequence of values.
A UGen that produces a geometric sequence of values.
If both start
and grow
are of integer type (Int
or Long
),
this produces an integer output, otherwise it produces a floating point output.
E.g. GeomSeq(start = 1, grow = 2)
will produce a series 1, 2, 4, 8, ...
.
the first output element
the multiplicative factor by which each successive element will grow
the number of elements to output
A UGen similar to GIMP's Slur image filter.
A UGen similar to GIMP's Slur image filter. Instead of a hard-coded kernel,
the probability table must be provided as a separate input.
The kernel width and height should be odd, so that the kernel is considered to be
symmetric around each input image's pixel. If they are odd, the centre corresponds to
integer divisions kernelWidth/2
and kernelHeight/2
.
image input
image width
image height
normalized and integrated probability table.
Like the image, the cells are read horizontally first,
every widthKernel
cell begins a new cell. The cell probabilities
must have been integrated from first to last, and must be normalized
so that the last cell value equals one. A new kernel signal is read
once per input image. (If the signal ends, the previous kernel will
be used again).
width of the kernel signal. Read once per input image.
height of the kernel signal. Read once per input image.
number of recursive application of the displacement per image. Read once per input image.
if non-zero, wraps pixels around the image bounds, otherwise clips.
A UGen that orthogonalizes an input matrix using the stabilized Gram-Schmidt algorithm.
A UGen that orthogonalizes an input matrix using the stabilized Gram-Schmidt algorithm. It processes the row vectors per matrix by making them orthogonal to one another, optionally also orthonormal.
the input matrices
the number of rows of the input
the number of columns of the input
A second order high-pass filter UGen.
A second order high-pass filter UGen. It implements the same type of filter as the SuperCollider equivalent.
the signal to filter
the normalized cut-off frequency (frequency in Hertz divided by sampling rate)
A UGen that produces a continuous hash value, useful for comparisons and debugging applications.
A UGen that produces a continuous hash value, useful for comparisons and debugging applications. The hash is produced using the 64-bit Murmur 2 algorithm, however the continuous output is given without "finalising" the hash, and it is not initialized with the input's length (as it is unknown at that stage).
Not yet implemented: Only after the input terminates, one additional sample of
finalised hash is given (you can use .last
to only retain the final hash).
the signal to hash.
Beginning of a conditional block.
Beginning of a conditional block.
the condition, which is treated as a boolean with zero being treated as false
and
non-zero as true
. Note that multi-channel expansion does not apply here, because
the branches may have side-effects which are not supposed to be repeated across
channels. Instead, if cond
expands to multiple channels, they are combined using
logical |
(OR).
A side effecting conditional block.
Reads a sequence of images, outputting them directly one after the other, determining
their file names by formatting a template
with a numeric argument given through indices
.
Reads a sequence of images, outputting them directly one after the other, determining
their file names by formatting a template
with a numeric argument given through indices
.
a file which contains a single placeholder for java.util.Formatter
syntax,
such as %d
to insert an integer number. Alternatively, if the file name does
not contain a %
character but a digit or a sequence of digits, those digits
will be replaced by %d
to produce a valid template.
Therefore, if the template is foo-123.jpg
and the indices contain 4
and 5
,
then the UGen will read the images foo-4
and foo-5
(the placeholder 123
is
irrelevant).
Writes a sequence of images, taken their data one by one from the input in
, and writing them
to individual files, determining
their file names by formatting a template
with a numeric argument given through indices
.
Writes a sequence of images, taken their data one by one from the input in
, and writing them
to individual files, determining
their file names by formatting a template
with a numeric argument given through indices
.
a file which contains a single placeholder for java.util.Formatter
syntax,
such as %d
to insert an integer number. Alternatively, if the file name does
not contain a %
character but a digit or a sequence of digits, those digits
will be replaced by %d
to produce a valid template.
Therefore, if the template is foo-123.jpg
and the indices contain 4
and 5
,
then the UGen will write the images foo-4
and foo-5
(the placeholder 123
is
irrelevant).
Impulse (repeated dirac) generator.
Impulse (repeated dirac) generator. For a single impulse that is never repeated, use zero.
normalized frequency (reciprocal of frame period)
phase offset in cycles (0 to 1).
Aliased sawtooth oscillator.
Aliased sawtooth oscillator.
Note that the frequency is not in Hertz but
the normalized frequency
as we do not maintained one global sample rate.
For a frequency in Hertz, freqN
would be
that frequency divided by the assumed sample rate.
Note: Unlike SuperCollider where LFSaw
starts at
zero for a zero phase, this oscillator begins at -1
.
To let it start at zero, use a phase
of 0.5
normalized frequency (f/sr). Note: negative values are currently broken.
phase offset from 0 to 1. Note: negative values are currently broken.
A second order low-pass filter UGen.
A second order low-pass filter UGen. It implements the same type of filter as the SuperCollider equivalent.
the signal to filter
the normalized cut-off frequency (frequency in Hertz divided by sampling rate)
A sample-and-hold UGen.
A sample-and-hold UGen. It passes through its input while the gate is open, and outputs the last held value while the gate is closed.
Reports the length of the input as a single value one the input has terminated.
A UGen that limits the amplitude of its input signal.
A UGen that limits the amplitude of its input signal. Modelled after FScape 1.0 limiter module. N.B.: The UGen outputs a gain control signal, so the input must be multiplied by this signal to obtain the actually limited signal.
input signal
the attack duration in frames, as -60 dB point
the release duration in frames, as -60 dB point
the maximum allowed amplitude
A line segment generating UGen.
A line segment generating UGen. The UGen terminates when the segment has reached the end.
A line can be used to count integers (in the lower
ranges, where floating point noise is not yet relevant),
e.g. Line(a, b, b - a + 1)
counts from a
to
b
(inclusive).
starting value
ending value
length of the segment in sample frames
A loudness measurement UGen, using Zwicker bands.
A loudness measurement UGen, using Zwicker bands. One value in Phon per window is output.
the signal to analyse
sample rate of the input signal
the window size for which to calculate values
the reference of 0 dBFS in decibels
whether to assume diffuse field (1
) or free field (0
)
A UGen that extends or truncates its first argument to match the length of the second argument.
A UGen that extends or truncates its first argument to match
the length of the second argument. If in
is shorter than
ref
, it will be padded with the zero element of its number type.
If in
is longer, the trailing elements will be dropped.
Note: mode
is not yet implemented.
A UGen that stitches together sequences of sub-matrices to a larger matrix.
A UGen that stitches together sequences of sub-matrices to a larger matrix.
The matrix dimensions and offsets are updated per "matrix chunk" which is are
columnsOuter/columnNum
input matrices of size rowsInner * columnsInner
.
In other words, the UGen has no
intrinsic knowledge of the height of the output matrix.
For example, if the input matrices are of size (5, 6) (rows, columns), and we want to assemble the
cells (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), that is copped matrices of size (2, 3)
beginning at the second row and second column, and we want the outer matrix to have 9 columns,
so that each three input matrices appear horizontally next to each other, the settings would be
rowsInner = 5
, columnsInner = 6
, columnsOuter = 9
, rowOff = 1
, columnOff = 1
,
rowNum = 2
, columnNum = 3
.
For more complex behaviour, such as skipping particular rows or columns, ScanImage
can be used.
the sequence of smaller matrices
height of the input matrices
width of input matrices
width of the output matrix. Must be an integer multiple of columnNum
.
offset in rows within the input matrices, where copying to the output matrix begins
offset in columns within the input matrices, where copying to the output matrix begins
number of rows to copy from each input matrix
number of columns to copy from each input matrix.
A UGen that maps short-time Fourier transformed spectra to the mel scale.
A UGen that maps short-time Fourier transformed spectra to the mel scale. To obtain
the MFCC, one has to take the log of the output of this UGen and decimate it with a DCT
.
Example:
def mfcc(in: GE) = { val fsz = 1024 val lap = Sliding(in, fsz, fsz/2) * GenWindow(fsz, GenWindow.Hann) val fft = Real1FFT(lap, fsz, mode = 1) val mag = fft.complex.mag.max(-80) val mel = MelFilter(mag, fsz/2, bands = 42) DCT_II(mel.log, 42, 13, zero = 0) }
magnitudes of spectra, as output by Real1FFT(..., mode = 1).complex.abs
bands in input spectrum (assumed to be fft-size / 2
).
lowest band corresponds to DC and highest to (size - 1)/size * sampleRate/2
.
lower frequency to sample. Will be clipped between zero (inclusive) and Nyquist (exclusive).
upper frequency to sample. Will be clipped between minFreq
(inclusive) and Nyquist (exclusive).
number of filter bands output
Metronome (repeated dirac) generator.
Metronome (repeated dirac) generator.
For a single impulse that is never repeated,
use a period of zero. Unlike Impulse
which
uses a frequency and generates fractional phases
prone to floating point noise, this is UGen is
useful for exact sample frame spacing. Unlike Impulse
,
the phase cannot be modulated.
number of frames between impulses. Zero is short-hand
for Long.MaxValue
phase offset in frames. Initialization time only!
A UGen that normalizes each input window according to a mode.
A UGen that normalizes each input window according to a mode. It can be used for normalizing the value range or removing DC offset. If the last window is not entirely filled, the output will pad that window always to zero (no matter the normalization mode!)
the input signal
the input's window size
0
for normalizing the amplitude to 1,
1
for fitting into the range of 0 to 1,
2
for fitting into the range of -1 to 1,
3
for removing DC (creating a mean of zero).
Overlapping window summation with offset (fuzziness) that can be modulated.
A one pole (IIR) filter UGen.
A one pole (IIR) filter UGen. Implements the formula :
out(i) = ((1 - abs(coef)) * in(i)) + (coef * out(i-1))
input signal to be processed
feedback coefficient. Should be between -1 and +1
A one pole (IIR) filter UGen applied to windowed data.
A one pole (IIR) filter UGen applied to windowed data. Implements the formula :
out(i) = ((1 - abs(coef)) * in(i)) + (coef * out(i-1))
This filter runs in parallel for all frames of the window (or matrix).
That is, in the above formula out
is replaced by each window element, and
i
is the window count.
input signal to be processed
window size
feedback coefficient. Should be between -1 and +1
A UGen that performs overlap-and-add operation on a stream of input windows.
A UGen that performs overlap-and-add operation on a stream of input windows.
The size
and step
parameters are demand-rate, polled once per (input) window.
the non-overlapped input
the window size in the input
the step between successive windows in the output.
when smaller than size
, the overlapping portions are summed together.
A UGen that calculates the Pearson product-moment correlation coefficient of two input matrices.
A UGen that calculates the Pearson product-moment correlation coefficient of two input matrices.
first matrix
second matrix
matrix or window size
A UGen that writes the pixels of an image using an x
and y
input signal.
A UGen that writes the pixels of an image using an x
and y
input signal.
It uses either a sinc-based band-limited resampling algorithm, or
bicubic interpolation, depending on the zeroCrossings
parameter.
All window defining parameters (width
, height
)
are polled once per matrix. All writing and filter parameters are polled one per
output pixel.
the source signal's amplitude or "pen color"
the alpha component of the source signal (0.0 transparent to 1.0 opaque).
the "background" image to draw on. A DC(0.0)
can be used, for example,
to have a "black" background.
the width (number of columns) of the input and output matrix
the height (number of rows) of the input and output matrix
horizontal position of the dynamic pen signal
vertical position of the dynamic pen signal
a trigger that causes the UGen to emit the current image and begin a new one.
An image of size width * height
will be output, and new background data will
be read from in
.
quasi-Porter-Duff rule id for composition between background (in
)
and pen foreground. It is assumed that
Ar = Ad = 1
,
and instead of addition we use a custom binary operation op
.
Where the constrain leads to otherwise identical rules, we flip the
operand order (e.g. SrcOver
versus SrcAtop
).
BinaryOp.Op
identifier for the operand in the application of the
Porter-Duff composition (+
in the standard definition).
if non-zero, wraps coordinates around the input images boundaries.
TODO: currently wrap = 0
is broken if using sinc interpolation!
the FIR anti-aliasing roll-off width. Between zero and one.
the FIR windowing function's parameter
the number of zero-crossings in the truncated and windowed sinc FIR. If zero (default), algorithm uses bicubic interpolation instead.
A graph element that implements Boersma's auto-correlation based pitch tracking algorithm.
A graph element that implements Boersma's auto-correlation based pitch tracking algorithm.
cf. Paul Boersma, ACCURATE SHORT-TERM ANALYSIS OF THE FUNDAMENTAL FREQUENCY AND THE HARMONICS-TO-NOISE RATIO OF A SAMPLED SOUND, Institute of Phonetic Sciences, University of Amsterdam, Proceedings 17 (1993), 97-110
Note that this is currently implemented as a macro, thus being quite slow.
A future version might implement it directly as a UGen.
Currently stepSize
is automatically given, and windowing is fixed to Hann.
A UGen that takes concurrent pitch tracker paths, and conditions them for the Viterbi algorithm.
A UGen that takes concurrent pitch tracker paths, and conditions them for the
Viterbi algorithm. The inputs are typically taken from AutoCorrelationPitches
,
and from this a suitable add
signal is produced to be used in the Viterbi
UGen.
The output are matrices of size (numIn + 1).squared
.
Warning: This is still not thoroughly tested.
pitches given as sample periods, such as returned by
AutoCorrelationPitches
.
strengths corresponding to the lags
, such as returned by
AutoCorrelationPitches
.
number of paths / candidates. to this the unvoiced candidate is added
the peak amplitude of the underlying input signal, one sample per pitch frame, used for the unvoiced candidate.
the maximum lag time, corresponding to the minimum pitch
threshold for determining whether window is voiced or unvoiced.
threshold for determining whether window is background or foreground.
weighting factor for low versus high frequency preference.
costs for moving pitches up and down.
to match the parameters in Praat, you should multiply
the "literature" value by 0.01 * sampleRate / stepSize
(typically in the order of 0.25)
cost for transitioning between voiced and unvoiced segments.
to match the parameters in Praat,
the "literature" value by 0.01 * sampleRate / stepSize
(typically in the order of 0.25)
see StrongestLocalMaxima
see Viterbi
Debugging utility that plots 1D "windows" of the input data.
A UGen that prints snapshots of its input to the console.
A UGen that prints snapshots of its input to the console. Note that arguments have different order than in ScalaCollider!
the input to be pulled. If this is a constant,
the UGen will close after polling it. This is to
prevent a dangling Poll
whose trigger is
infinite (such as Impulse
). If you want to avoid
that, you should wrap the input in a DC
.
trigger that causes the UGen to print a snapshot of the input.
an identifying label to prepend to the printing.
A sorting UGen that can be thought of as a bounded priority queue.
A sorting UGen that can be thought of as a bounded priority queue.
It keeps all data in memory but limits the size to the
top size
items. By its nature, the UGen only starts outputting
values once the input signal (keys
) has finished.
the sorting keys; higher values mean higher priority
the values corresponding with the keys and eventually
output by the UGen. It is well possible to use the
same signal both for keys
and values
.
the maximum size of the priority queue.
A UGen that contributes to the progress monitoring of a graph.
A UGen that contributes to the progress monitoring of a graph. It is possible to instantiate multiple instances of this UGen, in which cases their individual progress reports will simply be added up (and clipped to the range from zero to one).
progress fraction from zero to one
trigger that causes the UGen to submit a snapshot of the progress to the control instance.
the label can be used to distinguish the contributions of different progress UGens
A variant of progress UGen for the common case where one wants to count the incoming frames of a signal.
A variant of progress UGen for the common case where one wants to count the incoming frames of a signal.
It is possible to instantiate multiple instances of this UGen, in which cases their individual progress reports will simply be added up (and clipped to the range from zero to one).
The progress update is automatically triggered, using a combination where both the progress fraction (0.2%) and elapsed time (100ms) must have increased.
signal whose length to monitor
the expected length of the input signal
the label can be used to distinguish the contributions of different progress UGens
Forward short-time Fourier transform UGen for a real-valued input signal.
Forward short-time Fourier transform UGen for a real-valued input signal.
The FFT size is equal to size + padding
. The output is a succession
of complex half-spectra, i.e. from DC to Nyquist. Depending on mode
,
the output window size is either size + padding
or size + padding + 2
.
the real signal to transform. If overlapping windows
are desired, a Sliding
should already have been applied
to this signal, as well as multiplication with a window function.
the input window size
amount of zero padding for each input window.
packing mode.
0
(default) is standard "packed" mode,
whereby the real part of the bin at Nyquist is stored in the imaginary
slot of the DC. This mode allows perfect reconstruction with a
Real1IFFT
using the same mode.
1
is "unpacked" mode,
whereby the output windows are made two samples longer,
so that the Nyquist bin is included in the very end. By
definition, the imaginary parts of DC and Nyquist are zero.
This mode allows perfect reconstruction with a
Real1IFFT
using the same mode.
2
is "discarded" mode,
whereby the Nyquist bin is omitted. While it doesn't allow
a perfect reconstruction, this mode is useful for analysis,
because the output window size is equal to the fft-size,
and the imaginary part of DC is correctly zero'ed.
Forward short-time Fourier transform UGen for a real-valued input signal.
Forward short-time Fourier transform UGen for a real-valued input signal.
The FFT size is equal to rows * columns
. The output is a succession
of complex half-spectra, i.e. from DC to Nyquist.
XXX TODO: Depending on mode
,
the output window size is either size + padding
or size + padding + 2
.
the real signal to transform. If overlapping windows
are desired, a Sliding
should already have been applied
to this signal, as well as multiplication with a window function.
the input matrix number of rows
the input matrix number of columns
packing mode.
0
(default) is standard "packed" mode,
whereby the real part of the bin at Nyquist is stored in the imaginary
slot of the DC. This mode allows perfect reconstruction with a
Real2IFFT
using the same mode.
1
is "unpacked" mode,
whereby the output windows are made two samples longer,
so that the Nyquist bin is included in the very end. By
definition, the imaginary parts of DC and Nyquist are zero.
This mode allows perfect reconstruction with a
Real2IFFT
using the same mode.
2
is "discarded" mode,
whereby the Nyquist bin is omitted. While it doesn't allow
a perfect reconstruction, this mode is useful for analysis,
because the output window size is equal to the fft-size,
and the imaginary part of DC is correctly zero'ed.
A UGen that repeats the contents of input windows a number of times.
A UGen that repeats the contents of input windows a number of times.
the input signal to group into windows of size size
and
repeat num
times. If the input ends before a full window
is filled, the last window is padded with zeroes to obtain
an input window if size size
the window size. one value is polled per iteration
(outputting num
windows of size size
). the minimum
size
is one (it will be clipped to this).
the number of repetitions of the input windows. one value is polled per iteration
(outputting num
windows of size size
). the minimum
num
is one (it will be clipped to this).
A band-limited resampling UGen.
A band-limited resampling UGen.
It uses an internal table for the anti-aliasing filter.
Table resolution is currently fixed at 4096 filter samples per zero crossing and
linear interpolation in the FIR table, but the total filter length can be specified
through the zeroCrossings
parameter. Note: If filter parameters are changed, the
table must be recalculated which is very expensive. However, factor
modulation
is efficient.
Note: Unlike most other UGens, all parameters but in
are read at "output rate".
That is particular important for factor
modulation. For each frame output, one
frame from factor
is consumed.
the signal to resample
the resampling factor, where values greater than one mean the signal is stretched (sampling-rate increases or pitch lowers) and values less than one mean the signal is condensed (sampling-rate decreases or pitch rises)
the minimum expected resampling factor, which controls
the amount of buffering needed for the input signal. This is used at
initialization time only. The default
value of zero makes the UGen settles on the first factor
value encountered.
It is possible to use a value actually higher than the lowest provided
factor
, in order to limit the buffer usage. In that case, the FIR anti-aliasing
filter will be truncated.
the FIR anti-aliasing roll-off width
the FIR windowing function's parameter
the number of zero-crossings in the truncated and windowed sinc FIR.
A band-limited resampling UGen for images/matrices.
A band-limited resampling UGen for images/matrices.
This works like Resample
but processes each window cell
across time. Thus is is not _resampling each window by itself_,
but each "pixel" or matrix cell in a window across successive windows.
the signal to resample
the window size. Currently this is only read once upon initialization.
the resampling factor, where values greater than one mean the signal is stretched (sampling-rate increases or pitch lowers) and values less than one mean the signal is condensed (sampling-rate decreases or pitch rises)
the minimum expected resampling factor, which controls
the amount of buffering needed for the input signal. This is used at
initialization time only. The default
value of zero makes the UGen settles on the first factor
value encountered.
It is possible to use a value actually higher than the lowest provided
factor
, in order to limit the buffer usage. In that case, the FIR anti-aliasing
filter will be truncated.
the FIR anti-aliasing roll-off width
the FIR windowing function's parameter
the number of zero-crossings in the truncated and windowed sinc FIR.
A UGen that resizes the windowed input signal by trimming each
windows boundaries (if start
is greater than zero
or stop
is less than zero) or padding the boundaries
with zeroes (if start
is less than zero or stop
is
greater than zero).
A UGen that resizes the windowed input signal by trimming each
windows boundaries (if start
is greater than zero
or stop
is less than zero) or padding the boundaries
with zeroes (if start
is less than zero or stop
is
greater than zero). The output window size is thus
size - start + stop
.
the signal to window and resize
the input window size
the delta window size at the output window's beginning
the delta window size at the output window's ending
A UGen that can apply horizontal and vertical flip and 90-degree step rotations to a matrix.
A UGen that can apply horizontal and vertical flip and 90-degree step rotations to a matrix.
Unless mode is 90-degree rotation (4 or 5) and the matrix is not square, this needs one internal matrix buffer, otherwise two internal matrix buffers are needed.
the matrix / matrices to rotate
the number of rows in the input
the number of columns in the input
0: pass, 1: flip horizontally, 2: flip vertically, 3: rotate 180 degrees, 4: rotate clockwise, 8: rotate anti-clockwise. See the companion object for constants. If you combine flipping and rotation, flipping is performed first, so a mode of 5 means flip horizontally, followed by rotate clockwise.
A UGen that rotates the contents of a window, wrapping around its boundaries.
A UGen that rotates the contents of a window, wrapping around its boundaries. For example, it can be used to align the phases prior to FFT so that the sample that was formerly in the centre of the window moves to the beginning of the window.
the signal to window and resize
the input window size
the rotation amount in sample frames. Positive values "move" the contents
to the right, negative values "move" the contents to the left. The amount
is taken modulus size
.
A UGen that tracks the maximum value seen so far, until a trigger resets it.
A UGen that tracks the maximum value seen so far, until a trigger resets it.
Note: This is different from SuperCollider's RunningMax
UGen which outputs
the maximum of a sliding window instead of waiting for a reset trigger.
To track a sliding maximum, you can use PriorityQueue
.
the signal to track
a trigger occurs when transitioning from non-positive to positive. At this point (an initially) the internal state is set to negative infinity.
A UGen that tracks the minimum value seen so far, until a trigger resets it.
A UGen that tracks the minimum value seen so far, until a trigger resets it.
Note: This is different from SuperCollider's RunningMin
UGen which outputs
the maximum of a sliding window instead of waiting for a reset trigger.
To track a sliding minimum, you can use PriorityQueue
.
the signal to track
a trigger occurs when transitioning from non-positive to positive. At this point (an initially) the internal state is set to positive infinity.
A UGen that integrates the values seen so far, until a trigger resets it.
A UGen that integrates the values seen so far, until a trigger resets it.
Note: This is different from SuperCollider's RunningSum
UGen which outputs
the sum of a sliding window instead of waiting for a reset trigger.
To track a sliding sum, you can subtract a delayed version of RunningSum
from
a non-delayed RunningSum
.
the signal to track
a trigger occurs when transitioning from non-positive to positive. At this point (an initially) the internal state is set to zero.
A UGen that like RunningMax
calculates the maximum observed value of the
running input.
A UGen that like RunningMax
calculates the maximum observed value of the
running input. However, it operates on entire windows, i.e. it outputs
windows that contain the maximum elements of all the past windows observed.
the windowed signal to monitor
the window size. This should normally be a constant. If modulated, the internal buffer will be re-allocated, essentially causing a reset trigger.
a trigger signal that clears the internal state. When a trigger is observed, the _currently processed_ window is reset altogether until its end, beginning accumulation again from the successive window. Normally one will thus want to emit a trigger in sync with the _start_ of each window. Emitting multiple triggers per window does not have any effect different from emitting the first trigger in each window.
A UGen that like RunningMin
calculates the minimum observed value of the
running input.
A UGen that like RunningMin
calculates the minimum observed value of the
running input. However, it operates on entire windows, i.e. it outputs
windows that contain the minimum elements of all the past windows observed.
the windowed signal to monitor
the window size. This should normally be a constant. If modulated, the internal buffer will be re-allocated, essentially causing a reset trigger.
a trigger signal that clears the internal state. When a trigger is observed, the _currently processed_ window is reset altogether until its end, beginning accumulation again from the successive window. Normally one will thus want to emit a trigger in sync with the _start_ of each window. Emitting multiple triggers per window does not have any effect different from emitting the first trigger in each window.
A UGen that like RunningSum
calculates the sum of the
running input.
A UGen that like RunningSum
calculates the sum of the
running input. However, it operates on entire windows, i.e. it outputs
windows that contain the sum elements of all the past windows observed.
the windowed signal to monitor
the window size. This should normally be a constant. If modulated, the internal buffer will be re-allocated, essentially causing a reset trigger.
a trigger signal that clears the internal state. When a trigger is observed, the _currently processed_ window is reset altogether until its end, beginning accumulation again from the successive window. Normally one will thus want to emit a trigger in sync with the _start_ of each window. Emitting multiple triggers per window does not have any effect different from emitting the first trigger in each window.
A UGen that scans the pixels of an image using an x
and y
input signal.
A UGen that scans the pixels of an image using an x
and y
input signal.
It uses either a sinc-based band-limited resampling algorithm, or
bicubic interpolation, depending on the zeroCrossings
parameter.
All window defining parameters (width
, height
)
are polled once per matrix. All scanning and filter parameters are polled one per
output pixel.
the image to scan
the width (number of columns) of the input matrix
the height (number of rows) of the input matrix
horizontal position of the dynamic scanning signal
vertical position of the dynamic scanning signal
a trigger that causes the UGen to read in a new image from in
.
if non-zero, wraps coordinates around the input images boundaries.
TODO: currently wrap = 0
is broken if using sinc interpolation!
the FIR anti-aliasing roll-off width. Between zero and one.
the FIR windowing function's parameter
the number of zero-crossings in the truncated and windowed sinc FIR. If zero (default), algorithm uses bicubic interpolation instead.
A phasor UGen that takes new frequency values at the beginning of each cycle.
A phasor UGen that takes new frequency values at the beginning of each cycle.
It can be used to implement the 'segmod' program of Döbereiner and Lorenz.
In contrast, LFSaw
continuously reads frequency values, it
output values go from zero to one, and the phase argument is only used
internally (the output signal always starts at zero).
To turn this, for example, into a sine oscillator, you can use
(SegModPhasor(...) * 2 * math.Pi).sin
.
Warning: passing in zero frequencies will halt the process. XXX TODO
normalized frequency (f/sr). One value per output cycle is read.
Also note that the UGen terminates when the freqN
signal ends.
Thus, to use a constant frequency, wrap it in a DC
or DC(...).take
.
phase offset in radians. The phase offset is only used internally to
determine when to change the frequency. For example, with a phase of
0.25
, when the output phase reaches 0.25, the next frequency value
is read. With the default phase of 0.0, a frequency value is read
after one complete cycle (output reaches 1.0).
A flip-flop UGen with two inputs, one (set) triggering an output of 1, the other (reset) triggering an output of 0.
A flip-flop UGen with two inputs, one (set) triggering an output of 1, the other (reset) triggering an output of 0. Subsequent triggers happening within the same input slot have no effect. If both inputs receive a trigger at the same time, the reset input takes precedence.
Sine oscillator.
Sine oscillator.
Note that the frequency is not in Hertz but
the normalized frequency
as we do not maintained one global sample rate.
For a frequency in Hertz, freqN
would be
that frequency divided by the assumed sample rate.
normalized frequency (f/sr).
phase offset in radians
A UGen that assembles slices of an input signal in random access fashion.
A UGen that assembles slices of an input signal in random access fashion. It does so by buffering the input to disk.
the signal to re-arrange.
successive frame start (inclusive) and
stop (exclusive) frame
positions determining the spans that
are output by the UGen. This parameter
is read on demand. First, the first two
values are read, specifying the first span.
Only after this span has been output,
the next two values from spans
are
read, and so on. Values are clipped to
zero (inclusive) and the length of the
input signal (exclusive). If a
start position is greater than a stop
position, the span is output in reversed order.
A UGen that produces a sliding window over its input.
A UGen that produces a sliding window over its input.
the input to be repacked into windows
the window size
the stepping factor in the input, between windows
A UGen that reports a percentile of a sliding window across its input.
A UGen that reports a percentile of a sliding window across its input.
The UGen starts outputting values immediately, even if the median window len
is not yet reached. This is because len
can be modulated.
If one wants to discard the initial values, use a drop
.
Note that for an even median length and no interpolation, the reported median
may be either the value at index len/2
or len/2 + 1
in the sorted window.
All arguments are polled at the same rate. Changing the frac
value
may cause an internal table rebuild and can thus be expensive.
the input to analyze
the length of the sliding median window
the percentile from zero to one. The default of 0.5 produces the median.
if zero (default), uses nearest-rank, otherwise uses linear interpolation. Note: currently not implemented, must be zero
A UGen that reports a percentile of a sliding window across every cell of a window'ed input (such as an image).
A UGen that reports a percentile of a sliding window across every cell of a window'ed input (such as an image).
The UGen starts outputting values immediately, even if the medianLen
is not yet reached. This is because medianLen
can be modulated (per input window).
If one wants to discard the initial values, use a drop
, for example
for medianLen/2 * winSize
frames.
Note that for an even median length and no interpolation, the reported median
may be either the value at index medianLen/2
or medianLen/2 + 1
in the sorted window.
All arguments but in
are polled per input window. Changing the frac
value
may cause an internal table rebuild and can thus be expensive.
the window'ed input to analyze
the size of the input windows
the length of the sliding median window (the filter window applied to every cell of the input window)
the percentile from zero to one. The default of 0.5 produces the median.
if zero (default), uses nearest-rank, otherwise uses linear interpolation. Note: currently not implemented, must be zero
A UGen that sorts the input data window by window.
A UGen that sorts the input data window by window.
the sorting keys; output will be in ascending order
the values corresponding with the keys and eventually
output by the UGen. It is well possible to use the
same signal both for keys
and values
.
the window size.
A peak detection UGen, useful for implementing the auto-correlation based pitch detection method of Paul Boersma (1993).
A peak detection UGen, useful for implementing the auto-correlation based pitch detection
method of Paul Boersma (1993).
Taking an already calculated auto-correlation of size size
, the UGen looks
for local maxima within a given range.
The UGen has two outputs. The first output gives the
lag times or periods of the n
strongest peaks per window (to obtain a frequency, divide the sampling
rate by these lag times). The second output gives the intensities of these n
candidates. If there
are less than n
candidates, the empty slots are output as zeroes.
the auto-correlation windows
the size of the auto-correlation windows. must be at least 2.
the minimum lag time in sample frames, corresponding to the maximum frequency accepted
the maximum lag time in sample frames, corresponding to the minimum frequency accepted
the "voicing" threshold for considered for local maxima within minLag
maxLag
.
a factor for favouring higher frequencies. use zero to turn off this feature.
number of candidate periods output. This is clipped to be at least 1. see PitchesToViterbi see Viterbi
A UGen that outputs the number of sample frames passed since last triggered.
A UGen that outputs the number of sample frames passed since last triggered. If no trigger is used, it simply outputs a linearly rising ramp.
trigger signal to reset the counter. Note that the UGen
shuts down when trig
finishes, so to use a constant like 0
,
it has to be wrapped in a DC
, for example.
A UGen that transposes 2-dimensional matrices.
A UGen that transposes 2-dimensional matrices.
This is a 2-dimensional windowed process, where
each window has length rows * columns
. Input
is assumed to be "left-to-right, top-to-bottom",
so the first samples constitute the first row,
the next samples constitute the second row, etc.
Note: This is an in-place process which uses
less memory but possibly more time. A faster variant
would be to use RotateMirrorMatrix
The output matrix is transposed (rows and columns
exchanged). So an input of (a, b, c, d, e, f)
with rows = 2
and columns = 3
is interpreted
as ((a, b, c), (d, e, f))
, transposed as
((a, d), (b, e), (c, f))
and output flat as
(a, d, b, e, c, f)
.
To rotate an image ninety
degrees clockwise, you would have rows = height
and columns = width
.
the input matrices
the number of rows of the _input_
the number of columns of the _input_
A UGenOutProxy refers to a particular output of a multi-channel UGen.
A UGenOutProxy refers to a particular output of a multi-channel UGen. A sequence of these form the representation of a multi-channel-expanded UGen.
Loops the given values.
Loops the given values.
Loops the given values.
A UGen performing a generalized Viterbi algorithm.
A UGen performing a generalized Viterbi algorithm. The Viterbi algorithm
tries to find the best path among sequences of states, by evaluating transition
probabilities. It runs over a predefined number of frames, accumulating
data of different states. It maximizes the likelihood of the terminal state,
and then backtracks to reconstruct the likely path (sequence of states).
The output is the sequence of state indices (from zero inclusive to
numStates
exclusive).
Note: This UGen must run until numFrames
or the inputs are exhausted,
before it can begin outputting values.
This implementation is generalized in the sense that instead of the canonical
matrices "sequences of observations", "initial probabilities", "transition matrix",
and "emission matrix", it takes two large matrices mul
and add
that contain
the equivalent information. These two matrices allow the UGen to operate in two
different modes:
- multiplicative (as in the Wikipedia article) by damping the probabilities over time - accumulative (as used in Praat for pitch tracking) by adding up the weights (if you have "costs", feed in their negative values).
Basically the internal delta matrix is created by the update function
delta = (delta_prev * mul) + add
(with the corresponding matrix indices).
The initial delta state is zero. Therefore, in order to provide the initial state,
you obtain an initial vector v
by providing an add
matrix of numStates x numStates
cells, which is zero except for the first column filled by v
(alternatively, each row
filled with the next value of v
, or a diagonal matrix of v
; if v
can take negative
value, make sure to fill the initial numStates x numStates
completely by
duplicating v
).
For the classical data, set add
just to the initial matrix as explained above
(multiplying emitted first observations with initial probabilities),
and then use exclusively mul
by passing in emitted observations multiplied by their
transition probabilities:
mul[t][i][j] = transitionProb[i][j] * emissionProb[observation[t]][i]
See https://en.wikipedia.org/wiki/Viterbi_algorithm
the generalized multiplicative matrix (combining transition probabilities, emission probabilities and observations). If only accumulation is used, set this to 1.0.
the generalized accumulative matrix (combining transition probabilities, emission probabilities and observations). If only multiplication is used, set this to provide the initial state (see above), followed either by zeroes or by terminating the signal.
the number of different states, as reflected by the inner dimensions of matrices
mul
and add
.
the number of observations. If -1
, the UGen runs until the input
is exhausted. This happens when both mul
and add
end.
see StrongestLocalMaxima
see PitchesToViterbi
Nominal signal range is -mul
to +mul
(exclusive).
A UGen that extracts for each input window the element at a given index.
A UGen that extracts for each input window the element at a given index.
the window'ed signal to index
the window size.
the zero-based index into each window. One value per window is polled.
wrap mode. 0
clips indices, 1
wraps them around, 2
folds them, 3
outputs
zeroes when index is out of bounds.
A UGen that determines for each input window the first index where a predicate holds.
A UGen that determines for each input window the first index where a predicate holds.
It outputs one integer value per window; if the predicate does not hold across the entire
window, the index will be -1
.
a predicate to detect the index
the window size.
A UGen that determines for each input window the index of the maximum element.
A UGen that determines for each input window the index of the maximum element. It outputs one integer value per window; if multiple elements have the same value, the index of the first element is reported (notably zero if the window contains only identical elements).
the input signal.
the window size.
Binary operator assuming operands are complex signals (real and imaginary interleaved).
Binary operator assuming operands are complex signals (real and imaginary interleaved). Outputs another complex stream even if the operator yields a purely real-valued result.
XXX TODO - need more ops such as conjugate, polar-to-cartesian, ...
Unary operator assuming stream is complex signal (real and imaginary interleaved).
Unary operator assuming stream is complex signal (real and imaginary interleaved).
Outputs another complex stream even if the operator yields a purely real-valued result
(ex. abs
).
XXX TODO - need more ops such as conjugate, polar-to-cartesian, ...
Loops the given values.
Automatic range control UGen. It traces the range of a windowed input signal.
signal to adjust
window size of input
desired lower margin of output
desired upper margin of output
lag or feedback coefficient