Prerequisite setup: generate a 3s mono track e.g. with Tone. Select some one second portion of it. Then try the following snippets from the Ny prompt, undoing after each one:
;version 4
;type process
(seq (mult (hzosc 333) 0.7) (mult (hzosc 999) 0.2)) ; ok
That one works as expected, i.e. it’s a generator pretending to be an fx, and is in fact a (practical) way to return longer audio than the original sample, even from an fx (“type process”). Audacity lengthens the track to accommodate the extra sound returned, e.g. the track will be 4s long after running the above.
You can make an actual effect from something like that e.g.
;version 4
;type process
(seq (mult *track* 0.7) (mult (hzosc 999) 0.2)) ; also ok
But I can’t seem to make it process the track more than once:
;version 4
;type process
(seq (mult *track* 0.7) (mult *track* 0.2)) ; error
I thought the problem might be with playback being destructive of the Lisp objects, so need a snd-copy, but alas even the following still doesn’t work:
;version 4
;type process
(seq (mult (snd-copy *track*) 0.7) (mult (snd-copy *track*) 0.2)) ; still error
The error in the debug windows is pretty lengthy, but it’s not incredibly clear what’s causing it. Probably the sound was already mutated as snd-copy is probably a shallow copy. For a simpler stack trace, just
(seq (snd-copy *track*) (snd-copy *track*))
Errors like this:
error: bad argument type - NIL
Function: #<Subr-SND-COPY: #0000022AF3B01E70>
Arguments:
NIL
Function: #<FSubr-PROGV: #0000022AF3B05290>
Arguments:
(QUOTE (*WARP*))
(LET ((TIM T0)) (NY:TYPECHECK (NOT (NUMBERP TIM)) (ERROR "1st argument of AT-ABS (or 2nd argument of SAL's @@ operator) should be a number (start time)" TIM)) (IF (WARP-FUNCTION *WARP*) (LIST (LIST (SREF-INVERSE (WARP-FUNCTION *WARP*) TIM) (WARP-STRETCH *WARP*) (WARP-FUNCTION *WARP*))) (LIST (LIST TIM (WARP-STRETCH *WARP*) NIL))))
(CHECK-T0 (FORCE-SRATES S%RATE (SND-COPY *TRACK*)) (QUOTE (FORCE-SRATES S%RATE (SND-COPY *TRACK*))))
Function: #<FSubr-PROGV: #0000022AF3B05290>
Arguments:
(QUOTE (*WARP* *SUSTAIN* *START* *LOUD* *TRANSPOSE* *STOP* *CONTROL-SRATE* *SOUND-SRATE*))
NYQ%ENVIRONMENT
(AT-ABS T0 (FORCE-SRATES S%RATE (SND-COPY *TRACK*)))
Function: #<FSubr-SETF: #0000022AF3AFD028>
Arguments:
FIRST%SOUND
(EVAL-SEQ-BEHAVIOR (SND-COPY *TRACK*) "SEQ")
Function: #<Closure: #0000022AF28EEE78>
Arguments:
1.0124
1>
Just something like
(seq (mult 0.2 (snd-copy *track*)))
works though, so it’s clearly the 2nd copy that’s causing problems.
So, is there a way to fix that and use the same track more than once in a Nyquist fx plugin?