DXMixIn:
Filter:
miSCellaneous_lib/Classes (extension) | Libraries > miSCellaneous > DX suite

DXMixIn
ExtensionExtension

crossfades between signals from buses according to demand-rate control

Description

DXMixIn crossfades between signals from buses according to a sequence of indices, which, together with fadeTimes and stepTimes, can be passed as demand rate ugens.

NOTE: As interface and conventions of DX ugens are nearly identical, I didn't double examples for all features. It's recommended to start with the DX_suite overview and go through the help file examples in this order: DXMix - DXMixIn - DXEnvFan - DXEnvFanOut - DXFan - DXFanOut. Some general conventions are treated in detail in the following examples: fades and steps in DXMix, Ex.2 – width and offset arguments in DXMix, Ex.3 – multichannel expansion in DXMix, Ex.6 – crossfade types in DXEnvFan, Ex.1.
NOTE: PanAz.ar's args pos and orientation were scaled wrongly in SC versions up to 3.8. DX ugens neutralize this bug by inverse scaling, so it should actually work the same with SC versions before 3.9 with the exception of examples with modulatable width (disabled in earlier versions). I didn't encounter differences in any other test examples, however I'd rather recommend a SC version from 3.9 onwards, if you have the choice.
NOTE: Depending on the multichannel sizes it might be necessary to increase server resources, i.e. the number of interconnect buffers (e.g. s.options.numWireBufs = 256; s.reboot). See DXMix, Ex.8 and DXEnvFan, Ex.2, DXEnvFan, Ex.4 for aspects of CPU demand.
NOTE: In my tests timing was exact up to one sample. So when used for granulation DX ugens avoid the inevitable inccuracies of language-based triggering in realtime. However care has to be taken: fade and step times must be larger than the duration of a control cycle. With default values sampleRate = 44100 Hz and blockSize = 64, this equals ca. 0.00145 sec. If you go below, the fade mechanism is messed up and you get jumps and clicks. Accordingly with fadeModes 3 and 4 you have to ensure that the remaining 'real' stepTime, which is calculated by stepTime minus fadeTime, is larger than this threshold. But as a workaround you can always lower the blocksize. See DXFan, Ex.4 for aspects of granulation with high trigger rates / short grain durations.
NOTE: The current implementation is bound to counting with Dseries and – inherent to 32 bit floats – the integer accuracy limit of 2 ** 24 - 1 = 16777215. This can be an issue with setups that are using extreme short durations for hours.

Credits

Thanks to Wouter Snoei for his PlayBufCF class. It gave me a lot of inspiration for DX ugens – although in the end the implementation with PanAz and DemandEnvGen is quite different. Thanks also to Till Bovermann for ironing out a longstanding bug in PanAz.

Class Methods

.ar

Arguments:

in

Determines the sequence of signals to be crossfaded. A demand rate or other ugen returning bus indices, a single bus index or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of in and the latter contains demand rate ugens, they must all be wrapped into Functions.

fadeTime

A fade time, a demand rate or other ugens returning fade times or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of fadeTime and the latter contains demand rate ugens, they must all be wrapped into Functions. The interpretation of fadeTime depends on fadeMode. fadeTime must be larger than the duration of a control cycle. Defaults to 1.

stepTime

A step time, a demand rate or other ugens returning step times or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of stepTime and the latter contains demand rate ugens, they must all be wrapped into Functions. The interpretation of stepTime depends on fadeMode. stepTime must be larger than the duration of a control cycle. Defaults to 1.

fadeMode

Integers between 0 and 4 or a SequenceableCollection of such, causing multichannel expansion. Not modulatable.

  • fadeMode = 0: only fadeTimes are used, no steps
  • fadeMode = 1: alternate steps and fades, begin with step; stepTime means time without fade
  • fadeMode = 2: alternate fades and steps, begin with fade; stepTime means time without fade
  • fadeMode = 3: alternate steps and fades, begin with step; stepTime means sum of step and fade, thus stepTime must be larger than fadeTime, the difference must be larger than the duration of a control cycle
  • fadeMode = 4: alternate fades and steps, begin with fade; stepTime means sum of fade and step, thus stepTime must be larger than fadeTime, the difference must be larger than the duration of a control cycle

Defaults to 0.

sine

Determines the crossfade type: sine-based or not. A Boolean, 0 or 1 or a demand rate or other ugen returning sine numbers or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of sine and the latter contains demand rate ugens, they must all be wrapped into Functions. Modulating this arg is only possible if allowTypeSeq equals 1. Defaults to 1.

equalPower

Determines if crossfading of equal power type (square root) should be applied. A Boolean, 0 or 1 or a demand rate or other ugen returning equalPower numbers or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of equalPower and the latter contains demand rate ugens, they must all be wrapped into Functions. Modulating this arg is only possible if allowTypeSeq equals 1. Defaults to 1.

power

This only comes into play if equalPower equals 0, then it's applied to the crossfade amplitude. If power and curve are passed, power applies before. A positive Number or a demand rate or other ugen returning positive power numbers or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of power and the latter contains demand rate ugens, they must all be wrapped into Functions. Sequencing this arg with demand rate ugens is only possible if allowTypeSeq equals 1. Defaults to 1.

curve

This only comes into play if equalPower equals 0, then it's applied to the crossfade amplitude according to the lincurve mapping. If power and curve are passed, power applies before. A Number or a demand rate or other ugen returning curve numbers or a SequenceableCollection of such, causing multichannel expansion. If in this case the overall multichannel size is larger than the size of curve and the latter contains demand rate ugens, they must all be wrapped into Functions. Sequencing this arg with demand rate ugens is only possible if allowTypeSeq equals 1. Calculation of curvature is not giving reliable results when width and / or dynOutOffset are being modulated at the same time. Defaults to 0.

allowTypeSeq

Enables sequencing of sine, equalPower, power and curve with demand rate ugens and modulating of sine and equalPower with other ugens. A Boolean, 0 or 1 or a SequenceableCollection of such, causing multichannel expansion. Not modulatable. As this requires more ugens running in parallel it is disabled by default = 0.

fadeRate

One of the Symbols \ar and \kr, determining the crossfade rate used by PanAz or a SequenceableCollection of such, causing multichannel expansion. Not modulatable. Defaults to \ar.

maxFadeNum

Integer determining the maximum number of fades, after which doneAction applies. A SequenceableCollection causes multichannel expansion. Not modulatable. Defaults to inf.

maxWidth

An Integer determining the maximum width or a SequenceableCollection of such, causing multichannel expansion, width goes into PanAz's width arg. maxWidth increases the internally used and potentially needed number of parallel channels. Not modulatable. Defaults to 2.

width

Integer, Float, UGen (only from SC 3.9 onwards) or a SequenceableCollection of such, causing multichannel expansion. Not modulatable in versions earlier than SC 3.9. It determines the width according to PanAz's width arg. Note that a ugen's output must not exceed maxWidth. Defaults to 2.

initOutOffset

An Integer or Float or a SequenceableCollection of such, causing multichannel expansion. Determines an initial offset for PanAz's pos arg. This can be useful for a start with full or reduced width. Not modulatable. Defaults to 0.

maxDynOutOffset

An Integer or Float or a SequenceableCollection of such, causing multichannel expansion. Determines the maximum dynOutOffset to be expected. maxDynOutOffset increases the internally used and potentially needed number of parallel channels. Not modulatable. Defaults to 1.

dynOutOffset

UGen, Integer or Float or a SequenceableCollection of such, causing multichannel expansion. By passing a ugen the movement between buses can be modulated. Note that a ugen's output must not exceed maxDynOutOffset. Defaults to 0.

allowFadeEnd

Integer, Boolean or a SequenceableCollection of such, causing multichannel expansion. Determines if a demand rate input to in with finite length will be monitored, which needs a quite complicated trigger logic and more running ugens. If set to 0, the behaviour after the end of in is undefined. Defaults to 1.

zeroThr

A Number or a ugen returning zeroThr numbers or a SequenceableCollection of such, causing multichannel expansion. Determines if output values below this threshold are replaced by 0. This makes sense if the output signal is used as trigger (e.g. with DXEnvFan). In the case of low power numbers small inaccuracies are amplified, this is avoided with an appropriate zeroThr (e.g. = 0.001), as the operation is applied before taking the power. As this requires more ugens running in parallel it is disabled by default = nil.

doneAction

Integer or a SequenceableCollection of such, causing multichannel expansion. Determines the doneAction after maxFadeNum is exceeded. Defaults to 0.

.kr

Examples

 

Ex.1: Crossfaded mixing from buses

 

Ex.2: Multichannel expansion