~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to plug-ins/highpass.ny

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;nyquist plug-in
2
 
;version 1
 
2
;version 3
3
3
;type process
4
4
;name "High Pass Filter..."
5
5
;action "Performing High Pass Filter..."
6
 
;control f "Cutoff frequency" real "Hz" 1000 1 rate
7
 
(hp s f)
8
 
 
 
6
;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 6 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping."
 
7
 
 
8
;control rolloff-choice "     Rolloff [dB per octave]" choice " 3 dB, 6 dB,12 dB,18 dB,24 dB" 0
 
9
;control q "     Filter quality [q] for 6 dB rolloff" real "" 0.7071 .1 20
 
10
;control f "     Cutoff frequency [Hz]" real "" 1000 1 20000
 
11
 
 
12
; note that all Nyquist highpass functions 
 
13
; [hp, highpass2, highpass4, highpass6, highpass8]
 
14
; are defined below with -s suffix.
 
15
; This enables highpass functions other than hp 
 
16
; to deal with stereo selection,
 
17
; and dummy q arg for all but highpass2 
 
18
 
 
19
; 3dB/octave
 
20
(defun hp-s (s f q) ; dummy q arg
 
21
(hp s f))
 
22
 
 
23
; 6dB/octave
 
24
(defun highpass2-s (s f q)
 
25
(if (arrayp s)
 
26
(vector (highpass2 (aref s 0) f q)
 
27
(highpass2 (aref s 1) f q))
 
28
(highpass2 s f q)))
 
29
 
 
30
; 12dB/octave
 
31
(defun highpass4-s (s f q) ; dummy q arg
 
32
(if (arrayp s)
 
33
(vector (highpass4 (aref s 0) f)
 
34
(highpass4 (aref s 1) f))
 
35
(highpass4 s f)))
 
36
 
 
37
; 18dB/octave
 
38
(defun highpass6-s (s f q) ; dummy q arg
 
39
(if (arrayp s)
 
40
(vector (highpass6 (aref s 0) f)
 
41
(highpass6 (aref s 1) f))
 
42
(highpass6 s f)))
 
43
 
 
44
; 24dB/octave
 
45
(defun highpass8-s (s f q) ; dummy q arg
 
46
(if (arrayp s)
 
47
(vector (highpass8 (aref s 0) f)
 
48
(highpass8 (aref s 1) f))
 
49
(highpass8 s f)))
 
50
 
 
51
; check function: returns 1 on error
 
52
(defun check (arg min max)
 
53
(if (and (>= arg min) (<= arg max))
 
54
0 1))
 
55
 
 
56
 
 
57
; initialize blank error-msg
 
58
(setf error-msg "")
 
59
 
 
60
; check for erroneous q value
 
61
(setf error-msg (if 
 
62
(and (= rolloff-choice 1)
 
63
(= (check q 0.1 20) 1))
 
64
(strcat error-msg (format nil
 
65
"q value ~a lies outside valid range 0.1 to 20     
 
66
for your chosen rolloff of 6 dB per octave.
 
67
" q))
 
68
error-msg))
 
69
 
 
70
; check for erroneous frequency cutoff value
 
71
(setf error-msg (if 
 
72
(= (check f 1 20000) 0)
 
73
error-msg
 
74
(strcat error-msg (format nil
 
75
"Cutoff frequency ~a Hz lies outside valid range 1 to 20000.     
 
76
" f))))
 
77
 
 
78
 
 
79
(cond
 
80
((> (length error-msg) 0)
 
81
(setf error-msg (strcat (format nil
 
82
"Error - \n\nYou have entered at least one invalid value:
 
83
") error-msg))
 
84
(format nil "~a" error-msg)) 
 
85
;
 
86
(t ; perform highpass effect
 
87
(funcall (nth rolloff-choice '(hp-s highpass2-s highpass4-s highpass6-s highpass8-s)) 
 
88
s f q)))
 
89
 
 
90
 
 
91
 
 
92
; from previous commit
9
93
; arch-tag: 49302eba-9945-43d7-aade-f1c7eded27af
10
94