Dear Steve,steve wrote: ↑Fri Nov 20, 2015 2:11 pmUnfortunately that code is a bit tricky to use because it requires the sound to be followed to be in the left channel of a stereo track, and the sound to apply the envelope to in the right channel of the stereo track. To use that code with stereo tracks (and binaural beats are stereo by definition) requires messing around splitting and rejoining the stereo tracks several times.Trebor wrote:The magic phrase is "envelope-follower",
e.g. the second block of Nyquist-code here ... http://forum.audacityteam.org/viewtopic ... 90#p107790
Here is an alternative Nyquist script that will work with mono or stereo tracks, provided the tracks are not too long (I've set the max selection length to 30 minutes as that tested OK). This code requires Audacity 2.1.1 or later.
The track that you want to follow must be the first selected track.
Code: Select all
;type process ;control res "Time resolution" float "seconds" 0.1 0.01 10 ;control mode "Follow peak or RMS level" choice "Peak,RMS" 0 (defun mono (sig) (setf sig (s-abs sig)) (if (arrayp sig) (mult 0.5 (sum (aref sig 0)(aref sig 1))) sig)) (setf step (truncate (* res *sound-srate*))) (setf op (- 2 mode)) (cond ((> (get-duration 1) 1800) (format nil "Error.~%~%Selection too long.~%~ Reduce the selection to 30 mins maximum")) ((< (length (get '*selection* 'tracks)) 2) (format nil "Error.~%~%This effect requires at least 2 tracks to be selected.~%~ The amplitude envelope is copied from the first~%~ selected track, then applied to subsequent tracks.")) ((< (get-duration 0.5) res) (format nil "Error.~%~%The 'Time Resolution' should be considerably~%~ shorter than the length of the selection.~%~ The absolute maximum allowed 'Time Resolution' is~%~ half of the selection length.")) ((= (get '*track* 'index) 1) (setf *scratch* (snd-copy (snd-avg (mono *track*) step step op))) ; return *track* to prevent audio from being released from *scratch*. *track*) ;*track*) (T (let ((env *scratch*) (offset (* res (/ (1+ mode) 2.0))) (initial-amp (snd-fetch (snd-copy *scratch*)))) ; release *scratch* when we're finished (if (= (get '*track* 'index)(length (get '*selection* 'tracks))) (setf *scratch* '*unbound*)) (mult *track* (sim (abs-env (pwlv 0 offset initial-amp)) (at-abs offset (cue env)))))))
The envelope detected in the first selected track is then applied to each subsequent track.
This post was very helpful. I wanted to do the same thing, copy envelope from one track to another and this code worked 9/10 for my needs. The only knock is that it moved the envelope as opposed to copying it. With some creative copy/undo/paste, it was a mere speedbump.
I signed up for an account simply to say "Thanks for posting this".