Main Page       Index


strpad.lsp


 strpad.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 String ensemble instrument


wrapper

strpad

 (strpad   plist dur [:vel][:arpeg][:r][:r2][:vib][:vrate][:vdelay][:attack][:release][:vel])
 A rather complex "pad" instrument.

 The basic sound is produced by linearly fading between wave tables. The
 initial timbre, which is very rich in harmonics linearly fades out while
 the second timbre (a band limited sawtooth) fades up. The cross fade
 function is fixed and has no user parameters. However, the relative
 frequencies of the two tones may be altered and there is a complex vibrato
 waveform with randomized frequency. Odd and even numbered notes (in plst)
 are panned to opposite positions in the stereo field. By default there is a
 very slight arpeggio which smears the individual attacks. There is also a
 global (static) low-pass filter tied to the velocity parameter.

 plst     - list or sound. List of MIDI key number to be produced. 
            Alternately an individual key number may be specified. Odd and 
            even number key numbers are panned to opposite sides of the 
            stereo field.

 dur      - flonum. The tones duration in seconds.

 :r       - flonum. The frequency of the initial timbre relative to the key
            number. For r!=1 the effect is a transposition. Default 1.0

 :r2      - flonum. The relative frequency of the second timbre to the first
            timbre. Note the different uses of r and r2. r is relative to 
            the key number and r2 is relative to r. Default 1.006

 :vib     - flonum. Vibrato depth. 0<=vib<=127, Default 16

 :vrate   - flonum. Vibrato frequency. The actual frequency is randomized
            by +/-10%. The vibrato waveform has a very strong 8th harmonic, 
            the vrate argument is scaled by 1/8 so that the perceived 
            vibrato frequency is approximately vrate. Default 8.00

 :vdelay  - flonum. Vibrato delay time. Default 0.333 seconds.

 :attack  - flonum. Amplitude attack time, Default 0.333 seconds

 :release - flonum. Amplitude release time. Default 1.5 seconds.

 :vel     - flonum. MIDI velocity value. The velocity controls a static
            low-pass filter with a cutoff between 200 and 3KHz. For the 
            default velocity of 64 the cutoff is approx 1.6K
 
 :arpeg   - flonum. Time between iteration of notes in plist, Default 0.050

 return   - sound vector.


View the Sourcecode :



;; strpad.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 String ensemble instrument
;; 

(require 'definst)
(require 'math)
(require 'wtab)
(require 'saw-16)
(require 'dlfo)
(require 'map)
(require 'map-vibrato)
(provide 'strpad)
(current-file "strpad")


(setq strpad:*vmap* (map:linear 200 3000))


(setq strpad:*mod-tab*  (wtab:make '(( 3 0.255)( 8 1.000)) 1024)

      strpad:*trn-tab*  (wtab:make '(( 1 1.000)( 2 1.000)
				      ( 3 1.000)( 4 1.000)
				      ( 5 0.750)( 6 0.750)
				      ( 7 0.750)( 8 0.750)
				      (11 0.330)(12 0.330)
				      (13 0.125)(14 0.125)
				      (15 0.125)(16 0.125)))

      strpad:*sus-tab*  *saw-16*
      )


;; Version of dlfo with random frequency variations. The waveform
;; is non-sinusoidal with a predominate 8th harmonic and a secondary 3rd
;; harmonic.
;; frq - Signals fundamental frequency. The actual frequency is randomized
;; by +/- 10%
;; dur - Signals duration
;; delay - onset delay time, default 0.333
;; attack - attack time, default 0.333
;; tab - wave table, default strong 8 and 3, no fundamental
;; random - randomization percentage, default 0.1
;; phase - phase angle,. default 'RND
;;

(defun strpad:lfo  (frq dur &key delay attack tab random phase)
  (let* ((delay (or delay 0.333))
	 (attack (or attack 0.3333))
	 (tab (or tab strpad:*mod-tab*))
	 (rndoff (* frq (or random 0.10)))
	 (flo (- frq rndoff))
	 (fhi (+ frq rndoff))
	 (frq (rndr flo fhi)))
    (dlfo frq dur :tab tab :phase phase :delay delay :attack attack)))


;; An oscillator which cross mixes between two wave tables.
;; pitch - MIDI key number
;; dur - The tones duration. 
;; r - Frequency ratio of first tone to pitch, default 1.0
;; r2 - Frequency ratio of second tone to first tone, default 1.006
;; vib - Vibrato depth. 0<=vib<=127, default 16
;;
;; vrate - Vibrato rate, The vibrato signal is complex with strong 8th nd 3rd
;; harmonics and no fundamental. The actual rate is randomized by +/10% and
;; the vrate value is scaled by 1/8 so that the perceived vibrato frequency is
;; approximately vrate.
;;
;; vdelay - vibrato delay time
;;
;; The oscillator linearly fades out the initial tone (a very bright timbre)
;; while simultaneously fading in the second tone (a band-limited
;; sawtooth). By virtual of r2~=1 but r2!=1 and the random vibrato a
;; fairly complex tone results.
;;

(defun strpad:osc (pitch dur &key r r2 vib vrate vdelay)
  (let* ((r (or r 1.000))
	 (r2 (* r (or r2 1.006)))
	 (hz (* r (step-to-hz pitch)))
	 ;(vamp (* (or vib 1.000) 0.01000))
	 (vamp (map:vibrato hz (or vib 16)))
	 (vrate (* (or vrate 8.00) 0.125))
	 (env1 (ramp dur))
	 (env2 (iramp dur))
	 (vsig (scale vamp (strpad:lfo vrate dur :delay vdelay :phase 'RND)))
	 (p1 (hz-to-step hz))
	 (p2 (hz-to-step (* r r2 (step-to-hz pitch)))))
    (sum (mult (fmosc p2 vsig strpad:*sus-tab*) env1)
	 (mult (fmosc p1 vsig strpad:*trn-tab*) env2))))


(defun strpad:voice (pitch dur &key r r2 vib vrate vdelay attack release)
  (let* ((attack (or attack 0.333))
	 (decay 0.555)
	 (release (or release 1.5)))
    (mult (strpad:osc pitch dur :r2 r2 :r r :vib vib :vrate vrate :vdelay vdelay)
	  (adsr attack decay 0 release 0.8 dur))))


;; @doc wrapper strpad
;; (strpad   plist dur [:vel][:arpeg][:r][:r2][:vib][:vrate][:vdelay][:attack][:release][:vel])
;; A rather complex "pad" instrument.
;;
;; The basic sound is produced by linearly fading between wave tables. The
;; initial timbre, which is very rich in harmonics linearly fades out while
;; the second timbre (a band limited sawtooth) fades up. The cross fade
;; function is fixed and has no user parameters. However, the relative
;; frequencies of the two tones may be altered and there is a complex vibrato
;; waveform with randomized frequency. Odd and even numbered notes (in plst)
;; are panned to opposite positions in the stereo field. By default there is a
;; very slight arpeggio which smears the individual attacks. There is also a
;; global (static) low-pass filter tied to the velocity parameter.
;;
;; plst     - list or sound. List of MIDI key number to be produced. 
;;            Alternately an individual key number may be specified. Odd and 
;;            even number key numbers are panned to opposite sides of the 
;;            stereo field.
;;
;; dur      - flonum. The tones duration in seconds.
;;
;; :r       - flonum. The frequency of the initial timbre relative to the key
;;            number. For r!=1 the effect is a transposition. Default 1.0
;;
;; :r2      - flonum. The relative frequency of the second timbre to the first
;;            timbre. Note the different uses of r and r2. r is relative to 
;;            the key number and r2 is relative to r. Default 1.006
;;
;; :vib     - flonum. Vibrato depth. 0<=vib<=127, Default 16
;;
;; :vrate   - flonum. Vibrato frequency. The actual frequency is randomized
;;            by +/-10%. The vibrato waveform has a very strong 8th harmonic, 
;;            the vrate argument is scaled by 1/8 so that the perceived 
;;            vibrato frequency is approximately vrate. Default 8.00
;;
;; :vdelay  - flonum. Vibrato delay time. Default 0.333 seconds.
;;
;; :attack  - flonum. Amplitude attack time, Default 0.333 seconds
;;
;; :release - flonum. Amplitude release time. Default 1.5 seconds.
;;
;; :vel     - flonum. MIDI velocity value. The velocity controls a static
;;            low-pass filter with a cutoff between 200 and 3KHz. For the 
;;            default velocity of 64 the cutoff is approx 1.6K
;; 
;; :arpeg   - flonum. Time between iteration of notes in plist, Default 0.050
;;
;; return   - sound vector.
;;

(defun strpad   (plst dur &key r r2 vib vrate vdelay attack release vel arpeg)
  (setq plst (->list plst))
  (let* ((ncount (length plst))
	 (pinc (/ (or arpeg 0.050)(float ncount)))
	 (cutoff (send strpad:*vmap* :get (or vel 64)))
	 (plst1 (every-even plst))
	 (plst2 (every-odd  plst)))
    (scale-db (definst:comp ncount)
	      (sum 
	       (pan (lowpass2 (simrep (n (length plst1))
				      (at (* n 2 pinc)(cue (strpad:voice (nth n plst1) dur :r r :r2 r2
									 :vib vib :vdelay vdelay
									 :attack attack :release release))))
			      cutoff) 0.333)
	       (pan (lowpass2 (simrep (n (length plst2))
				      (at (* n 2 pinc)(cue (strpad:voice (nth n plst2) dur :r r :r2 r2
									 :vib vib :vdelay vdelay
									 :attack attack :release release))))
			      cutoff) 0.666)))))


Main Page       Index