posc.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 A special case oscillator for clipped waveforms. posc uses amplitude modulation where the modulation signal is an unsigned pulse train.
function
(posc pitch [:dur][:r][:w][:fm][:am][:tab] ----- tab >-------->| O | fm >-------->| S |----------------------[VCA]---> out r >-->[*]-->| C | ^ ^ ----- | | | | | | -------- | pitch >----->|PULSE |---->[VCA]---------->[+] w >----->|OSC | ^ ^ -------- | | am >----------------------->[*]-->[+]---- ^ ^ | | -1 +1 pitch - flonum. Frequency of modulator (pulse osc) as MIDI note number :dur - flonum. Duration :r - Carrier / modulator frequency ratio :w - Pulse width. (by default w=1/r for r >1 and w=r for r < 1 :fm - FM modulator signal for carrier oscillator. :am - sound. AM modulation depth. The interaction between the pulse oscillator and the am signal are complex. Basically when AM is high (~1) the pulse oscillator is amplitude modulating the main oscillator. When am is low (~0) the primary oscillator signal is passed to the output unchanged. Thus there is always some output. The am signal serves as a timbre control and does not directly effect the output amplitude. It should be positive only and have amplitude in interval [0,1]. :tab - table. Main oscilator wave table. Default *sine-table*
;; posc.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 ;; ;; A special case oscillator for clipped waveforms. posc uses amplitude ;; modulation where the modulation signal is an unsigned pulse train. ;; (require 'wtab) (provide 'posc) (current-file "posc") (defun posc:xenv (sig dur) (sum (scale -1 sig)(rgate dur 1))) ;; @doc function posc ;; (posc pitch [:dur][:r][:w][:fm][:am][:tab] ;; ;; ----- ;; tab >-------->| O | ;; fm >-------->| S |----------------------[VCA]---> out ;; r >-->[*]-->| C | ^ ;; ^ ----- | ;; | | ;; | | ;; | -------- | ;; pitch >----->|PULSE |---->[VCA]---------->[+] ;; w >----->|OSC | ^ ^ ;; -------- | | ;; am >----------------------->[*]-->[+]---- ;; ^ ^ ;; | | ;; -1 +1 ;; ;; pitch - flonum. Frequency of modulator (pulse osc) as MIDI note number ;; ;; :dur - flonum. Duration ;; ;; :r - Carrier / modulator frequency ratio ;; ;; :w - Pulse width. (by default w=1/r for r >1 and w=r for r < 1 ;; ;; :fm - FM modulator signal for carrier oscillator. ;; ;; :am - sound. AM modulation depth. The interaction between the pulse ;; oscillator and the am signal are complex. Basically when AM ;; is high (~1) the pulse oscillator is amplitude modulating the ;; main oscillator. When am is low (~0) the primary oscillator signal ;; is passed to the output unchanged. Thus there is always some ;; output. The am signal serves as a timbre control and does not ;; directly effect the output amplitude. It should be positive only ;; and have amplitude in interval [0,1]. ;; ;; :tab - table. Main oscilator wave table. Default *sine-table* ;; (defun posc (pitch &key dur r w fm am tab) (let* ((dur (or dur 1.00)) (r (or r 2.0)) (w (or w (if (> r 1) (/ (float r)) r))) (fm (or fm (rgate dur 0))) (am (or am (rgate dur 1))) (tab (or tab *sine-table*)) (mfrq (step-to-hz pitch)) (cfrq (* mfrq r)) (mtab (wtab:pulse w 0 1))) (mult (fmosc (hz-to-step cfrq) fm tab) (sum (mult (sim (osc pitch dur mtab)) am) (posc:xenv am dur )))))