home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Multimedia / audacity-macosx-ub-2.0.0.dmg / Audacity / plug-ins / highpass.ny < prev    next >
Encoding:
Audacity Nyquits plug-in  |  2012-03-03  |  2.9 KB  |  100 lines

  1. ;nyquist plug-in
  2. ;version 3
  3. ;type process
  4. ;categories "http://lv2plug.in/ns/lv2core#HighpassPlugin"
  5. ;name "High Pass Filter..."
  6. ;action "Performing High Pass Filter..."
  7. ;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\nAttenuates frequencies below your specified cutoff frequency.\nHigher rolloff values give a sharper attenuation of frequencies below\nthe cutoff frequency. If using a rolloff of 12 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping."
  8.  
  9. ;control rolloff-choice "     Rolloff [dB per octave]" choice "  6 dB,12 dB,24 dB,36 dB,48 dB" 0
  10. ;control q "     Filter quality [q] for 12 dB rolloff" real "" 0.7071 .1 20
  11. ;control f "     Cutoff frequency [Hz]" real "" 1000 1 20000
  12.  
  13. ; note that all Nyquist highpass functions 
  14. ; [hp, highpass2, highpass4, highpass6, highpass8]
  15. ; are defined below with -s suffix.
  16. ; This enables highpass functions other than hp 
  17. ; to deal with stereo selection,
  18. ; and dummy q arg for all but highpass2 
  19.  
  20. ; 6dB/octave
  21. (defun hp-s (s f q) ; dummy q arg
  22. (hp s f))
  23.  
  24. ; 12dB/octave
  25. (defun highpass2-s (s f q)
  26. (if (arrayp s)
  27. (vector (highpass2 (aref s 0) f q)
  28. (highpass2 (aref s 1) f q))
  29. (highpass2 s f q)))
  30.  
  31. ; 24dB/octave
  32. (defun highpass4-s (s f q) ; dummy q arg
  33. (if (arrayp s)
  34. (vector (highpass4 (aref s 0) f)
  35. (highpass4 (aref s 1) f))
  36. (highpass4 s f)))
  37.  
  38. ; 36dB/octave
  39. (defun highpass6-s (s f q) ; dummy q arg
  40. (if (arrayp s)
  41. (vector (highpass6 (aref s 0) f)
  42. (highpass6 (aref s 1) f))
  43. (highpass6 s f)))
  44.  
  45. ; 48dB/octave
  46. (defun highpass8-s (s f q) ; dummy q arg
  47. (if (arrayp s)
  48. (vector (highpass8 (aref s 0) f)
  49. (highpass8 (aref s 1) f))
  50. (highpass8 s f)))
  51.  
  52. ; check function: returns 1 on error
  53. (defun check (arg min max)
  54. (if (and (>= arg min) (<= arg max))
  55. 0 1))
  56.  
  57.  
  58. ; initialize blank error-msg
  59. (setf error-msg "")
  60.  
  61. ; check for erroneous q value
  62. (setf error-msg (if 
  63. (and (= rolloff-choice 1)
  64. (= (check q 0.1 20) 1))
  65. (strcat error-msg (format nil
  66. "q value ~a lies outside valid range 0.1 to 20     
  67. for your chosen rolloff of 12 dB per octave.~%
  68. " q))
  69. error-msg))
  70.  
  71. ;; check for erroneous frequency cutoff value
  72. (cond ((< f 1)
  73.        (setf error-msg
  74.           (strcat error-msg (format nil
  75.             "Cutoff frequency is set at ~a Hz~%but must be at least 1 Hz." f))))
  76.       ((> f (truncate (/ *sound-srate* 2.0)))
  77.        (setf error-msg
  78.           (strcat error-msg (format nil
  79.             "Cutoff frequency is set at ~a Hz but must not~%~
  80.             be greater than ~a Hz (half of the track sample rate)."
  81.             f (truncate (/ *sound-srate* 2.0)))))))
  82.  
  83.  
  84. (cond
  85. ((> (length error-msg) 0)
  86. (setf error-msg (strcat (format nil
  87. "Error.~%You have entered at least one invalid value:~%
  88. ") error-msg))
  89. (format nil "~a" error-msg)) 
  90. ;
  91. (t ; perform highpass effect
  92. (funcall (nth rolloff-choice '(hp-s highpass2-s highpass4-s highpass6-s highpass8-s)) 
  93. s f q)))
  94.  
  95.  
  96.  
  97. ; from previous commit
  98. ; arch-tag: 49302eba-9945-43d7-aade-f1c7eded27af
  99.  
  100.