pipe.lsp Version 1.00 14 November 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 An instrument based on parallel narrow-band noise.
function
(pipe:voice pitch dur [:vel][:ffn][:afn][:bw][:attack][:decay][:env][:vib][:vrnd][:vfrq][:vdelay][:vtab][:vphase][:fm]) A monophonic instrument which generates tones by mixing bands of noise which are harmonically related. pitch - flonum. MIDI key number. dur - flonum. Duration in seconds. :vel - flonum. MIDI velocity controls number of harmonics. vel 0 --> 1 vel 128 --> 16 The higher the velocity the greater the computation time. default 64 --> 8 :ffn - closure. Relative frequency as function of harmonic index. Default (lambda (j hz)(* j hz)) Where j is harmonic number 1 2 3 ... n and hz is fundamental frequency in Hertz :afn - closure. Relative amplitude as function of harmonic index Default (lambda (j)(/ 1.0 j)) Where j is harmonic number 1 2 3 ... n :bw - flonum. Each "harmonic" is actually a band of noise centered at the harmonic's frequency. By default the band width is a function of pitch with lower pitches having narrow band widths. The bw argument may be used to set an explicit band width. Default nil :attack - flonum. Attack time in seconds, The basic tone has a somewhat slow natural attack. Setting attack values faster then the natural value will have no effect. Default 0.1 :decay - flonum. Decay time in seconds, default 0.5 :env - sound. Alternate amplitude envelope. If specified the attack and decay arguments are ignored. Default nil :vib - flonum. MIDI vibrato depth, default 0 :vrnd - flonum. Amount of random value added to vibrato frequency. Default 1.0 :vfrq - flonum. Vibrato frequency in Hertz. If vrnd != 0 the actual frequency will be randomly varied around vfrq, default 5 :vdelay - flonum. Vibrato delay, default 0 :vtab - table. Vibrato wave table, default *tri-table* :vphase - any. Vibrato phase, see phase function in utilities.lsp default 'RANDOM :fm - sound. Optional fm modulator, default silence. return - sound.
wrapper
(pipe:voice plst dur [:vel][:arpeg][:pos][:ffn][:afn][:bw][:attack][:decay][:env][:vib][:vrnd][:vfrq][:vdelay][:vtab][:vphase][:fm]) A polyphonic instrument which generates tones by mixing harmonically related bands of noise. The number of component tones generated is a function of the length of plst and the velocity. Computation time increases with higher velocities. plst - list flonum. MIDI key number(s). dur - flonum. Duration in seconds. :arpeg - flonum. Arpeggio interval. Default 0 sec. :pos - flonum or sound. Pan position, default 0.5 :vel - flonum. MIDI velocity controls number of harmonics. vel 0 --> 1 vel 128 --> 16 The higher the velocity the greater the computation time. default 64 --> 8 :ffn - closure. Relative frequency as function of harmonic index. Default (lambda (j hz)(* j hz)) Where j is harmonic number 1 2 3 ... n and hz is fundamental frequency in Hertz :afn - closure. Relative amplitude as function of harmonic index Default (lambda (j)(/ 1.0 j)) Where j is harmonic number 1 2 3 ... n :bw - flonum. Each "harmonic" is actually a band of noise centered at the harmonics frequency. By default the band width is a function of pitch with lower pitches having narrow band widths. The bw argument may be used to set an explicit band width. Default nil :attack - flonum. Attack time in seconds, The basic tone has a somewhat slow natural attack. Setting attack values faster then the natural value will have no effect. Default 0.1 :decay - flonum. Decay time in seconds, default 0.5 :env - sound. Alternate amplitude envelope. If specified the attack and decay arguments are ignored. Default nil :vib - flonum. MIDI vibrato depth, default 0 :vrnd - flonum. Amount of random value added to vibrato frequency. Default 1.0 :vfrq - flonum. Vibrato frequency in Hertz. If vrnd != 0 the actual frequency will be randomly varied around vfrq, default 5 :vdelay - flonum. Vibrato delay, default 0 :vtab - table. Vibrato wave table, default *tri-table* :vphase - any. Vibrato phase, see phase function in utilities.lsp default 'RANDOM :fm - sound. Optional fm modulator, default silence. return - sound.
;; pipe.lsp ;; Version 1.00 14 November 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 ;; ;; An instrument based on parallel narrow-band noise. ;; (require 'rmband) (require 'dlfo) (require 'map) (require 'vel-vibrato) (require 'definst) (provide 'pipe) (current-file "pipe") (setq pipe:*n-map* (send map:functional :new #'(lambda (i)(truncate (max 1 (* i 0.125)))))) (setq pipe:*bw-map* (send map:functional :new #'(lambda (i)(+ (* 0.012 i i) 0.988)))) ;; @doc function pipe:voice ;; (pipe:voice pitch dur [:vel][:ffn][:afn][:bw][:attack][:decay][:env][:vib][:vrnd][:vfrq][:vdelay][:vtab][:vphase][:fm]) ;; A monophonic instrument which generates tones by mixing bands of noise which ;; are harmonically related. ;; ;; pitch - flonum. MIDI key number. ;; ;; dur - flonum. Duration in seconds. ;; ;; :vel - flonum. MIDI velocity controls number of harmonics. ;; vel 0 --> 1 ;; vel 128 --> 16 ;; The higher the velocity the greater the computation time. ;; default 64 --> 8 ;; ;; :ffn - closure. Relative frequency as function of harmonic index. ;; Default (lambda (j hz)(* j hz)) ;; Where j is harmonic number 1 2 3 ... n and ;; hz is fundamental frequency in Hertz ;; ;; :afn - closure. Relative amplitude as function of harmonic index ;; Default (lambda (j)(/ 1.0 j)) ;; Where j is harmonic number 1 2 3 ... n ;; ;; :bw - flonum. Each "harmonic" is actually a band of noise centered at ;; the harmonic's frequency. By default the band width is a function ;; of pitch with lower pitches having narrow band widths. The bw ;; argument may be used to set an explicit band width. Default nil ;; ;; :attack - flonum. Attack time in seconds, The basic tone has a somewhat ;; slow natural attack. Setting attack values faster then the ;; natural value will have no effect. Default 0.1 ;; ;; :decay - flonum. Decay time in seconds, default 0.5 ;; ;; :env - sound. Alternate amplitude envelope. If specified the attack and ;; decay arguments are ignored. Default nil ;; ;; :vib - flonum. MIDI vibrato depth, default 0 ;; ;; :vrnd - flonum. Amount of random value added to vibrato frequency. ;; Default 1.0 ;; ;; :vfrq - flonum. Vibrato frequency in Hertz. If vrnd != 0 the actual ;; frequency will be randomly varied around vfrq, default 5 ;; ;; :vdelay - flonum. Vibrato delay, default 0 ;; ;; :vtab - table. Vibrato wave table, default *tri-table* ;; ;; :vphase - any. Vibrato phase, see phase function in utilities.lsp ;; default 'RANDOM ;; ;; :fm - sound. Optional fm modulator, default silence. ;; ;; return - sound. ;; (defun pipe:voice (pitch dur &key vel ffn afn bw attack decay env vib vrnd vfrq vdelay vtab vphase fm) (let* ((hz (step-to-hz pitch)) (vel (or vel 64)) (ffn (or ffn #'(lambda (j hz)(* j hz)))) (afn (or afn #'(lambda (j)(/ 1.0 j)))) (bwf (if bw #'(lambda (j) bw) #'(lambda (j)(send pipe:*bw-map* :get j)))) (attack (or attack 0.1)) (decay (or decay 0.5)) (vamp (map:vibrato hz (or vib 0))) (vfrq (or vfrq 5)) (vfrqvar (* vfrq (rnd)(or vrnd 1.0))) (vdelay (or vdelay 0)) (vattack (* 0.25 vdelay)) (vtab (or vtab *tri-table*)) (vphase (or vphase 'random)) (fm (or fm (s-rest)))) (mult (rmband:harmonic pitch dur :n (send pipe:*n-map* :get vel) :bwfn bwf :rffn ffn :rafn afn :modsig (sum (scale vamp (dlfo (+ vfrq vfrqvar) dur :delay vdelay :attack vattack :tab vtab :phase (phase vphase))) fm)) (or env (asd attack (max 0 (- dur attack decay)) decay))))) ;; @doc wrapper pipe ;; (pipe:voice plst dur [:vel][:arpeg][:pos][:ffn][:afn][:bw][:attack][:decay][:env][:vib][:vrnd][:vfrq][:vdelay][:vtab][:vphase][:fm]) ;; A polyphonic instrument which generates tones by mixing harmonically ;; related bands of noise. The number of component tones generated is a ;; function of the length of plst and the velocity. Computation time increases ;; with higher velocities. ;; ;; plst - list flonum. MIDI key number(s). ;; ;; dur - flonum. Duration in seconds. ;; ;; :arpeg - flonum. Arpeggio interval. Default 0 sec. ;; ;; :pos - flonum or sound. Pan position, default 0.5 ;; ;; :vel - flonum. MIDI velocity controls number of harmonics. ;; vel 0 --> 1 ;; vel 128 --> 16 ;; The higher the velocity the greater the computation time. ;; default 64 --> 8 ;; ;; :ffn - closure. Relative frequency as function of harmonic index. ;; Default (lambda (j hz)(* j hz)) ;; Where j is harmonic number 1 2 3 ... n and ;; hz is fundamental frequency in Hertz ;; ;; :afn - closure. Relative amplitude as function of harmonic index ;; Default (lambda (j)(/ 1.0 j)) ;; Where j is harmonic number 1 2 3 ... n ;; ;; :bw - flonum. Each "harmonic" is actually a band of noise centered at ;; the harmonics frequency. By default the band width is a function ;; of pitch with lower pitches having narrow band widths. The bw ;; argument may be used to set an explicit band width. Default nil ;; ;; :attack - flonum. Attack time in seconds, The basic tone has a somewhat ;; slow natural attack. Setting attack values faster then the ;; natural value will have no effect. Default 0.1 ;; ;; :decay - flonum. Decay time in seconds, default 0.5 ;; ;; :env - sound. Alternate amplitude envelope. If specified the attack and ;; decay arguments are ignored. Default nil ;; ;; :vib - flonum. MIDI vibrato depth, default 0 ;; ;; :vrnd - flonum. Amount of random value added to vibrato frequency. ;; Default 1.0 ;; ;; :vfrq - flonum. Vibrato frequency in Hertz. If vrnd != 0 the actual ;; frequency will be randomly varied around vfrq, default 5 ;; ;; :vdelay - flonum. Vibrato delay, default 0 ;; ;; :vtab - table. Vibrato wave table, default *tri-table* ;; ;; :vphase - any. Vibrato phase, see phase function in utilities.lsp ;; default 'RANDOM ;; ;; :fm - sound. Optional fm modulator, default silence. ;; ;; return - sound. ;; (defwrapper pipe #'pipe:voice)