How to compute SPL from sound inputed from a microphone.

General discussion about writing or understanding source code in audio software that does not fit in the other specific Programming and Development boards.

If you require help using Audacity, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by endolith » Thu Jul 15, 2010 4:33 pm

Is the snd-avg function written in lisp? I tried looking for the source code and couldn't find it.
endolith
 
Posts: 29
Joined: Fri Jan 15, 2010 10:31 pm

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by steve » Thu Jul 15, 2010 4:56 pm

No, I think it's written in C, but I know so little about C programming that I wouldn't know what to look for to find it.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32987
Joined: Sat Dec 01, 2007 11:43 am

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by steve » Thu Jul 15, 2010 5:33 pm

It looks like there is some demand for this type of plug-in
viewtopic.php?f=12&t=36226
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32987
Joined: Sat Dec 01, 2007 11:43 am

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by endolith » Fri Jul 16, 2010 9:32 pm

stevethefiddle wrote:
endolith wrote:Is there a better way to handle mono/stereo?

Yes there is, using (multichan-expand #'function arg1 arg2 ...)
I suggest getting the plug-in working just with mono tracks. Once it is working with mono tracks it is easy to convert it to accept multi-channel sounds.


Hmm, is that really applicable? It seems to be a shortcut for doing processing on one or two channels, and returning audio in the same format (zipping the two channels back together again afterward). I'm outputting text, and the output should be different depending on whether it's mono or stereo.
endolith
 
Posts: 29
Joined: Fri Jan 15, 2010 10:31 pm

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by steve » Sat Jul 17, 2010 6:50 pm

For stereo tracks, are you wanting to output data for the combined channels, or "left channel data" / "right channel data"?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32987
Joined: Sat Dec 01, 2007 11:43 am

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by endolith » Sat Jul 17, 2010 6:53 pm

stevethefiddle wrote:For stereo tracks, are you wanting to output data for the combined channels, or "left channel data" / "right channel data"?


It should show each track individually. In my other script, if both tracks are identical, it says so, and then displays one set of statistics. I don't really care if it does this or not though.
endolith
 
Posts: 29
Joined: Fri Jan 15, 2010 10:31 pm

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by steve » Sat Jul 17, 2010 8:10 pm

Then you could use (multichan-expand ...), though it would probably be simpler to use (if (arrayp s)(analyze-stereo s)(analyze-mono s))

By wrapping up the analysis code into a function will remove the need for duplicate code.
This is the type of thing that I'm thinking of:
Code: Select all
(defun analyze (s-in) ; code that does the analysis and returns data as a string
  (format NIL "Peak level ~a dB~%"
  (linear-to-db (peak s-in ny:all))))

(defun analyze-mono (input) ; for mono tracks
  (format NIL "Mono track.~%~a~%" (analyze input)))

(defun analyze-stereo (input) ; for stereo tracks
  (format NIL "Stereo track.~%Left Channel: ~aRight Channel: ~a~%" (analyze (aref input 0))(analyze (aref input 1))))

(if (arrayp s)(analyze-stereo s)(analyze-mono s))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32987
Joined: Sat Dec 01, 2007 11:43 am

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by endolith » Mon Jul 19, 2010 4:17 pm

stevethefiddle wrote:No, I think it's written in C, but I know so little about C programming that I wouldn't know what to look for to find it.


You know anything about writing a replacement? I'm not sure how to work with individual samples here.

(snd-fetch-array sound len step)
Reads sequential arrays of samples from sound, returning either an array of FLONUMs or NIL when the sound terminates.

(snd-samples sound limit)
Converts the samples into a lisp array.


So I could read chunks of data from the sound, and calculate the average of each array using some regular lisp array average function?
endolith
 
Posts: 29
Joined: Fri Jan 15, 2010 10:31 pm

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by steve » Mon Jul 19, 2010 11:48 pm

I think you are already pretty close to achieving what you want, but I'm not sure exactly what you want.
I'm also hoping that you know all of the ins-and-outs of weighted measurements because my theory knowledge gets a bit shaky there.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32987
Joined: Sat Dec 01, 2007 11:43 am

Re: How to compute SPL from sound inputed from a microphone.

Permanent link to this post Posted by endolith » Tue Jul 20, 2010 12:58 am

Yeah I understand what I'm doing and what i want, I just need help with the lisp/nyquist part.
endolith
 
Posts: 29
Joined: Fri Jan 15, 2010 10:31 pm

PreviousNext

Return to General Audio Programming



Who is online

Users browsing this forum: No registered users and 4 guests