home/ atoms/ tidal-range-scaling

TidalCycles range rescales a 0–1 continuous pattern to any numeric interval

The range function takes a pattern that goes from 0 to 1 (such as sine or cosine) and rescales it to span between two given values. range 1 1.5 sine shifts the sine’s output from the 0–1 range to the 1–1.5 range. A logarithmic variant, rangex, is provided for frequency-domain use: rangex 20 2000 0.5 gives 200 (midpoint on a log scale) whereas range 20 2000 0.5 gives 1010 (linear midpoint). The distinction matters whenever mapping to pitch or frequency because equal perceptual steps are logarithmic. quantise n rounds values to the nearest 1/n fraction, useful for snapping a continuous wave pattern to discrete notes or MIDI values.

Examples

d1 $ jux (iter 4) $ sound "arpy arpy:2*2" |+ speed (slow 4 $ range 1 1.5 sine)
-- logarithmic frequency mapping (sounds better for pitch):
-- rangex 20 2000 0.5 → 200, not 1010
-- quantise to semitones:
d1 $ s "superchip*8" # n (quantise 1 $ range (-10) (10) $ slow 8 $ cosine)

Assessment

Predict the output of rangex 20 2000 0.5 vs range 20 2000 0.5. Explain why one is better for mapping to pitch. Write a TidalCycles line that uses range to map a slow sine oscillator to pan values between -0.5 and 0.5.

“`rangex` is an exponential version of `range` described above, good to use for frequencies.”
corpus · tidalcycles-alteration-reference-ply-chunk-linger-snowball-s · chunk 1