;;; ring.cl ;;; ring modulation module for Mantra ;;; parameters for the controls (defparameter ring-on-off 1300) (defparameter ring-mod-amp 1301) (defparameter ring-mod-frq 1302) (defparameter ring-in-amp 1303) (defparameter ring-out-amp 1304) (defparameter ring-direct 1305) ;;; instrument (defpinstrument ring (&key (tester nil)) (let* ((modulator (make-oscil :frequency 1.0)) (mod-amp-f (make-fcontrol ring-mod-amp)) (mod-frq-f (make-fcontrol ring-mod-frq)) (in-amp-f (make-fcontrol ring-in-amp)) (direct-f (make-fcontrol ring-direct)) (out-amp-f (make-fcontrol ring-out-amp))) (run (loop for i from 0 do (when (= (control ring-on-off) 0.0)(loop-finish)) (setf (frequency modulator) (fcontrol mod-frq-f)) (let* ((in-val (* (fcontrol in-amp-f)(rec-any 0))) ;;; input signal (mod-val (* (fcontrol mod-amp-f)(oscil modulator))) ;;; modulated signal (out-val (+ (* (fcontrol direct-f) in-val) (ring-modulate in-val mod-val)))) ;;; output signal (outa i (* (fcontrol out-amp-f) out-val)) (if tester (setf (tester-in) out-val)))))))The control panel has sliders to control modulation amplitude, scaled between 0.0 or no modulation to 1.0 or maximum modulation; modulation frequency with a range from 1.0 to 1000.0 Hertz; direct signal level, input amplitude and output amplitude.
;;; control panel for ring (make-controller "ring" 2048 '(ring-on-off "on/off" :toggle t) '(ring-mod-amp "mod-amp" :slider 0.0 1.0) '(ring-mod-frq "mod-frq" :slider 1.0 1000.0) '(ring-in-amp "in-amp" :slider 0.0 1.0) '(ring-direct "direct" :slider 0.0 1.0) '(ring-out-amp "out-amp" :slider 0.0 1.0))
(open-controls 2048)Now you can start the GUI in an Xterm, remember to start the tester as well!
ring &If you are using the tester you can see the side bands of the modulated signal on the FFT graphic (you can try whistling into the mic to have a clearer image of them).
;;; ring called with tester (with-psound (:srate 22050 :rec-line 0 :rec-chans 1 :bufsize 512) (tester)(ring :tester t))