You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
3.1 KiB
Plaintext
69 lines
3.1 KiB
Plaintext
TITLE:: FluidAudioTransport
|
|
summary:: Interpolate between sounds
|
|
categories:: Libraries>FluidCorpusManipulation
|
|
related:: Classes/FluidBufAudioTransport
|
|
|
|
DESCRIPTION::
|
|
Interpolates between the spectra of two sounds using the Optimal Transport algorithm
|
|
|
|
See
|
|
Henderson and Solomonm (2019) AUDIO TRANSPORT: A GENERALIZED PORTAMENTO VIA OPTIMAL TRANSPORT, DaFx
|
|
|
|
|
|
CLASSMETHODS::
|
|
|
|
METHOD:: ar
|
|
Process incoming audio signals
|
|
|
|
ARGUMENT:: in
|
|
Source A
|
|
|
|
ARGUMENT:: in2
|
|
Source B
|
|
|
|
ARGUMENT:: interpolation
|
|
The amount to interpolate between A and B (0-1, 0 = A, 1 = B)
|
|
|
|
ARGUMENT:: windowSize
|
|
The window size in samples. As AudioTransport relies on spectral frames, we need to decide what precision we give it spectrally and temporally, in line with Gabor Uncertainty principles. http://www.subsurfwiki.org/wiki/Gabor_uncertainty
|
|
|
|
ARGUMENT:: hopSize
|
|
The window hop size in samples. As AudioTransport relies on spectral frames, we need to move the window forward. It can be any size but low overlap may create audible artefacts. The -1 default value will default to half of windowSize (overlap of 2).
|
|
|
|
ARGUMENT:: fftSize
|
|
The inner FFT/IFFT size. It should be at least 4 samples long; at least the size of the window; and a power of 2. Making it larger than the window size provides interpolation in frequency. The -1 default value will use the next power of 2 equal or above the windowSize.
|
|
|
|
ARGUMENT:: maxFFTSize
|
|
How large can the FFT be, by allocating memory at instantiation time. This cannot be modulated.
|
|
|
|
RETURNS::
|
|
An audio stream with the interpolated spectrum of the inputs.
|
|
EXAMPLES::
|
|
|
|
code::
|
|
//didactic - the mouse X axis interpolates between the two sinewaves
|
|
{FluidAudioTransport.ar(SinOsc.ar(220,mul: 0.1),SinOsc.ar(440,mul: 0.02),MouseX.kr())}.play;
|
|
|
|
//notice how the interpolation quantizes to the FFT bins. Like most spectral processes, it benefits from oversampling the fft... at the cost of CPU power, obviously.
|
|
{FluidAudioTransport.ar(SinOsc.ar(220,mul: 0.1),SinOsc.ar(440,mul: 0.02),MouseX.kr(),fftSize: 8192)}.play;
|
|
|
|
// when the signal is steady, larger hopSize can be accommodated to save back on the CPU
|
|
{FluidAudioTransport.ar(SinOsc.ar(220,mul: 0.1),SinOsc.ar(440,mul: 0.02),MouseX.kr(),windowSize: 8192)}.play; // here we get a default hop of half the window so 8 times less than above.
|
|
|
|
//if you CPU can cope, try this setting, almost smooth, but attacks would smear (the Y axis mixes some in to hear the effect)
|
|
{var attacks = Impulse.ar(1,mul: MouseY.kr(-40,10).dbamp); FluidAudioTransport.ar(SinOsc.ar(220,mul: 0.1,add: attacks),SinOsc.ar(440,mul: 0.02,add: attacks),MouseX.kr(),windowSize: 16000)}.play;
|
|
|
|
//richer with complex spectra
|
|
//load 2 files
|
|
(
|
|
b = Buffer.read(s,File.realpath(FluidAudioTransport.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-CEL-GlitchyMusicBoxMelo.wav");
|
|
c = Buffer.read(s,File.realpath(FluidAudioTransport.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-CF-ChurchBells.wav");
|
|
)
|
|
//listen to them
|
|
b.play
|
|
c.play
|
|
//stereo cross!
|
|
{FluidAudioTransport.ar(PlayBuf.ar(2,b,loop: 1),PlayBuf.ar(2,c,loop: 1),MouseX.kr())}.play;
|
|
|
|
::
|