From: Mikael <mr.ogren@gm...>  20070115 06:19:54
Attachments:
Message as HTML

Hi again! I have made a plugin that analyses the selected audio (mono only) using an Aweighting filter (by Edgar), time weighting FAST (125 ms) and then outputs the equivalent and maximum level as a label track. The plugin assumes 44.1kHz sampling frequency now, but I guess that can be fixed. I have made a preliminary verification against professional acoustics software with minor differences (+/ 0.1 dB). Other than that I let the code speak for itself, let me know what you think! Mikael ;nyquist plugin ;version 1 ;type analyze ;name "Equivalent and maximum dB(A)..." ;action "Calc. Aweighted equivalent level (LAeq) and maximum level with time weighting FAST (LAFmax)..." ; Mikael Ogren, mr.ogren@... ; 20070112 ; Licensed under GPL, no warranty, use at your own risk... ; Calibration so that a 1000 Hz tone with amplitude 1.0 gives 94 dB (setq calibration (+ 94 28.2)) ; Aweighting by Edgar (thanks!) (setq sa (lp (lp (hp (hp (hp (hp s 20.6) 20.6) 107.7) 737.9) 12200) 12200) ) ; Exponential timeweighting filter FAST (125 ms) ; sndavg is used to downsample to 100 Hz (by averaging over 441 samples) ; This only works for 44.1 kHz sampling frequency, perhaps someone can help out here ; by making a more general approach that works for all sampl. frq? ; The filtering part is OK for all frequencies, but the "441" constant is not. ;  ; The constant 0.000001 is to avoid clipping at filtered squared pressure > 1.0 (setq saf2 (mult 0.000001 (sndavg (sndbiquad (mult sa sa ) 1 0 0 (exp (/ 1 (mult (sndsrate sa)  0.125))) 0 0 0) 441 441 OPAVERAGE) ) ) ; Length of the downsampled pressure squared signal (setq mlength (sndlength saf2 99999999999) ) ; Calc. the equivalent level (setq leq (+ calibration (* 0.5 (lineartodb (sndmaxsamp (sndavg saf2 mlength mlength OPAVERAGE) )))) ); ; Calc. the maximum level (setq lmax (+ calibration (* 0.5 (lineartodb (sndmaxsamp saf2)))) ); ; Set the output format to 3 digits (example: 53.3 dB) (setq *floatformat* "%#3.3g"); ; Output result as a label track (or append into existing label track) (setq u (format NIL "LAeq= ~A LAFmax= ~A" leq lmax)) (list (list 0.0 u)) 
From: George Jenner <geo.jenner@gm...>  20070116 12:48:10
Attachments:
Message as HTML

Wow this is great. I haven't had time to deconstruct it all  I think I get somewhere with these things then all of a sudden there is a line with an orgy of parentheses. I understand better getting information back out to be visible. Anyway let me ask a few things to see if this is a way forward. > > > (setq saf2 > (mult 0.000001 > (sndavg (sndbiquad (mult sa sa ) 1 0 0 (exp (/ 1 (mult (sndsrate sa)  > 0.125))) 0 0 0) 441 441 OPAVERAGE) > ) I think after this line we have a new "sound" called saf2 that consists of 8 samples per second. > ; Length of the downsampled pressure squared signal > (setq mlength > (sndlength saf2 99999999999) > ) By running sndlength it forces all samples into memory  the manual says "about 4 bytes per sample". Why about? Anyway can I then do (setq array_of_samples (sndsample(saf2 7200))) to get the samples into an array. (7200 samples in 15 minutes) Then define a function that sorts the array (will "sort" work on an array or just a list?  or can we convert it to a list and use "sort") then read out the 720th element of the array to get the L10? Thanks again. I'll try some of these ideas in the next few days. George 
From: Mikael <mr.ogren@gm...>  20070116 14:43:59
Attachments:
Message as HTML

Hi! I downsample my signal to 100 Hz using the constant "441" samples (44100 / 100 = 441) in the sndavg call, so you need to change this constant to your sampling frequency and divide by 8 to get eight samples per second. My new "sound" saf2 is also squared, since the exponential time weighting filter I apply works on the squared pressure (like the "mean square" in RMS). This gives a slowly varying envelope normally known as the FASTweighted sound pressure squared. Perhaps I should not dwell on the details of the different metrics used in acoustics in this forum, but you might want to try this directly in the Effect > Nyquist prompt: (sndavg (mult s s) 5513 5513 OPAVERAGE) which is a bit more straightforward, it gives an (almost) 8Hz signal if your sampling frequency is 44.1 kHz. And note that your signal did not disappear, you need to zoom since it's only 8 Hz now :) About your more (x)lisp oriented questions I can't really help, I only know a tiny bit. Mikael On 1/16/07, George Jenner <geo.jenner@...> wrote: > > Wow this is great. I haven't had time to deconstruct it all  I think I > get somewhere with these things then all of a sudden there is a line with an > orgy of parentheses. I understand better getting information back out to be > visible. > > Anyway let me ask a few things to see if this is a way forward. > > > > > > (setq saf2 > > (mult 0.000001 > > (sndavg (sndbiquad (mult sa sa ) 1 0 0 (exp (/ 1 (mult (sndsrate sa) > > 0.125))) 0 0 0) 441 441 OPAVERAGE) > > ) > > > I think after this line we have a new "sound" called saf2 that consists of > 8 samples per second. > > > > ; Length of the downsampled pressure squared signal > > (setq mlength > > (sndlength saf2 99999999999) > > ) > > > By running sndlength it forces all samples into memory  the manual says > "about 4 bytes per sample". > > Why about? Anyway can I then do > > (setq array_of_samples (sndsample(saf2 7200))) > to get the samples into an array. (7200 samples in 15 minutes) > > Then define a function that sorts the array (will "sort" work on an array > or just a list?  or can we convert it to a list and use "sort") then read > out the 720th element of the array to get the L10? > > Thanks again. I'll try some of these ideas in the next few days. > > George > > > > > > > >  > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys  and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist > > > 