TimeStretch is the 1952 Cadillac Fleetwood of extreme time stretching algorithms - a big, hulking, and slow beauty. All calculations and audio processing are done in the language, thus calculations move at a glacial pace. For a faster version that uses the server, but doesn't sound quite as good, check out TimeStretch2.
Transient separation requires FluidBufTransients from the FluCoMa Fluid Decomposition Toolbox (flucoma.org). This is commented out in the release. Open TimeStretch.sc to uncomment the method once you have the toolbox.
Implements a phase randomized FFT time stretch algorithm, the NessStretch, which splits the original sound file into 9 discrete frequency bands, and uses a decreasing frame size to correspond to increasing frequency. Starting with a largest frame of 65536, the algorithm will use the following frequency/frame size breakdown:
0-86hz : 65536
86-172hz : 32768
172-344 : 16384
344-689 : 8192
689-1378 : 4096
1378-2756 : 2048
2756 - 5512 : 1024
5512-11025 : 512
11025-22050 : 256
The algorithm also correlates each grain in the FFT with the previous and next grain, and creates a custom crossfade for each overlap based on the correlations between grains.
The mergeFiles method below requires FluidBufCompose from the FluCoMa library. This method is commented out in the distro. Files can be merged in any DAW.
Performs a stretch on a file channel and places the stretched file in the same folder as the original.
inFile |
Path to the input file to be stretch. Can be a mono or stereo file. |
durMult |
How many times longer the outFile will be than the inFile. Goes waaaaay past 11 (try 100!). Must be an integer. Will round to the nearest integer if it receives a float. |
chanNum |
The Channel to stretch; |
splits |
By default, the algorithm will split audio data into 9 frequency "octaves", starting with the first octave below nyquist, then subsequent octaves down from there, leaving everything below the last split to the largest buffer. However, for files of transients, you may want to approach this differently. A number smaller than 9 will leave the top N octaves "normal", but will stop at the number provided. So, a 4 would have a max window size of 2048. An Array can also be provided. All values in the array need to be powers of 2, so something like [65536, 32768, 16384, 8192] will work. |
filterOrder |
By default (value = 129) the filter will be a brickwall fft bandpass filter separating frequency bands. However, by giving filterOrder a number 128 and below, the program switches to a Linkwitz-Riley filter with the order number provided. |
fftType |
By default (fftType=0) this will use a standard fft. However, if set to fftType=1, it will use the rfftTwo from the SignalBox Quark (which needs to be installed). This is about 50% faster. |
Stretches a stereo+ audio file into single channel audio files in the same folder as the source file. Will open two instances of sclang in the terminal to stretch these independently. Only works on MacOS. The folder that contains sclang has to be in your PATH for this to work.
inFile |
The file to stretch. |
durMult |
See above. |
chanArray |
An array telling the algorithm which channels in the file to stretch. If nil, will default to [0,1]. |
splits |
See above. |
filterOrder |
See above. |
fftType |
See above. |
Merges the provided single channel files (2 from a stereo file or 4 from a stereo file split into resonance and transients) into a single stereo file. Will output a wav file if possible, but a w64 if the resulting file will be too large for the wav format. With larger stretches, it may be better to just use a DAW, where you can mix things with your ears.
inFilesArray |
An Array listing the 2 or 4 audio files (1 or 2 stereo pairs) to mix into one stereo file. |
outPath |
An Array listing the 2 or 4 audio files (1 or 2 stereo pairs) to mix into one stereo file. |
numChans |
Number of channels in the original audio file. |
transientMix |
How loud the transients should be in the final mix. |
A convenience method for transient separation. This is a very aggressive setting, which should work for most sources. Places the separated files into the same folder as the source.
Commented out in the TimeStretch.sc file. Requires the FluCoMa library for SC. Download this library, uncomment and recompile to use this.
inFile |
The file to separate. |
Will start an NRT server, load the file, and execute the time stretch. Each instance of TimeStretch will run on its own server, so you can run as many simultaneously as your computer can handle.