projects
/
cluck.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
24df75e
)
r11721:
author
Kevin M. Rosenberg
<kevin@rosenberg.net>
Thu, 7 Jun 2007 04:52:28 +0000
(
04:52
+0000)
committer
Kevin M. Rosenberg
<kevin@rosenberg.net>
Thu, 7 Jun 2007 04:52:28 +0000
(
04:52
+0000)
dtmf.lisp
patch
|
blob
|
history
diff --git
a/dtmf.lisp
b/dtmf.lisp
index ef282ac554d614b449009c1644a210c2cf733e19..957281ce4f911ce3a853fd14a2157a9ca640f944 100644
(file)
--- a/
dtmf.lisp
+++ b/
dtmf.lisp
@@
-38,7
+38,7
@@
(in-package #:cluck)
(in-package #:cluck)
-(defconstant
*
+dtmf-tones+
+(defconstant +dtmf-tones+
'(
;; keypad
(1 . (1209 . 697))
'(
;; keypad
(1 . (1209 . 697))
@@
-58,10
+58,10
@@
(\# . (1477 . 941))
(D . (1633 . 941))
(\# . (1477 . 941))
(D . (1633 . 941))
- ;; event
- (busy . (
480 . 62
0))
- (dial-tone . (
350 . 44
0))
- (ringback . (4
40 . 48
0))
+ ;; event
s
+ (busy . (
620 . 48
0))
+ (dial-tone . (
440 . 35
0))
+ (ringback . (4
80 . 44
0))
))
(defun dtmf-ratios ()
))
(defun dtmf-ratios ()
@@
-79,8
+79,7
@@
;; A(low) / A(high) between 0.7 and 0.9
(defun dtmf-waveform (key duration sample-freq
;; A(low) / A(high) between 0.7 and 0.9
(defun dtmf-waveform (key duration sample-freq
- &key (min -1d0) (max 1d0)
- (element-type 'double-float)
+ &key (min -1d0) (max 1d0) (element-type 'double-float)
&aux dtmf-record)
"Returns the DTMF waveform of a key code for duration seconds
at a sample frequency of sample-freq. Waveform normalized to -1 to 1 output."
&aux dtmf-record)
"Returns the DTMF waveform of a key code for duration seconds
at a sample frequency of sample-freq. Waveform normalized to -1 to 1 output."
@@
-143,17
+142,30
@@
at a sample frequency of sample-freq. Waveform normalized to -1 to 1 output."
(format os "~F~A~F~%" time delimiter (aref wave i))
(incf time period)))))
(format os "~F~A~F~%" time delimiter (aref wave i))
(incf time period)))))
+
+;;; Functions optionally defined if supporting packages have already
+;;; been loaded
+;;;
+;;; Functions requiring CL-WAV-SYNTH, used for it WAV file writing
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (when (find-package '#:cl-wav-synth)
+ (pushnew :kmr-cl-wav-synth cl:*features*)))
+
+#+:kmr-cl-wav-synth
(defun write-dtmf-wav (file key duration &key (sample-freq 8000)
(n-bits-per-sample 8)
&aux wave)
(setq wave (dtmf-waveform key duration sample-freq
:min (ecase n-bits-per-sample
(defun write-dtmf-wav (file key duration &key (sample-freq 8000)
(n-bits-per-sample 8)
&aux wave)
(setq wave (dtmf-waveform key duration sample-freq
:min (ecase n-bits-per-sample
-
(8 -128
)
-
(16 -32768))
+
(8 0
)
+ (16 -32768))
:max (ecase n-bits-per-sample
:max (ecase n-bits-per-sample
- (8 127)
- (16 32767))
- :element-type (list 'signed-byte n-bits-per-sample)))
+ (8 255)
+ (16 32767))
+ :element-type (ecase n-bits-per-sample
+ (8 '(unsigned-byte 8))
+ (16 '(signed-byte 16)))))
(unless wave (return-from write-dtmf-wav nil))
(let ((sample (make-instance 'cl-wav-synth:sample
(unless wave (return-from write-dtmf-wav nil))
(let ((sample (make-instance 'cl-wav-synth:sample
@@
-167,7
+179,18
@@
at a sample frequency of sample-freq. Waveform normalized to -1 to 1 output."
(cl-wav-synth:write-sample file sample)
sample))
(cl-wav-synth:write-sample file sample)
sample))
-#|
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (when (find :kmr-cl-wav-synth cl:*features*)
+ (setq cl:*features* (delete :kmr-cl-wav-synth cl:*features*))))
+
+
+;;; Functions requiring CGN, a plotting package
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (when (find-package '#:cgn)
+ (pushnew :kmr-cgn cl:*features*)))
+
+#+:kmr-cgn
(defun plot-dtmf (key duration sample-freq &aux wave)
(setq wave (dtmf-waveform key duration sample-freq))
(unless wave (return-from plot-dtmf nil))
(defun plot-dtmf (key duration sample-freq &aux wave)
(setq wave (dtmf-waveform key duration sample-freq))
(unless wave (return-from plot-dtmf nil))
@@
-190,4
+213,7
@@
at a sample frequency of sample-freq. Waveform normalized to -1 to 1 output."
(cgn:set-range 'y -1 1)
(cgn:plot-points x y)
)))
(cgn:set-range 'y -1 1)
(cgn:plot-points x y)
)))
-|#
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (when (find :kmr-cgn cl:*features*)
+ (setq cl:*features* (delete :kmr-cgn cl:*features*))))