The problem seems to be with the Audacity implementation of Nyquist. Below is my plug-in which illustrates the problem. For testing it in Audacity, copy the code below to a file in the Audacity 1.3.7 plug-ins directory called Storer-phaser.ny.
In audacity, create a stereo track 20 seconds long with a 250Hz tone.
Split the left and right channels, select the left channel, and run the plug-in below. By renaming it with a .lsp extension instead of .ny, and commenting or uncommenting a few lines as noted, you can run the same code in stand-alone Nyquist. The stand-alone version works, the Audacity one does not. To make the Audacity version run correctly, set the fudge-factor, called Scale, to 48 and re-run it. Now it matches closely the stand-alone version's output.
I don't have access to a development system, so I can't try it in 1.3.8.
Dave
Here's the plug-in code:
;;=======================================
;nyquist plug-in
;version 3
;type process
;categories "GeneratorPlugin"
;name "Test Phase Shifter"
;action "Testing Phaser"
;info "Test harness for tapv"
;control Frequency "Signal Frequency" real "Hz" 1000 0 2000
;control Lfo-freq "LFO Frequency" real "Hz" 1 0.01 20
;control Min-Phase "Minimum Phase" real "Degrees" 0.0 0.0 360.0
;control Max-phase "Maximum Phase" real "Degrees" 0.0 0.0 360.0
;control Scale "Scale LFO" real "fraction" 1.0 0.0 100.0
;control Tone-Length "Tone Length" real "Seconds" 30.0 0.0 100.0
;;;
;;; For Stand-alone Nyquist, uncomment the following six lines.
;;;
;(setf Frequency 250.0)
;(setf Lfo-freq 0.25)
;(setf Min-Phase 45.0)
;(setf Max-phase 135.0)
;(setf Scale 1.0)
;(setf Tone-Length 20.0)
(defun my-shifter (s)
(setf Max-phase (float Max-phase))
(setf Min-phase (float Min-phase))
(setf Pd (recip (float Frequency)))
(setf Pd-x-Pd (/ Pd 360.0))
(setf Depth (/ (- Max-phase Min-phase) 2.0 ))
(setf Depth-x-Pd (* Depth Pd-x-Pd))
(setf Fixed (/ (+ Max-phase Min-phase) 2.0 ))
(setf Fixed-x-Pd (* Fixed Pd-x-Pd))
(snd-tapv s Fixed-x-Pd (mult scale Depth-x-Pd (lfo Lfo-freq Tone-Length *table* 270)) Pd)
)
;;;
;;; For Stand-Alone Nyquist, uncomment the following line and comment out the line marked ;; Audacity-nyquist
;(play (vector (stretch Tone-Length (hzosc Frequency)) (my-shifter (stretch Tone-Length (hzosc Frequency)))))
(my-shifter s) ;; Audacity-nyquist
;;=======================================
>> Roger Dannenberg wrote:
I think your calculations are right and it looks like tapv is working as
predicted. Here's what I tried:
(defun test ()
(vector (hzosc 1000.0)
(shifter (hzosc 1000.0))))
(defun shifter (s)
(snd-tapv s (* 0.001 (/ 60.0 360.0)) (mult (* 0.001 (/ 30.0 360.0))
(lfo 1.0)) 0.001))
(play (test))
Viewing this in Audacity, I can see a small phase shift with maximum
shift 1/4 of the way through and minimum at 3/4 as you would expect
since the lfo rises to a peak of 1 after 1/4 cycle and to -1 at 3/4 cycle.
-Roger
------------------------------------------------------------------------------
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist