an open-source digital signal processing and sound synthesis language
about · links · contact
SCRUB -- dynamically transpose an input signal using sync interpolation
in RTcmix/insts/std

quick syntax:
SCRUB(outsk, insk, outdur, AMP, SPEEDMULT, syncwidth, oversampling[, inputchan, pan])

CAPITALIZED parameters are pfield-enabled for table or dynamic control (see the maketable or makeconnection scorefile commands). Parameters after the [bracket] are optional and default to 0 unless otherwise noted.

   p0 = output start time (seconds)
   p1 = input start time (seconds)
   p2 = output duration (or endtime if negative) (seconds)
   p3 = amplitude multiplier (relative multiplier of input signal)
   p4 = speed multiplier
   p5 = sync width (samples)
   p6 = sync oversampling (samples)
   p7 = input channel [optional; default is 0]
   p8 = percent to left [optional; default is .5]

   p3 (amplitude), p4 (speed multiplier) can receive dynamic updates
   from a table or real-time control source

   Author:  Doug Scott, based on interpolation and i/o code by Tobias Kunze-Briseno.

SCRUB is a pitch-shifting instrument using an interesting interpolation scheme. This approach allows for the 'scrubbing' of sound samples down to 0 (and reversed!) to achieve an effect similar to the sound of analog tape being moved back and forth against a playback tape head.

Usage Notes

The main parameter to use is the "SPEEDMULT" (p4), which can change dynamically. A value of 1.0 will play the input sound normally, a value of -1.0 will play it in reverse (you will need to set the input start time (p1) accordingly). 2.0 will play the file at twice the speed, and -0.5 will play it backwards at 1/2 speed. A valu of 0 will stop the sound altogether, just like 'scrubbing' a tape on a tape head (ancient people can recall this...).

The "syncwidth" (p5) and "oversampling" (p6) parameters determine how the buffer used for scrubbing will be set up. These don't seem to have an obvious effect on the sound. It also seems that they should be < the buffer size set in rtsetparams.

The buffer size set in rtsetparams seems to have a significant effect on the sound.

The output of SCRUB can be either mono or stereo

Sample Scores

very basic:
   rtsetparams(44100, 2)

   speed = 1
   dur = DUR(0)
   skip = 0
   // Play forward from time 0
   SCRUB(0, skip, dur, 1, speed, 16, 40)

slightly more advanced:
   rtsetparams(44100, 2, 2048)


   speedchange = maketable("line", 8192, 0,1, 1,-1)
   dur = DUR(0) * 2
   skip = 0
   // Play file, moving from normal speed to reverse normal
   SCRUB(0, skip, dur, 1, speedchange, 16, 40)

fun stuff!
   rtsetparams(44100, 2, 256)


   speed = -1
   skip = DUR(0)
   dur = skip
   // Play backwards from end to beginning in channel 0
   SCRUB(0, skip, dur, 1, speed, 16, 40, 0, 0)

   speed = -0.5
   skip = DUR(0)
   dur = DUR(0) * 2
   // Play reversed at half-speed from end in channel 1
   SCRUB(0, skip, dur, 1, speed, 16, 40, 0, 1)

See Also