**SPECTSTR**- Time-stretch analysis file, suppressing artefacts when stretch > 1
- STRETCH
**SPECTRUM** - stretch/compress the frequency components of a sound in an inharmonic way
- STRETCH
**TIME** - stretch/compress a sound in time without changing the pitch
**STRETCHA**- Utility to Calculate
*timestretch*factor relating to beats and tempo for use with STRETCH TIME **Technical Discussion**- Stretching Frequency Components

**Return**
to Main Index for the CDP System.

Return
to Spectral Index

NB: This function is a newer version of **STRETCH TIME**.

infile– input analysis file

outfile– output analysis file

timestretch– stretch/shrink multiplier, which may itself vary over time. (Range: 0.0001 to 10000; <1 shrinks the time)

d-ratio– proportion of channels to discohere. (Range: 0 to 1)

d-rand– frequency randomisation of discohered channels. (Range: 0 to 1)

Timestretch stretches or shrinks the sound over time, without changing frequency. It creates extra time-windows to expand the overall time-base of the sound, without a change of frequency. The stretching itself can be time-varying. If the stretch factor TSTRETCH is <1, a time-shrinking occurs.

SPECTSTR is identical to the original

STRETCH TIMEprocess in respect of time-stretching, but adds the DISCOHERE and RANDOMISE parameters. It is not clear yet what is meant by "discohere" in the context of time-stretching.

See

STRETCH TIME

End of SPECTSTR

Return to List of stretch functions at top of
this file

**Return**
to Main Index for the CDP System.

Return
to Spectral Index

1Stretch above thefrq_divide

2Stretch below thefrq_divide

infile– input analysis file made with PVOC

outfile– output analysis file

frq_divideis the frequency above or below which spectral stretching takes place

maxstretchis the transposition ratio of the topmost spectral components

exponentspecifies the type of stretching required (> 0)

-ddepthstretch effect on source (from 0 (no effect) to 1 (full effect)

depthcan vary over time

The STRETCH SPECTRUM process is a means to warp the spectrum of a sound. For example, a harmonic sound may become inharmonic, in a controllable way. (It is derived from CDP's former function SPECE.)

The STRETCH SPECTRUM process gives us control over the way in which we stretch the spectrum of a sound. It should be used for stretching as opposed to shifting the spectrum of a sound. The stretching operation begins at the

frq_divideand proceeds upwards.The main thing to appreciate regarding STRETCH SPECTRUM is that the stretch factor is scaled across the frequencies, beginning at 1 at the

frq_divide(no stretch) and gradually increasing or decreasing until reachingmaxstretchof the uppermost channel in which a frequency is found (not > Nyquist). Overall, it is rather like stretching or compressing a rubber sheet – the whole sheet is warped by the stretching process and the partials are thereby moved.The scaling of

maxstretchis linear (even increments) whenexponentis an integer. Ifexponentis < 1.0, the stretch curve will rise quickly and then tend to even out. Ifexponentis > 1.0, the stretch curve will start to rise slowly and then gradually rise more quickly.The stretching operation expands or contracts the frequency gap between partials. The

Technical Discussionoffers some supplementary observations about how to think about what this means.Under this operation the frequency ratios between the partials of the original sound are not preserved. Thus, for example, a sound with harmonically related partials, e.g., 100, 200, 300, 400 Hz (common factor, 100) will end up with partials which are not harmonically related, e.g., 110, 213, 316, 419 Hz (no common factor). Such an inharmonic spectrum will normally be perceived as containing several pitches or (with a small stretch) strong spectral colouration. So the stretching operation usually increases inharmonicity and the timbral richness of a sound.

## Use of

maxstretch

Maxstretchspecifies the amount of stretch to be applied to the partial found in the uppermost channel. The partial in the channel corresponding tofrq_dividedoes not move (maxstretch= 1). Inbetween components will be moved by an amount corresponding to their relative position.

Special Note- components stretched beyond the Nyquist frequency (sr/2) are made to disappear so that the maximum component we will 'hear' will be the one marked 'X' in the above diagram. Hence amaxstretchvalue > 1 may be something of a fiction in practice because partials stretched beyond Nyquist actually disappear.

The image of frequencies on a rubber sheet, referred to above, can help point us in the direction of the possible applications of this process. We can picture the frequencies drawn on the sheet with the lower frequencies at the bottom and the higher frequencies at the top. When we stretch or compress the bottom of the sheet, the frequencies get further apart (i.e., pushing the bottom frequencies lower) or closer together (higher). This will deepen or tighten the tone, as well as make it become more inharmonic at the same time.

Similarly, when the top of the sheet is stretched or compressed, the frequencies become further apart (higher: top ones pushed up) or closer together (this will lower and bunch up the high frequencies), with a similar increase in inharmonicity.

As ever, the results are greatly affected by the nature of the

infile. Experiments with a vocalinfileshould reveal the way it acts on a sound in an easily perceptible manner. Probably the single most important parameter isfrq-divide: where the split point is placed. The quickest way to determine the frequency range of a sound is to use a tuning fork. Trial and error (i.e., guessing) can also be a fairly quick way to get results. Charts of the frequency ranges occupied by various types of sound can also be instructive.For further discussion of stretching frequency components see:

Stretching in the Spectral Domain

End of STRETCH SPECTRUM

Return to List of stretch functions
at top of this file

**Return**
to Main Index for the CDP System.

Return
to Spectral Index

NB: A newer version of this process is available: SPECTSTR

In Mode 2, the program calculates the length of the output only, and does not produce anoutfile.

infile– input analysis file made with PVOC

outfile– output analysis file

timestretchsingle value or the name of atime timestretchbreakpoint file of values.Timestretchis used as a multiple.

The key here is to time stretch the sound without altering the pitch. This can be used either to lengthen or compress the duration. Formerly SPECSTR, meaning 'spectrum time-stretching', the internal prolongation of spectral data is itself subject to temporal control according to the amount of stretch specified at different times.

The fact that the time can be set in the breakpoint file provides an important tool. For example, it can be used to retain the ability to recognise the source of the sound. We often can identify a sound according to the way it begins, its 'attack transient'. This can be kept unchanged by giving a

timestretchof 1 for this part of the sound. Then the stretching can begin, so we retain the recognisability of the sound while stretching it in time. Retaining recognisability is often a very important compositional issue.The breakpoint file sets

timeandtimestretchfactors in such a way thatchange is gradual(interpolated) between different times with different stretch factors. For example:[time stretch] 0.0 1.0 1.0 1.0 2.0 2.5During the 1

^{st}second of the sound, there will be no change. During the 2^{nd}second of the sound, the spectrum will be gradually stretched to 2.5 times its original length.Two different stretch factors cannot be assigned to the same time. At least a slight difference in time is required. So, for virtually instantaneous changes in the stretch factor, use values such as:

[time stretch] 2.0 2.5 2.01 1.5

The stretching can be imagined in a quite literal way. This is illustrated by time stretching a sound which contains strong beat patterns. As the stretch gets longer, one really begins to hear the pulse slow down.

Very long time stretches might best be done in stages rather than all at once. If the whole sound is not required, one way to proceed is to cut out a portion after each time stretch (say a stretch factor between 5 and 10) with SPEC CUT and then restretch that portion. Otherwise, time is wasted as the sound gets longer and longer.

End of STRETCH TIME

Return to List of stretch functions at top of
this file

**Return**
to Main Index for the CDP System.

Return
to Spectral Index

Example command lines (in these examples 'bdt.wav' is 4.9 seconds long):

Mode1.-cflag:

(1)[Result: 12 beats (8 seconds fills 12 beats at MM = 90]`stretcha -c -d8 -T90`

(2)[Result: 8.819878 beats (the input soundfile fills 8.819878 beats at MM=108]`stretcha -c -fbdt.wav -T108`

(3)[Result: 9.6 beats (8 beats at MM=60 becomes 9.6 beats at MM=72]`stretcha -c -b8 -t60 -T72`

Mode2.-sflag:

(1)[Result:`stretcha -s -d8 -D12`

stretchfactor= 1.5 (use to make 8 seconds fill 12 seconds]

(2)[Result:`stretcha -s -d8 -B4 -T50`

stretchfactor= 0.6 (use to make a specified duration fill 4 beats at MM=50]

(3)[Result:`stretcha -s -fbdt.wav -D12`

stretchfactor= 2.449014 (use to make a 4.9 second soundfile fill 12 seconds]

(4)[Result:`stretcha -s -fbdt.wav -B4 -T50`

stretchfactor= 0.977605 (use to make a 4.9 second soundfile fill 4 beats at MM=50]

(5)[Result:`stretcha -s -b8 -t84 -D12`

stretchfactor= 2.449014 (use to make 8 beats at MM=84 fill 12 seconds]

(6)[Result:`stretcha -s -b8 -t84 -B6 -T96`

stretchfactor= 0.5625 (use to make 8 beats at MM=72 fill 6 beats at MM=96]

Mode3.-sflag:

[Result:`stretcha`

-s-t66-T120stretchfactor= 0.550 (use to convert a passage moving at tempo MM=66 to one moving at tempo MM=120]

Mode1: (three input options ⇒ a specified tempo)

-c– takes as inputs: a duration OR a soundfile OR (a number of (possibly fractional) beats and a tempo) and also an output tempo

1. IN:Mode-ddurOUT:-Touttempo⇒ displays how many beats there will be at the new tempo

2. IN:-fsndfileOUT:-Touttempo⇒ displays how many beats the length of the input soundfile will fill at the new tempo

3. IN:-bbeats-ttempoOUT:-Touttempo⇒ displays how many beats there are at the new tempo

2: (three input options ⇒ to a specified duration OR to a number of beats at a given tempo)

-s– takes as inputs: a duration OR a soundfile OR a number of (possibly fractional) beats and a tempo and also an output duration OR a number of (possibly fractional) output beats and an output tempo

1. IN:Mode-ddurOUT:-Doutdur⇒ displays thestretchfactorneeded to change one duration to the other

2. IN:-ddurOUT:-Bbeats-Ttempo⇒ displays thestretchfactorneeded to convert an input duration to a given number of beats at a given tempo

3. IN:-fsndfileOUT:-Toutdur⇒ displays thestretchfactorneeded to convert a given input soundfile to a specified duration

4. IN:-fsndfileOUT:-Bbeats-Ttempo⇒ displays thestretchfactorneeded to convert a given input soundfile to a given number of beats at a given tempo

5. IN:-bbeats-ttempoOUT:-Toutdur⇒ displays thestretchfactorneeded to convert a given number of beats at a given tempo to a specified duration

6. IN:-bbeats-btempoOUT:-Touttempo⇒ displays thestretchfactorneeded to convert a given number of beats at a given tempo to specified number of beats a specified tempo3: (input tempo ⇒ output tempo)

-s– takes as inputs: an input tempo and an output tempo;1. IN:-ttempoOUT:-Ttempo(displays thestretchfactorto change from the first tempo to the second)

dur– an input length of time in seconds

sndfile– an input soundfile

beats– an input number of (possibly fractional) beats

tempo– an input tempo at which the beats occur

outdur– an output length of time in seconds

outbeats– an output number of (possibly fractional) beats

outtempo– an output tempo

STRETCHA is a utility program for use with STRETCH TIME. It takes a bit of calculating to work out how to make a soundfile fit specific numbers of possibly fractional beats. STRETCHA does the work for you. When a soundfile is named as in input, its duration is automatically determined. It can also handle durations and beats as inputs or as outputs to add extra flexibility.

Note that, if you do not have the environment variable CDP_SOUND_EXT SET, you will have to include the .wav extension with the soundfile name. The commandline environment also enables you to write the output to a file rather than just see it displayed on the screen. This is done with the redirection symbol

>as in this example command line:

`stretcha -s -fbdt.wav -D8 >strfac.txt`

.The stretch factor is then used with the CDP program STRETCH TIME. While most of the options are fairly straightforward, note that some possibilities are not covered directly but require two steps. The three

-coptions of Mode1, for example, which convert to a specified tempo, display only "number of beats at new tempo" – it does not actually give astretchfactor. It gives the number of beats that will result. You can then use this information to fill in the 'beats' parameter value in Mode2options to get thestretchfactorto convert the input beats and tempo to a specified duration (option 5) OR tempo (option 6).To illustrate this two step process, if you input adurationof 4 seconds and anouttempoof MM = 90: Mode1option 1 (`stretcha -c -d4 -T90`

), the program tells you that 6 crotchets will result. Now you can use that information to calculate the requiredstretchfactorto fill a specified duration: Mode2, option 5 (`stretcha -s -b6 -t90 -D10`

), yielding a stretch factor of 2.5. Thus 4 seconds changes to 6 crotchets at MM = 90, and this will fill 10 seconds with a stretch factor of 2.5. You have thus gone from duration to duration while specifying a specific number of beats at a given tempo. What you need to do depends on the nature of the material with which you start.It may also be useful to know the actual duration that results from a given number of beats at a given tempo. For example, if you want 4 beats at MM = 72 to be changed to 7.5 beats at MM = 108, you will have to know what duration the later produces (to use Mode

2option 5). The program doesn't provide this facility, but it is easily calculated as, which in this case is`numbeats * 60.0/tempo`

`7.5 * (60.0/108)`

, giving 4.1666 seconds. Then you can use:`stretcha -s -b4 -t72 -D4.1666`

, giving a stretch factor of 1.249980.You can also calculate the duration of the input portion of beats at a tempo and then use the input and output duration option (Mode

2option 1). Thus`4 * (60.0/72) = 3.3333`

:`stretcha -s -d3.3333 -D4.1666`

gives a stretch factor of 1.249980.

It may be helpful to separate out all the options. This reveals how easy it is to use. In the examples, the soundfilebdt.wavis used. Its duration is 4.90 seconds, as shown by`dirsf bdt.wav`

. I've used numbers that enable you to see and compare the results quite easily.Mode

1:1. Inputs: duration and output tempo, Output: number of beats

`stretcha -c -ddur -Touttempo`

Example:`stretcha -c -d4 -T120`

Result: number of beats at new tempo = 8.0 crotchets2. Inputs: soundfile and output tempo, Output: number of beats

`stretcha -c -finsnd.wav -Touttempo`

Example:`stretcha -c -fbdt.wav -T120`

Result: number of beats at new tempo = 9.799864 crotchets3. Inputs: beats & tempo and output tempo, Output: number of beats

`stretcha -c -bbeats -ttempo -Touttempo`

Example:`stretcha -c -b4 -t60 -T120`

Result: number of beats at new tempo = 8.0 crotchets

Mode

2:1. Inputs: duration and output duration, Output: stretch factor

`stretcha -s -ddur -Doutdur`

Example:`stretcha -s -d4 -D8`

Result: stretch factor is 2.02. Inputs: duration and output beats & tempo, Output: stretch factor

`stretcha -s -dduration -Bbeats -Ttempo`

Example:`stretcha -s -d4 -B8 -T90`

Result: stretch factor is 1.3333333. Inputs: soundfile and output duration, Output: stretch factor

`stretcha -s -finsnd.wav -Doutdur`

Example:`stretcha -s -fbdt.wav -D8`

Result: stretch factor is 1.6326764. Inputs: soundfile and output beats and tempo, Output: stretch factor

`stretcha -s -finsnd.wav -Boutbeats -Touttempo`

Example:`stretcha -s -fbdt.wav -B8 -T90`

Result: stretch factor is 1.088455. Inputs: beats & tempo and output duration, Output: stretch factor

`stretcha -s -bbeats -ttempo -Doutdur`

Example:`stretcha -s -b4 -t60 -D8`

Result: stretch factor is 2.06. Inputs: beats & tempo and output beats & tempo, Output: stretch factor

`stretcha -s -bbeats -ttempo -Boutbeats -Touttempo`

Example:`stretcha -s -b4 -t60 -B8 -T90`

Result: stretch factor is 1.333333

Mode

3:1. Input: tempo, Output: tempo

`stretcha -s -ttempo -Touttempo`

Example:`stretcha -s -d60 -D90`

Result: stretch factor is 0.666667

I (AE) asked Trevor to write this program several years ago in order to help create passages of music using regular beat patterns. The source code has been lost for all these years, but an enquiry from Arthur Green, who found the program in his directory of CDP programs and discovered that it would not work on a 64-bit PC, led Richard Dobson to search out the source and recompile it for us.

End of STRETCHA

**Return** to list of STRETCH functions at
top of this file

**Return** to Main Index for
the CDP System.

**Return**
to Groucho Index

**To help visualise what might be happening with the spectrum, here
are some observations about 'interval', 'frequency' and 'partials':**

The stretching operation therefore expands or compresses the frequency (i.e., partial) spacings. But in the higher end of the spectrum, it is useful to remember that the intervals involved will be very small. The aural effect of the stretching process will relate in part to the inharmonic relationships created (or altered) among the intervals defined by the frequencies.Bear in mind that the partials of a tone are closer together in pitch the higher their frequency. This is because pitches are the logarithm of frequency. This means that going up in pitch by equal amounts, we

add intervals– such as going up by one octave – but wemultiply frequencies– times 2 to go up one octave.For example, going up one octave from 400 Hz takes us to 800 Hz, but going up an equivalent one octave from 4000 Hz takes us to 8000 Hz, i.e., 10 times as far in terms of frequency.

Looking at this the other way round, going up by 400 Hz, e.g., from 400 Hz to 800 Hz, takes us up an octave; but going up 400 Hz from 4000 Hz to 4400 Hz takes us up only a very small interval.

The harmonic partials, being integer multiples of the fundamental, are equally spaced in

frequency(e.g., 400 (400 * 1), 800 (400 * 2), 1200 (400 * 3), 1600 (400 * 4) – all are 400 Hz apart). As a result, the pitch-intervals between them get smaller and smaller as we rise in frequency.

End of Technical Discussion

Return to List of stretch functions at top
of this file

**Return**
to Main Index for the CDP System.

Return
to Spectral Index