TITLE:: FluidTransientSlice
SUMMARY:: Transient-Based Real-Time Audio Slicer
CATEGORIES:: Libraries>FluidDecomposition
RELATED:: Guides/FluCoMa, Guides/FluidDecomposition

DESCRIPTION::
This class implements a real-time transient-based slice extractor relying on the same algorithm than Classes/FluidBufTransients using clicks/transients/derivation/anomaly in the signal to estimate the slicing points. It is part of the LINK:: Guides/FluidDecomposition:: of LINK:: Guides/FluCoMa::. For more explanations, learning material, and discussions on its musicianly uses, visit http://www.flucoma.org/

The process will return an audio steam with sample-long impulses at estimated starting points of the different slices.

CLASSMETHODS::

METHOD:: ar
	The audio rate version of the object.

ARGUMENT:: in
	The audio to be processed.

ARGUMENT:: order
	The order in samples of the impulse response filter used to model the estimated continuous signal. It is how many previous samples are used by the algorithm to predict the next one as reference for the model. The higher the order, the more accurate is its spectral definition, not unlike fft, improving low frequency resolution, but it differs in that it is not connected to its temporal resolution.

ARGUMENT:: blockSize
	The size in samples of frame on which it the algorithm is operating. High values are more cpu intensive, and also determines the maximum transient size, which will not be allowed to be more than half that lenght in size.

ARGUMENT:: padSize
	The size of the handles on each sides of the block simply used for analysis purpose and avoid boundary issues.

ARGUMENT:: skew
	The nervousness of the bespoke detection function with values from -10 to 10. It allows to decide how peaks are amplified or smoothed before the thresholding. High values increase the sensitivity to small variations.

ARGUMENT:: threshFwd
	The threshold of the onset of the smoothed error function. It allows tight start of the identification of the anomaly as it proceeds forward.

ARGUMENT:: threshBack
	The threshold of the offset of the smoothed error function. As it proceeds backwards in time, it allows tight ending of the identification of the anomaly.

ARGUMENT:: windowSize
	The averaging window of the error detection function. It needs smoothing as it is very jittery. The longer the window, the less precise, but the less false positives.

ARGUMENT:: clumpLength
	The window size in sample within with positive detections will be clumped together to avoid overdetecting in time.

ARGUMENT:: minSliceLength
	The minimum duration of a slice in samples.

RETURNS::
	An audio stream with impulses at detected transients. The latency between the input and the output is (blockSize + padSize - order) samples.


EXAMPLES::

CODE::
//load some sounds
b = Buffer.read(s,File.realpath(FluidTransientSlice.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");

// basic param (the process add a latency of (blockSize + padSize - order) samples
{var sig = PlayBuf.ar(1,b,loop:1); [FluidTransientSlice.ar(sig) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate))]}.play

// other parameters
{var sig = PlayBuf.ar(1,b,loop:1); [FluidTransientSlice.ar(sig,order:80,minSliceLength:2205) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 80)/ s.sampleRate))]}.play

// More musical, transient-trigged autopan
(
{
	var sig, trig, syncd, pan;
	sig = PlayBuf.ar(1,b,loop:1);
	trig = FluidTransientSlice.ar(sig,order:10,minSliceLength:4410);
	syncd = DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate));
	pan = TRand.ar(-1,1,trig);
	Pan2.ar(syncd,pan);
}.play
)
::
