Slide effect - HELP NEEDED

Archive of Nyquist Plug-ins.
Many of the plug-ins here will be available on the Audacity Wiki.

This Forum is an archive of old topics concerning Nyquist plug-ins.

Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.

New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.

The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.

Slide effect - HELP NEEDED

Permanent link to this post Posted by Michael Kazmierski » Wed May 31, 2017 1:26 am

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.
Code: Select all
;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)))))
Last edited by waxcylinder on Wed May 31, 2017 8:57 am, edited 1 time in total.
Reason: code tags added for readability
Michael Kazmierski
 
Posts: 48
Joined: Wed Aug 17, 2016 1:06 am
Operating System: Windows 7

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Thu Jun 01, 2017 12:52 am

If you try running that code using the "Debug" button rather than the "OK" button, you will see an error message saying:
Code: Select all
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 wrote: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/slid ... shift.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by Michael Kazmierski » Thu Jun 01, 2017 1:13 am

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?
Michael Kazmierski
 
Posts: 48
Joined: Wed Aug 17, 2016 1:06 am
Operating System: Windows 7

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Thu Jun 01, 2017 8:20 am

Michael Kazmierski wrote: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
(15.57 KiB) Downloaded 31 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Thu Jun 01, 2017 9:40 am

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.

Code: Select all
;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*))))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by Michael Kazmierski » Thu Jun 01, 2017 5:47 pm

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.
Michael Kazmierski
 
Posts: 48
Joined: Wed Aug 17, 2016 1:06 am
Operating System: Windows 7

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Thu Jun 01, 2017 7:30 pm

Michael Kazmierski wrote: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/ ... l#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):

Code: Select all
;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)))

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Tue Jul 04, 2017 2:12 pm

I think this does what you want:
slide-speed.ny
(1.1 KiB) Downloaded 26 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by Michael Kazmierski » Thu Jul 06, 2017 5:38 pm

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.
Michael Kazmierski
 
Posts: 48
Joined: Wed Aug 17, 2016 1:06 am
Operating System: Windows 7

Re: Slide effect - HELP NEEDED

Permanent link to this post Posted by steve » Fri Jul 07, 2017 12:09 am

Michael Kazmierski wrote: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 wrote:instead of *track*, I forgot

"S"
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44998
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Next

Return to Plug-in Archive



Who is online

Users browsing this forum: No registered users and 1 guest