Re: [Audacity-nyquist] Spectrum Analysis

Hi Richard,
Short reply to your questions:
Nyquist and Audacity are two separate things. In Audacity, Nyquist
runs as an "embedded subprocess".
Nyquist is NOT an "Audacity scripting language" and has no access to
the Audacity GUI functions.
The only spectrum-related Nyquist functions available are are "snd-fft"
and "snd-ifft" (inverse fft).
In Nyquist, there is no "graphical plot" function but a very rudimentary
"s-plot" function which writes ascii-data files to be plotted with
programs like gnu-plot etc.
This means in practice:
> OPEN FILE (SPECIFIED MP3 SAMPLE)
- a Nyquist plugin cannot read mp3 files, you have to load the mp3
fille manually via Audacity "File > import", the mp3 gets converted
by Audacity to temporary au-Files (Sun audio format). Nyquist (in
Audacity) has access to these .au-files via a global variable "s".
> EXECUTE "EFFECT/AMPLIFY" /* EXISTING MENU COMMAND
- Nyquist has no access to Audacity Menu, but build-in "scale" and
"mult" functions to change the volume of audio samples.
> EXECUTE "ANALYZE/PLOT SPECTRUM" /* EXISTING MENU COMMAND
- Nyquist has no access to the Audacity Menu. Nyquist has no
"graphical plot" function.
> (EXPORT)
> (SAVE AS (SPECIFIED FILE NAME))
> (WHERE (SPECIFIED LOCATION))
> (SAVE)
- since Audacity_1.3.7-beta Nyquist in Audacity can read and write
sound files but the sound-file-io interface ist still very buggy.
See the discussion on this mailing list approx. a month ago.
I will help debugging the sound-file-io but unfortunately do not
have much time yet.
- edgar

Thread view

Good Morning All-
I am NOT new to studio sound processing nor traditional scientific
programming (including LISP), but I AM new to both Audacity and
Nyquist. I have need to (batch) parse large amounts of streamed audio
data from natural and artificial manatee habitats to isolate and
analyze vocalization (call) data. Rather than start from scratch, I
was hoping to use Audacity to provide some of the base processing,
particularly the Fourier transformation (I presume this is what is
being done) to get a spectrum analysis, which is what I need.
If I could write a "macro" (term used loosely) perhaps using Nyquist,
it would look something like the following (even more loosely, in
pseudo-code):
OPEN FILE (SPECIFIED MP3 SAMPLE)
EXECUTE "EFFECT/AMPLIFY" /* EXISTING MENU COMMAND
WHILE NOT EOF DO
SELECT FIRST/NEXT 0.5 SECONDS OF SAMPLE
EXECUTE "ANALYZE/PLOT SPECTRUM" /* EXISTING MENU COMMAND
(EXPORT)
(SAVE AS (SPECIFIED FILE NAME))
(WHERE (SPECIFIED LOCATION))
(SAVE)
(CLOSE)
END DO
CLOSE FILE
What would result, unless I have made a silly mistake above, is a
series of spectra output files, one for each 0.5 second of the sample.
A couple (to say the least!) of problems/issues present themselves:
1. I REALLY want all of the spectra for a given sample (typically 30
minutes) to go into the SAME spectrum output file, i.e. to append at
each iteration of the loop, otherwise I would have 3600 (!) separate
output spectra files per audio sample.
2. For reasons of simplicity, I would prefer to do this with a plug-
in instead of having to modify the Audacity source code and re-build.
(I am NOT an object-oriented programmer.)
3. I intend to process this spectrum data OUTSIDE of Audacity,
because it appears that the spectrum tools are limited and I need to
extract time stamp, duration, fundamental pitch, harmonics, etc. which
I can do easily enough out of the "ANALYZE/PLOT SPECTRUM" output file
(which is a simple text file with two column of numbers; frequency
(Hz) v. level (dB)).
I have downloaded the complete Nyquist implementation from Carnegie-
Melon University, noting that Audacity can ONLY use the LISP flavor
(my preference anyway). I am confident that I could navigate the file-
append issues and so forth, but I would NOT want to have to replicate
the production of the spectra themselves, unless that task would be a
LOT easier than I am thinking.
>>>There may be an alternate approach that I have come across: There
is a "Spectrum" display on the "Track" drop-down. This would be
perfect if I could export it into a format similar to "ANALYZE/PLOT
SPECTRUM"...
ANY guidance getting started would be appreciated. (I may have missed
much simpler approaches entirely.) I can noodle my way through the
details, I just would like to avoid making a plethora of false starts
with the wrong tool or strategy.
Best Regards,
Richard
- - - - - - - - - -
Richard Hamilton, B.S., M.S.
Research Scientist,
Midwest Manatee Research Project
Xavier University
Visiting Assistant Professor,
Departments of Mathematics and Physics
Xavier University
HamiltonR@...
R_E_H@...
513.484.6284

Hi Richard,
I'm not sure about your Nyquist request, but am cc'ing this to the
Audacity development list, perhaps someone here can help you.
David
--
David R. Sky
http://www.shellworld.net/~davidsky/
On Wed, 27 May 2009, REH wrote:
> Good Morning All-
>
> I am NOT new to studio sound processing nor traditional scientific
> programming (including LISP), but I AM new to both Audacity and
> Nyquist. I have need to (batch) parse large amounts of streamed audio
> data from natural and artificial manatee habitats to isolate and
> analyze vocalization (call) data. Rather than start from scratch, I
> was hoping to use Audacity to provide some of the base processing,
> particularly the Fourier transformation (I presume this is what is
> being done) to get a spectrum analysis, which is what I need.
>
> If I could write a "macro" (term used loosely) perhaps using Nyquist,
> it would look something like the following (even more loosely, in
> pseudo-code):
>
> OPEN FILE (SPECIFIED MP3 SAMPLE)
> EXECUTE "EFFECT/AMPLIFY" /* EXISTING MENU COMMAND
>
> WHILE NOT EOF DO
> SELECT FIRST/NEXT 0.5 SECONDS OF SAMPLE
> EXECUTE "ANALYZE/PLOT SPECTRUM" /* EXISTING MENU COMMAND
> (EXPORT)
> (SAVE AS (SPECIFIED FILE NAME))
> (WHERE (SPECIFIED LOCATION))
> (SAVE)
> (CLOSE)
> END DO
>
> CLOSE FILE
>
> What would result, unless I have made a silly mistake above, is a
> series of spectra output files, one for each 0.5 second of the sample.
>
> A couple (to say the least!) of problems/issues present themselves:
>
> 1. I REALLY want all of the spectra for a given sample (typically 30
> minutes) to go into the SAME spectrum output file, i.e. to append at
> each iteration of the loop, otherwise I would have 3600 (!) separate
> output spectra files per audio sample.
>
> 2. For reasons of simplicity, I would prefer to do this with a plug-
> in instead of having to modify the Audacity source code and re-build.
> (I am NOT an object-oriented programmer.)
>
> 3. I intend to process this spectrum data OUTSIDE of Audacity,
> because it appears that the spectrum tools are limited and I need to
> extract time stamp, duration, fundamental pitch, harmonics, etc. which
> I can do easily enough out of the "ANALYZE/PLOT SPECTRUM" output file
> (which is a simple text file with two column of numbers; frequency
> (Hz) v. level (dB)).
>
> I have downloaded the complete Nyquist implementation from Carnegie-
> Melon University, noting that Audacity can ONLY use the LISP flavor
> (my preference anyway). I am confident that I could navigate the file-
> append issues and so forth, but I would NOT want to have to replicate
> the production of the spectra themselves, unless that task would be a
> LOT easier than I am thinking.
>
> >>>There may be an alternate approach that I have come across: There
> is a "Spectrum" display on the "Track" drop-down. This would be
> perfect if I could export it into a format similar to "ANALYZE/PLOT
> SPECTRUM"...
>
> ANY guidance getting started would be appreciated. (I may have missed
> much simpler approaches entirely.) I can noodle my way through the
> details, I just would like to avoid making a plethora of false starts
> with the wrong tool or strategy.
>
> Best Regards,
>
> Richard
>
> - - - - - - - - - -
>
> Richard Hamilton, B.S., M.S.
>
> Research Scientist,
> Midwest Manatee Research Project
> Xavier University
>
> Visiting Assistant Professor,
> Departments of Mathematics and Physics
> Xavier University
>
> HamiltonR@...
> R_E_H@...
> 513.484.6284
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> Audacity-nyquist mailing list
> Audacity-nyquist@...
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
>
>

Hi Richard,
Short reply to your questions:
Nyquist and Audacity are two separate things. In Audacity, Nyquist
runs as an "embedded subprocess".
Nyquist is NOT an "Audacity scripting language" and has no access to
the Audacity GUI functions.
The only spectrum-related Nyquist functions available are are "snd-fft"
and "snd-ifft" (inverse fft).
In Nyquist, there is no "graphical plot" function but a very rudimentary
"s-plot" function which writes ascii-data files to be plotted with
programs like gnu-plot etc.
This means in practice:
> OPEN FILE (SPECIFIED MP3 SAMPLE)
- a Nyquist plugin cannot read mp3 files, you have to load the mp3
fille manually via Audacity "File > import", the mp3 gets converted
by Audacity to temporary au-Files (Sun audio format). Nyquist (in
Audacity) has access to these .au-files via a global variable "s".
> EXECUTE "EFFECT/AMPLIFY" /* EXISTING MENU COMMAND
- Nyquist has no access to Audacity Menu, but build-in "scale" and
"mult" functions to change the volume of audio samples.
> EXECUTE "ANALYZE/PLOT SPECTRUM" /* EXISTING MENU COMMAND
- Nyquist has no access to the Audacity Menu. Nyquist has no
"graphical plot" function.
> (EXPORT)
> (SAVE AS (SPECIFIED FILE NAME))
> (WHERE (SPECIFIED LOCATION))
> (SAVE)
- since Audacity_1.3.7-beta Nyquist in Audacity can read and write
sound files but the sound-file-io interface ist still very buggy.
See the discussion on this mailing list approx. a month ago.
I will help debugging the sound-file-io but unfortunately do not
have much time yet.
- edgar