Hi All, I'm working on a fun little audio side-project. I want to be able to create a sound collage using sounds I find online. I hope you can point me in the right direction with regard to algorithms, approaches, etc. I'll be writing a Clojure (Java) program to find and download mp3s, chop them up into chunks, perform spectrum analysis on the chunks, and then write an algorithm to layer them together in such a way that I don't combine two or more chunks with lots of amplitude in a given frequency band. Basically, I want to avoid layering two very bassy sounds together or two very hissy sounds together so that the finished sound collage has some space and musicality. I'll want to figure out a quick way to adjust amplitude to prevent clipping, as well. But that will wait until a later time. So. I've found Java libraries for manipulating chunks of sound, but have not found libraries that I could easily use to obtain the kinds of spectral information I want. When I'm done analyzing a chunk of sound, I want the following information. I want the average amplitude of the energy at the given frequency bands over the length of the sound sample expressed as a floating-point value between 0 and 1.0: 0 - 150 150 - 250 250 - 350 350 - 500 500 - 750 750 - 1000 1000 - 1500 1500 - 2500 2500 - 5000 5000+ A chunk of a bass-heavy dance track might look like: {0.8, 0.9. 0.6, 0.5, 0.4, 0.4, 0.3, 0.2, 0.2, 0.2} A field recording of birds might look like: {0.0, 0.1, 0.2, 0.3, 0.5, 0.6, 0.4, 0.2, 0.1, 0.1} I'm looking for something quick and dirty that can execute quickly. I've read enough about spectrum analysis to determine that I need to use an FFT. I located the following FFT Java library: http://sites.google.com/site/piotrwendykier/software/jtransforms which provides access to FFTs of various types over sets of single and double-precision data. I have a basic (if rusty) understanding of discrete math and have to admit that the Wikipedia pages on these subjects have not been terribly illuminating. I appreciate any pointers and general guidance. Thanks! John David
Fast Coarse Spectrum Analysis of Sound Samples in Java
Started by ●August 8, 2010
Reply by ●August 9, 20102010-08-09
John David Eriksen wrote:> When I'm done analyzing a chunk of sound, I want the following > information. I want the average amplitude of the energy at the given > frequency bands over the length of the sound sample expressed as a > floating-point value between 0 and 1.0: > I'm looking for something quick and dirty that can execute quickly.Use a simplest zero crossing period counter. Make a hystogram of half-periods. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●August 9, 20102010-08-09
high pass the top half of your spectrum and measure the range min,max. square your residual and repeat for an octave division... normalize outputs to approximate unit range. Not as quick as Vlad's but will be different. Cheers Jacko
Reply by ●August 9, 20102010-08-09
> > When I'm done analyzing a chunk of sound, I want the following > information. I want the average amplitude of the energy at the given > frequency bands over the length of the sound sampleThe MP3 compression has already perfomred a frequency domain analysis, perhaps you can use the MP3 data? Mark
Reply by ●August 9, 20102010-08-09
On Aug 9, 6:29�am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:> John David Eriksen wrote: > > When I'm done analyzing a chunk of sound, I want the following > > information. I want the average amplitude of the energy at the given > > frequency bands over the length of the sound sample expressed as a > > floating-point value between 0 and 1.0: > > I'm looking for something quick and dirty that can execute quickly. > > Use a simplest zero crossing period counter. > Make a hystogram of half-periods. > > Vladimir Vassilevsky > DSP and Mixed Signal Design Consultanthttp://www.abvolt.comHi Vladimir, Thanks for your help. Correct me if I am wrong, but doesn't zero crossing information fail to give me any information about amplitude? John David
Reply by ●August 9, 20102010-08-09
John David Eriksen wrote:> On Aug 9, 6:29 am, Vladimir Vassilevsky <nos...@nowhere.com> wrote: > >>John David Eriksen wrote: >> >>>When I'm done analyzing a chunk of sound, I want the following >>>information. I want the average amplitude of the energy at the given >>>frequency bands over the length of the sound sample expressed as a >>>floating-point value between 0 and 1.0: >>>I'm looking for something quick and dirty that can execute quickly. >> >>Use a simplest zero crossing period counter. >>Make a hystogram of half-periods. >> > Thanks for your help. Correct me if I am wrong, but doesn't zero > crossing information fail to give me any information about amplitude?FWIW, the relation of the different columns in the histogram gives you the relative estimate of energies at the corresponding frequencies. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●August 10, 20102010-08-10
On Aug 9, 10:49=A0am, jacko <jackokr...@gmail.com> wrote:> high pass the top half of your spectrum and measure the range min,max. > square your residual and repeat for an octave division... normalize > outputs to approximate unit range. > > Not as quick as Vlad's but will be different. > > Cheers JackoHey Jacko, Thanks for your suggestion. Much of your terminology is unfamiliar -- it looks like I have quite a bit to learn. I have access to FFT libraries, but it looks like I have to perform operations on my data once I have it in the frequency domain that may not be supported by available Java libraries. It looks like I'm either going to have to hit the books or keep searching around for well-documented and ready-made software packages that can help me out. Thanks again, John David
Reply by ●August 10, 20102010-08-10
On Aug 9, 5:29=A0am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:> John David Eriksen wrote: > > When I'm done analyzing a chunk of sound, I want the following > > information. I want the average amplitude of the energy at the given > > frequency bands over the length of the sound sample expressed as a > > floating-point value between 0 and 1.0: > > I'm looking for something quick and dirty that can execute quickly. > > Use a simplest zero crossing period counter. > Make a hystogram of half-periods.Yet another option similar to this is to create a histogram of the times between local maxima/minima inflection points; or a 2D histogram using both time and delta amplitude between these local extrema points. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
Reply by ●September 4, 20142014-09-04
On Sunday, August 8, 2010 7:46:47 PM UTC-7, John David Eriksen wrote:> Hi All, > > I'm working on a fun little audio side-project. I want to be able to > create a sound collage using sounds I find online. I hope you can > point me in the right direction with regard to algorithms, approaches, > etc. > > I'll be writing a Clojure (Java) program to find and download mp3s, > chop them up into chunks, perform spectrum analysis on the chunks, and > then write an algorithm to layer them together in such a way that I > don't combine two or more chunks with lots of amplitude in a given > frequency band. Basically, I want to avoid layering two very bassy > sounds together or two very hissy sounds together so that the finished > sound collage has some space and musicality. I'll want to figure out a > quick way to adjust amplitude to prevent clipping, as well. But that > will wait until a later time. > > So. I've found Java libraries for manipulating chunks of sound, but > have not found libraries that I could easily use to obtain the kinds > of spectral information I want. > > When I'm done analyzing a chunk of sound, I want the following > information. I want the average amplitude of the energy at the given > frequency bands over the length of the sound sample expressed as a > floating-point value between 0 and 1.0: > > 0 - 150 > 150 - 250 > 250 - 350 > 350 - 500 > 500 - 750 > 750 - 1000 > 1000 - 1500 > 1500 - 2500 > 2500 - 5000 > 5000+ > > A chunk of a bass-heavy dance track might look like: {0.8, 0.9. 0.6, > 0.5, 0.4, 0.4, 0.3, 0.2, 0.2, 0.2} > > A field recording of birds might look like: {0.0, 0.1, 0.2, 0.3, 0.5, > 0.6, 0.4, 0.2, 0.1, 0.1} > > I'm looking for something quick and dirty that can execute quickly. > I've read enough about spectrum analysis to determine that I need to > use an FFT. I located the following FFT Java library: > http://sites.google.com/site/piotrwendykier/software/jtransforms which > provides access to FFTs of various types over sets of single and > double-precision data. I have a basic (if rusty) understanding of > discrete math and have to admit that the Wikipedia pages on these > subjects have not been terribly illuminating. > > I appreciate any pointers and general guidance. > > Thanks! > > John DavidHi John, I was looking for something similar to find the rhythm and timbre of a song. Did you find any existing code or FFT libraries ( in java) that would do this? Thanks, Mita
Reply by ●September 5, 20142014-09-05
On Tuesday, August 10, 2010 6:42:18 AM UTC+12, Vladimir Vassilevsky wrote:> John David Eriksen wrote: > > > On Aug 9, 6:29 am, Vladimir Vassilevsky <nos...@nowhere.com> wrote: > > > >>John David Eriksen wrote: > >> > >>>When I'm done analyzing a chunk of sound, I want the following > >>>information. I want the average amplitude of the energy at the given > >>>frequency bands over the length of the sound sample expressed as a > >>>floating-point value between 0 and 1.0: > >>>I'm looking for something quick and dirty that can execute quickly. > >> > >>Use a simplest zero crossing period counter. > >>Make a hystogram of half-periods. > >> > > Thanks for your help. Correct me if I am wrong, but doesn't zero > > crossing information fail to give me any information about amplitude? > > FWIW, the relation of the different columns in the histogram gives you > the relative estimate of energies at the corresponding frequencies. > > > Vladimir Vassilevsky > DSP and Mixed Signal Design Consultant > http://www.abvolt.comZero crossing are an awful way to get information. Bit of noise and you're screwed. In fact unless you have a very high SNR forget it.