Music 220B

A CLM Ring Modulation instrument

Modulation techniques

Please, visit this site for a quick review on Modulation techniques (ring modulation, amplitude modulation, etc.)

Ring modulation instrument for Mantra

In his piece Mantra, (1970) Karheinz Stockhausen uses two ring modulators to process the sound of the pianos. The following CLM instrument can be used as one of the ring modulation modules required for the piece. This instrument can process sound from the mic or line input and mix direct signal with modulated signal. We use the ring-modulate CLM function to multiply the modulator (a sinusoidal oscillator) with the carrier (any signal coming from the mic input).
;;; 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))

Playing the Ring instrument

Once ring.cl is Compiled and Loaded, remember to allocate memory for the controllers (if you haven't done this before):
(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))



©1998 by Juan Pampin,
juan@ccrma.stanford.edu