# Slide effect - HELP NEEDED

**URL:** <https://forum.audacityteam.org/t/slide-effect-help-needed/45813>\
**Category:** Plug-in Archive\
**Created:** [May 31, 2017, 1:26am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813 "2017-05-31T01:26:29Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [May 31, 2017, 1:26am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/1 "2017-05-31T01:26:29Z")

</div>

Hello,  
I really find the Turntable Warp plugin very interesting. However, I’ve tried to modify it so that there is no amplitude change, nor Change Time (i.e. I want it to slide for the whole entire selection). Ever since I’ve tried to modify it, I never got it to work, So I need some help please.  
Also understand I’m not an expert about Nyquist at all, I’d prefer help from others.  
Here’s the code. Again it doesn’t work when I run it, so I definitely would benefit from some help.

```plaintext
;nyquist plug-in

;version 2

;type process

;name "Slide..."

;action "Sliding..."

;info "Turntable Warping by David R. Sky\nbased on warp tutorial by Roger B. Dannenberg\nSteps are number of semitones above or below non-warped audio\nreleased under terms of the GNU Public License"

;control step0 "Initial step" real "semitones" 0 -36 36
;control step1 "End step" real "semitones" -12 -36 36

; Turntable Warping (mono/stereo) by David R. Sky, December 26, 2004 

; warps mono or stereo audio loaded into Audacity 1.2.3 and later

; step values are semitones above or below pitch of unwarped audio 

; Based on warp tutorial by Roger B. Dannenberg

; Released under terms of the GNU Public License

; http://www.opensource.org/licenses/gpl-license.php

; determine duration of selection in seconds

(setf dur (/ len *sound-srate*))

; function to stretch audio to inverse of duration

(defun newstretch (dur s)

(if (arrayp s) 

(vector (force-srate 44100 (stretch-abs (/ 1.0 dur) (sound (aref s 0)))) 

(force-srate 44100 (stretch-abs (/ 1.0 dur) (sound (aref s 1))))) 

(force-srate 44100 (stretch-abs (/ 1.0 dur) (sound s)))))

; Variable Resample function by Roger B. Dannenberg

(defun variable-resample (steps snd)

; p1 helps convert steps to a ratio        

  (let ((p1 (/ (log 2.0) 12)) ratio map)

; pitch ratio

    (setf ratio (s-exp (mult steps p1))) 

; map from real-time to sound time     

    (setf map (integrate ratio)) 

(snd-compose snd (force-srate *sound-srate* map))))

; doing the warp

(if (arrayp s)

(vector

; left channel

(newstretch dur 

(variable-resample 

(pwl 0.0 step0 dur step1 finish step1)

(mult (pwl 1.0 dur) 

(sound (aref s 0)))))

; right channel

(newstretch dur 

(variable-resample 

(pwl 0.0 step0 dur step1 finish step1)

(mult (pwl 1.0 dur) 

(sound (aref s 1))))))

; mono

(newstretch dur 

(variable-resample 

(pwl 0.0 step0 dur step1 finish step1)

(mult (pwl 1.0 dur) 

(sound s)))))

```

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [June 1, 2017, 12:52am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/2 "2017-06-01T00:52:32Z")

</div>

If you try running that code using the “Debug” button rather than the “OK” button, you will see an error message saying:

```plaintext
error: unbound variable - FINISH

```

That means that somewhere in your code you are using a variable called “finish” but it is not set to anything, so Nyquist doesn’t know what to do with it.

> [@Michael Kazmierski](#):
>
> I’ve tried to modify it so that there is no amplitude change, nor Change Time

I’m not sure that I understand what you are trying to do. Turntable warp slows down the audio, like a turntable slowing down, so if all of the selected audio is processed it must get longer.

If you really want it change speed without the length changing, then use the “Sliding Time Scale / Pitch Shift” effect: [http://manual.audacityteam.org/man/sliding\_time\_scale\_pitch\_shift.html](http://manual.audacityteam.org/man/sliding_time_scale_pitch_shift.html)

---

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [June 1, 2017, 1:13am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/3 "2017-06-01T01:13:27Z")

</div>

I’m not referring to changing the pitch by itself. What I am trying to do is change the speed from one point to another, that’s all. In other words, create a Jaws-accessible version of timetracks. Now why are they so f\*\*ing visual?

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [June 1, 2017, 8:20am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/4 "2017-06-01T08:20:25Z")

</div>

> [@Michael Kazmierski](#):
>
> What I am trying to do is change the speed from one point to another, that’s all. In other words, create a Jaws-accessible version of timetracks.

Thanks, I now understand what you’re trying to do, and it’s a very good idea. It is, however, tricky to code. The hardest part is working out the time positions. The next hardest part is fixing bugs in the original plug-in code.

From a quick look at the code in turntablewarp-ms.ny I see there’s quite a lot of errors in David Sky’s code, so I think the best approach would be to start again from Roger Dannenberg’s “variable resample” tutorial. I have attached that tutorial in RTF format here:  
[pitch\_change.rtf](https://forum.audacityteam.org/uploads/short-url/eHxw1CILvEnyvhPL5XuGUbEQdNJ.rtf) (15.6 KB)

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [June 1, 2017, 9:40am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/5 "2017-06-01T09:40:36Z")

</div>

This may help as a start. It can be run in the Nyquist Prompt effect.  
It “sort of works”, but the function to calculate the new length after stretching needs to be written.

```plaintext
;version 4
;control initial-pitch "Initial pitch" float "" 0 -12 12
;control final-pitch "Final pitch" float "" 12 -12 12

(defun variable-resample (steps snd)
  (let ((p1 (/ (log 2.0) 12)) ; p1 helps convert steps to a ratio
        ratio map)
    (setf ratio (s-exp (mult steps p1))) ; pitch ratio
    (setf map (integrate ratio)) ; map from real-time to sound time
    (snd-compose snd (force-srate *sound-srate* map))))

(defun new-length (initial-dur)
  ;; Need to work out the new length after stretching
  ;; For now, we just return the original length
  initial-dur)

(setf dur (get-duration 1)) ;The initial length of the selection

(abs-env
  (let* ((end (new-length dur))
         ; make the speed envelope a little longer than required to avoid click at end.
         (pitch (pwl 0 initial-pitch end final-pitch (1+ end))))
     (multichan-expand #'variable-resample pitch (sound *track*))))

```

---

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [June 1, 2017, 5:47pm UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/6 "2017-06-01T17:47:43Z")

</div>

Thanks Steve.  
Unfortunately I didn’t quite understand even the tutorial, but I somehow knew that the plugin will need to get the entire duration of the file as does the Turntable Warp plugin.  
The parameters in my Slide effect are actually pretty simple really - “Initial deviation” and “Final deviation”, but rather than in semitones it would be in percentages. So I guess I’d have to delete the calculation of converting steps to a ratio? And get the duration? Or is there more to it besides the warp command and the last two points?  
I knew it’d be at least a bit easier than you thought it would.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [June 1, 2017, 7:30pm UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/7 "2017-06-01T19:30:06Z")

</div>

> [@Michael Kazmierski](#):
>
> The parameters in my Slide effect are actually pretty simple really - “Initial deviation” and “Final deviation”, but rather than in semitones it would be in percentages. So I guess I’d have to delete the calculation of converting steps to a ratio?

You still need to create the “mapping”, which is a ramp up from 0,0. The **slope** governs the speed.  
The function that does the heavy lifting is the Nyquist function “snd-compose”.  
[http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index700](http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index700)

As an example, this gives a fixed rate speed change (which of course could be implemented more easily by just resampling, but the point is to use snd-compose):

```plaintext
;version 4

;control speed "Speed multiplier" float "" 1 0.1 10

; For constant speed, the duration is easily calculated as:
; original-duration / speed
(setf dur (/ (get-duration 1) speed))

(abs-env
  (let ((map (force-srate *sound-srate* (pwlv 0 dur (* speed dur)))))
    (snd-compose *track* map)))

```

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [July 4, 2017, 2:12pm UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/8 "2017-07-04T14:12:28Z")

</div>

I think this does what you want:  
[slide-speed.ny](https://forum.audacityteam.org/uploads/short-url/jcDKAaiFAzMpP5YHgvgVVkgGgDb.ny) (1.1 KB)

---

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [July 6, 2017, 5:38pm UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/9 "2017-07-06T17:38:21Z")

</div>

Thanks Steve,  
However, I think it’s now just a case of trying to convert it so it’s understood by Audacity 2.0.6. I wonder what to modify for that? I guess that instead of version 4 would be version 3, and instead of _track_, I forgot - was it Snd? Just can’t remember.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [July 7, 2017, 12:09am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/10 "2017-07-07T00:09:17Z")

</div>

> [@Michael Kazmierski](#):
>
> I think it’s now just a case of trying to convert it so it’s understood by Audacity 2.0.6

Why not upgrade to Audacity 2.1.3?

> [@Michael Kazmierski](#):
>
> instead of _track_, I forgot

“S”

---

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [July 7, 2017, 12:20am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/11 "2017-07-07T00:20:51Z")

</div>

Well, the only reason why I don’t ever want to try 2.1.2 is because it makes no sense at all for a plugin to insert unwanted silence and latency which might not be corrected, plus I’m not used to having effects perform in real-time. When I replaced _track_ with just S, it doesn’t work.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [July 7, 2017, 12:24am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/12 "2017-07-07T00:24:38Z")

</div>

> [@Michael Kazmierski](#):
>
> it makes no sense at all for a plugin to insert unwanted silence and latency which might not be corrected

What are you referring to?

---

<div class="post-metadata">

**Author:** ![Michael\_Kazmierski](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Michael\_Kazmierski](https://forum.audacityteam.org/u/Michael_Kazmierski)\
**Post date:** [July 7, 2017, 12:27am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/13 "2017-07-07T00:27:43Z")

</div>

I can remember for some reason, whichever plugins that can be changed in real-time when you play a file, I remember something about the effect having to insert latency so it could be applied. I’m not sure if this is still true in 2.1.2, but to me it just doesn’t make sense.  
All I did with the code was to change _track&_ to S, and version 4 to version 3. The plugin appears, but when I run it, it says Nyquist did not return audio.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [July 7, 2017, 1:07am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/14 "2017-07-07T01:07:58Z")

</div>

> [@Michael Kazmierski](#):
>
> remember something about the effect having to insert latency so it could be applied.

The bug that you are referring to affects the preview of some third party plug-ins. It does not affect how the effect is applied, and does not affect any of the effects that are shipped with Audacity. It also does not affect Nyquist effects.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [July 7, 2017, 1:36am UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/15 "2017-07-07T01:36:11Z")

</div>

> [@Michael Kazmierski](#):
>
> The plugin appears, but when I run it, it says Nyquist did not return audio.

Try running the effect using the Debug button rather than the OK button.  
What does it say in the debug window?

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [October 12, 2017, 1:34pm UTC](https://forum.audacityteam.org/t/slide-effect-help-needed/45813/16 "2017-10-12T13:34:32Z")

</div>

The “Sliding Speed Change” plug-in is now available on the Audacity wiki: [http://wiki.audacityteam.org/wiki/Nyquist\_Effect\_Plug-ins#Sliding\_Speed\_Change](http://wiki.audacityteam.org/wiki/Nyquist_Effect_Plug-ins#Sliding_Speed_Change)
