mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-12 07:35:51 +01:00
Steve's new replacement http://bugzilla.audacityteam.org/attachment.cgi?id=299, for http://bugzilla.audacityteam.org/show_bug.cgi?id=554
This commit is contained in:
@@ -59,10 +59,10 @@
|
||||
(sqr (mult (aref s 1)(aref s 1)))
|
||||
(avgsq (mult 0.5 (sum sql sqr)))
|
||||
(avgsq (snd-avg avgsq number number op-average)))
|
||||
(linear-to-db (peak (snd-sqrt avgsq) 1)))
|
||||
(lin-to-db (peak (snd-sqrt avgsq) 1)))
|
||||
(let* ((sndsq (mult snd snd))
|
||||
(avgsq (snd-avg sndsq number number op-average)))
|
||||
(linear-to-db (peak (snd-sqrt avgsq) 1)))))
|
||||
(lin-to-db (peak (snd-sqrt avgsq) 1)))))
|
||||
|
||||
|
||||
;;; dc off-set mono
|
||||
@@ -79,9 +79,9 @@
|
||||
(if (arrayp sig)
|
||||
(let ((lin0 (dc-off-mon (aref sig 0) number))
|
||||
(lin1 (dc-off-mon (aref sig 1) number)))
|
||||
(list lin0 (linear-to-db (abs lin0)) lin1 (linear-to-db (abs lin1))))
|
||||
(list lin0 (lin-to-db (abs lin0)) lin1 (lin-to-db (abs lin1))))
|
||||
(let ((lin (dc-off-mon sig number)))
|
||||
(list lin (linear-to-db (abs lin))))))
|
||||
(list lin (lin-to-db (abs lin))))))
|
||||
|
||||
|
||||
(defun checknumber ()
|
||||
@@ -105,6 +105,14 @@
|
||||
(char= #\\ *file-separator*))
|
||||
|
||||
|
||||
;;; Windows safe linear-to-db
|
||||
(setf ln10over20 (/ (log 10.0) 20))
|
||||
(defun lin-to-db (val)
|
||||
(if (= val 0)
|
||||
"[-inf]"
|
||||
(/ (log val) ln10over20)))
|
||||
|
||||
|
||||
;;; Check if Mac
|
||||
(defun macp ()
|
||||
(string-equal (subseq (get-env "HOME") 0 6) "/Users"))
|
||||
@@ -128,7 +136,7 @@
|
||||
;;; get sample and convert to dB if required
|
||||
(defun snd-get (snd &optional (dB 0))
|
||||
(if (= dB 0) ; dB scale
|
||||
(linear-to-db (abs (snd-fetch snd)))
|
||||
(lin-to-db (abs (snd-fetch snd)))
|
||||
(snd-fetch snd))) ; linear scale
|
||||
|
||||
|
||||
@@ -278,6 +286,18 @@
|
||||
|
||||
|
||||
(defun normhead ()
|
||||
(if (= fileformat 4) ; html
|
||||
(format nil
|
||||
"~a ~a~%~aSample Rate: ~a Hz.~%Length processed: ~a samples ~a seconds.~a"
|
||||
filename ; file name
|
||||
(get 'info 'channels) ; mono/stereo
|
||||
(get 'info 'chan-order) ; Channel Order
|
||||
(get 'info 'srate) ; sample rate
|
||||
number ; number of samples
|
||||
(get 'info 'duration) ; duration (seconds)
|
||||
(if (> (length optext)0)
|
||||
(format nil "~%~a~%~%~%" optext) ; optional text
|
||||
(format nil "~%~%~%"))) ; no optional text
|
||||
(format nil
|
||||
"~a ~a~%~aSample Rate: ~a Hz. Sample values on ~a scale.~%~
|
||||
Length processed: ~a samples ~a seconds.~a"
|
||||
@@ -290,7 +310,7 @@ Length processed: ~a samples ~a seconds.~a"
|
||||
(get 'info 'duration) ; duration (seconds)
|
||||
(if (> (length optext)0)
|
||||
(format nil "~%~a~%~%~%" optext) ; optional text
|
||||
(format nil "~%~%~%")))) ; no optional text
|
||||
(format nil "~%~%~%"))))) ; no optional text
|
||||
|
||||
|
||||
(defun fullhead ()
|
||||
@@ -306,7 +326,7 @@ DC offset: ~a~a"
|
||||
number ; number of samples
|
||||
(get 'info 'duration) ; duration (seconds)
|
||||
(setq smax (stereomax s)) ; peak amplitude linear
|
||||
(linear-to-db smax) ; peak amplitude dB
|
||||
(lin-to-db smax) ; peak amplitude dB
|
||||
(srms s) ; rms
|
||||
(let ((vals (dc-off s))) ; DC offset
|
||||
(if (= (length vals) 2) ; mono
|
||||
@@ -431,7 +451,7 @@ ul {
|
||||
(get 'info 'duration) ; duration (seconds)
|
||||
(get 'info 'srate) ; sample rate
|
||||
(setq smax (stereomax s)) ; peak amplitude linear
|
||||
(linear-to-db smax) ; peak amplitude dB
|
||||
(lin-to-db smax) ; peak amplitude dB
|
||||
(srms s) ; rms
|
||||
(let ((vals (dc-off s))) ; DC offset
|
||||
(if (= (length vals) 2) ; mono
|
||||
@@ -480,15 +500,15 @@ Daulton (<a href=
|
||||
(if val2
|
||||
;; stereo
|
||||
(let ((time (/ (1- id) *sound-srate*))
|
||||
(db1 (linear-to-db (abs val1)))
|
||||
(db2 (linear-to-db (abs val2))))
|
||||
(db1 (lin-to-db (abs val1)))
|
||||
(db2 (lin-to-db (abs val2))))
|
||||
(format fp
|
||||
"<tr>~%<td>~a</td>~%<td>~a</td>~%<td>~a</td>~%<td>~a</td>~%~
|
||||
<td>~a</td>~%<td>~a</td>~%</tr>~%"
|
||||
id time val1 val2 db1 db2))
|
||||
;; mono
|
||||
(let ((time (/ (1- id) *sound-srate*))
|
||||
(db (linear-to-db (abs val1))))
|
||||
(db (lin-to-db (abs val1))))
|
||||
(format fp
|
||||
"<tr>~%<td>~a</td>~%<td>~a</td>~%<td>~a</td>~%<td>~a</td>~%</tr>~%"
|
||||
id time val1 db))))
|
||||
|
||||
Reference in New Issue
Block a user