Main Page       Index


fmop.lsp


 fmop.lsp
 Version 1.00  31 October 2004
 Author Steven Jones

 Contact jones57@swbell.net include the word "nyquist" in subject line

 The contents of this file are released under the terms of the GNU General
 Public License. See the file LICENSE.txt

 Basic FM "operators"


function

fmop:cc

 (fmop:cc   chz am fm [:tab][:phase])
 FM carrier "operator"

 chz    - flonum. Frequency of carrier in Hertz

 am     - sound. Amplitude modulation signal

 fm     - sound. Frequency modulation signal

 :tab   - table. Wave table. Default *sine-table*

 :phase - any. See phase function in utilites.lsp, default 0

 return - sound.


function

fmop:mm

 (fmop:mm   chz r i am fm [:tab][:phase])
 FM modulation "operator"

 chz    - flonum. Carrier frequency in Hertz

 r      - flonum. Modulator/Carrier ratio

 i      - flonum. Modulation index

 am     - sound. Amplitude modulation signal

 fm     - sound. Frequency modulation signal

 :tab   - table. Wave table. Default *sine-table*

 :phase - any. See phase in utilities.lsp, default 0

 return - sound.


function

fmop:format

 (fmop:format  ff f0 snd [mi])
 A format filter.

 fmop:format serves as an FM carrier with a nearly fixed frequency. The
 actual frequency tracks the input signal in such a way that it is always a
 harmonic of the signal and is as close as possible to the format frequency.

 ff     - flonum. The desired format frequency in Hertz.

 f0     - flonum. The fundamental frequency of snd in Hertz.

 snd    - sound. The signal to impart a format to. The assumption is that
          snd is harmonic.  The duration of the result is the same as snd.

 mi     - flonum. Modulation index.  For sinusoidal modulator mi is the
          modulation index. Default 1

 return - sound.


function

fm1

 (fm1  pitch dur [:r1][:t1][:env1][:r2][:t2][:env2][:i2][:vib][:vibsig])
 Single carrier/modulator FM algorithm.
 
 pitch - flonum. MIDI key number

 dur - flonum. Duration in seconds. NOTE: The duration is a used to set
 the default envelope and vibrato signal times. In use the actual duration
 is the same as the vibrato signal's duration.

 :r1     - flonum. Carrier frequency multiplier. Default 1.00

 :t1     - table. Carrier wave table. Default *sine-table*

 :env1   - sound. Carrier envelope. Default gate

 :r2     - flonum. Modulator frequency ratio. Default 1.00

 :t2     - table. Modulator wave table. Default *sine-table*

 :env2   - sound. Modulator envelope. Default gate

 :i2     - flonum. Modulation index. Default 1

 :vib    - flonum. Vibrato depth. The vibrato signal modulates both carrier
           and modulator signals. Vibrato depth is specified as MIDI 
           controller value  0<=vib<128. Default 0
 

 :vibsig - sound. Vibrato signal which is applied to all operators. 
           Default silence.

 return  - sound.


View the Sourcecode :



;; fmop.lsp
;; Version 1.00  31 October 2004
;; Author Steven Jones
;;
;; Contact jones57@swbell.net include the word "nyquist" in subject line
;;
;; The contents of this file are released under the terms of the GNU General
;; Public License. See the file LICENSE.txt
;;
;; Basic FM "operators"
;; 

(require 'map)
(require 'map-vibrato)
(provide 'fmop)
(current-file "fmop")


;; @doc function   fmop:cc
;; (fmop:cc   chz am fm [:tab][:phase])
;; FM carrier "operator"
;;
;; chz    - flonum. Frequency of carrier in Hertz
;;
;; am     - sound. Amplitude modulation signal
;;
;; fm     - sound. Frequency modulation signal
;;
;; :tab   - table. Wave table. Default *sine-table*
;;
;; :phase - any. See phase function in utilites.lsp, default 0
;;
;; return - sound.
;;

(defun fmop:cc (chz am fm &key tab phase)
    (mult (fmosc (hz-to-step chz) fm (or tab *sine-table*)(phase phase))
	  am))


;; @doc function  fmop:mm
;; (fmop:mm   chz r i am fm [:tab][:phase])
;; FM modulation "operator"
;;
;; chz    - flonum. Carrier frequency in Hertz
;;
;; r      - flonum. Modulator/Carrier ratio
;;
;; i      - flonum. Modulation index
;;
;; am     - sound. Amplitude modulation signal
;;
;; fm     - sound. Frequency modulation signal
;;
;; :tab   - table. Wave table. Default *sine-table*
;;
;; :phase - any. See phase in utilities.lsp, default 0
;;
;; return - sound.
;;

(defun fmop:mm (chz r i am fm &key tab phase)
  (let ((frq (* chz r)))
    (scale (* chz i) (fmop:cc frq am fm :tab tab :phase phase))))


;; @doc function  fmop:format
;; (fmop:format  ff f0 snd [mi])
;; A format filter.
;;
;; fmop:format serves as an FM carrier with a nearly fixed frequency. The
;; actual frequency tracks the input signal in such a way that it is always a
;; harmonic of the signal and is as close as possible to the format frequency.
;;
;; ff     - flonum. The desired format frequency in Hertz.
;;
;; f0     - flonum. The fundamental frequency of snd in Hertz.
;;
;; snd    - sound. The signal to impart a format to. The assumption is that
;;          snd is harmonic.  The duration of the result is the same as snd.
;;
;; mi     - flonum. Modulation index.  For sinusoidal modulator mi is the
;;          modulation index. Default 1
;;
;; return - sound.
;;

(defun fmop:format (ff f0 snd &optional mi)
  (let* ((n (truncate (/ ff f0)))
	 (frq (* f0 n))
	 (sigamp (* frq (or mi 1))))
    (fmosc (hz-to-step frq)(scale sigamp snd))))


;; @doc function fm1
;; (fm1  pitch dur [:r1][:t1][:env1][:r2][:t2][:env2][:i2][:vib][:vibsig])
;; Single carrier/modulator FM algorithm.
;; 
;; pitch - flonum. MIDI key number
;;
;; dur - flonum. Duration in seconds. NOTE: The duration is a used to set
;; the default envelope and vibrato signal times. In use the actual duration
;; is the same as the vibrato signal's duration.
;;
;; :r1     - flonum. Carrier frequency multiplier. Default 1.00
;;
;; :t1     - table. Carrier wave table. Default *sine-table*
;;
;; :env1   - sound. Carrier envelope. Default gate
;;
;; :r2     - flonum. Modulator frequency ratio. Default 1.00
;;
;; :t2     - table. Modulator wave table. Default *sine-table*
;;
;; :env2   - sound. Modulator envelope. Default gate
;;
;; :i2     - flonum. Modulation index. Default 1
;;
;; :vib    - flonum. Vibrato depth. The vibrato signal modulates both carrier
;;           and modulator signals. Vibrato depth is specified as MIDI 
;;           controller value  0<=vib<128. Default 0
;; 
;;
;; :vibsig - sound. Vibrato signal which is applied to all operators. 
;;           Default silence.
;;
;; return  - sound.
;;

(defun fm1  (pitch dur &key
		   r1 t1 env1
		   r2 t2 env2 i2
		   vib vibsig)
  (let* ((r1 (or r1 1.000)) 
	 (t1 (or t1 *sine-table*))
	 (env1 (or env1 (rgate dur)))
	 (r2 (or r2 1.000))
	 (t2 (or t2 *sine-table*))
	 (env2 (or env2 (rgate dur)))
	 (i2 (or i2 1.000))
	 ;(vibamp (or vib 0.00))
	 (vibamp (send map:*vibrato* :get (or vib 0)))
	 (vibsig (or vibsig (s-rest dur)))
	 (hz (step-to-hz pitch))
	 (hz1 (* r1 hz))
	 (hz2 (* r2 hz)))
    (mult (fmosc pitch (sum (scale (* vibamp hz1) vibsig)
			    (mult (fmosc (hz-to-step hz2) (scale (* vibamp hz2) vibsig) t2)
				  (scale (* hz1 i2) env2)))
		 t1)
	  env1)))


Main Page       Index