[OT] sorting an audio folder depending on the spectra

julien breval's icon

Hello,

I am trying to find a Windows, OS X or Linux simple software that does this (in non-realtime):

1. loads a folder that contains only audio files (WAVE and/or AIFF)

2. calculates the average frequency of each file (called the "centroid" sometimes)

3. renames all the files so they are ordered from the lowest to the highest average frequency.

I usually do this manually, most of the time without any analysis tool (just hearing). I import all the samples to a DAW track and move them so they are ordered from low to high. Then I export them one by one under lexicographically increasing names. The good point about this technique is that you are sure the samples are in the order you need.

But this time I have far too many samples for doing this, and I don't have the time to develop a specific application.

In a conference, Diemo Schwarz showed that his CataRT software has to perform this task at the beginning (among other analysis tasks), so perhaps I should try it. But I fear the ordering in CataRT is simply written somewhere (like in a text file) because there are lots of ways to order samples, so you still have to change the sample filenames manually.
I was rather looking for a very simple software that does all the process in differed time. It can also be a part of the Ircam libraries used in CataRT perhaps ...

Thanks for your help,
-j

justin's icon

maybe you should have a look at audiofinder: http://www.icedaudio.com/

it has a useful function for pitch analysis, and reports the fundamental (centroid), and other frequency components of the audio file.

it does have a batch function for naming, but you would still need to do quite a bit work yourself.

hth,

justin

AlexHarker's icon

Quote: julien breval wrote on Wed, 17 September 2008 07:57
----------------------------------------------------
> In a conference, Diemo Schwarz showed that his CataRT software has to perform this task at the beginning (among other analysis tasks), so perhaps I should try it. But I fear the ordering in CataRT is simply written somewhere (like in a text file)

That's not necessarily an insurmountable problem. On OSX, you could use the aka.shell object to do the renaming. You'd need to build a little patch to take data from CataRT, and work out what names to give the files, plus what you'd need to know enough about shell scripts to do this, but I don't imagine it would take that much code.

Looking into it a bit more you get 4 text files out of cataRT - you'll need the one with the descriptors (.ud) and the one with the list of filepaths (.sf) - you can do the analysis straight in the cataRT patch, you just need a file renaming patch in Max that'll load up the text files, allow you to enter some kind of basic name, and then do the renaming for you...

Regards,

Alex

julien breval's icon

Quote: justin wrote on Wed, 17 September 2008 18:11
----------------------------------------------------
> maybe you should have a look at audiofinder: http://www.icedaudio.com/
>
> it has a useful function for pitch analysis, and reports the fundamental (centroid), and other frequency components of the audio file.
>
> it does have a batch function for naming, but you would still need to do quite a bit work yourself.
----------------------------------------------------
I downloaded it, it's a great software but I'm afraid it's not the right tool for doing this ...

julien breval's icon

I am now trying CataRT but still wonder how you load a sample folder (not individual samples). I must have a wrong version as it crashes Max regularly

-j

AlexHarker's icon

Quote: julien breval wrote on Thu, 18 September 2008 07:11
----------------------------------------------------
> I am now trying CataRT but still wonder how you load a sample folder (not individual samples). I must have a wrong version as it crashes Max regularly
>

I have 0.9.5 and it has not crashed for me yet whilst running, although I haven't ued it much. To load a folder of samples, drag and drop them onto the corpus bpatcher (you can I think probably drag the folder also) and they will all load one after the other.

Alex

julien breval's icon

All right, i have installed the previous version of CataRT and it can load folders.

I imported 18 files and had a look at the descriptor file. As far as I understand, the spectral centroid is the 17th number of each line. Though it's really boring to have to do this, it's possible to make a renaming Max patch that uses these text files.

But though the centroid calculus must be theoretically valid, when ordering my 18 samples according to it (either by renaming the files manually or playing them in the CatRT software), the order looks completely random ... Perhaps it's because these are short synthetic percussion samples and the FFT parameters are not adapted :(

I'm afraid I will have to program my own sorting software (possibly in Scilab)

Peiman's icon

You can calculate centroid in csound too. Probably easier than
programming your own I would think :-)

It should be relatively easy to write a script in python or whatever
that does this in conjunction with csound or any other command-line
programme.

Good luck
Peiman

On 18 Sep 2008, at 20:20, julienbreval wrote:

>
> All right, i have installed the previous version of CataRT and it
> can load folders.
>
> I imported 18 files and had a look at the descriptor file. As far
> as I understand, the spectral centroid is the 17th number of each
> line. Though it's really boring to have to do this, it's possible
> to make a renaming Max patch that uses these text files.
>
> But though the centroid calculus must be theoretically valid, when
> ordering my 18 samples according to it (either by renaming the
> files manually or playing them in the CatRT software), the order
> looks completely random ... Perhaps it's because these are short
> synthetic percussion samples and the FFT parameters are not adapted :(
>
> I'm afraid I will have to program my own sorting software (possibly
> in Scilab)

AlexHarker's icon

Quote: julien breval wrote on Thu, 18 September 2008 13:20
----------------------------------------------------

> But though the centroid calculus must be theoretically valid, when ordering my 18 samples according to it (either by renaming the files manually or playing them in the CatRT software), the order looks completely random ... Perhaps it's because these are short synthetic percussion samples and the FFT parameters are not adapted :(

It works *fairly* well for me, but this is going to depend on your material. Note also that the centroid is really a measure of brightness, rather than say fundamental frequency (for which you could use the Pitch descriptor), or the most prominent spectral peak.

When I tried it with 70-100 files it gave me a good general ordering, but somethings were not where I'd have placed them by hand. I guess you aren't going to easily mimic complex human perception with a straightforward calculation (note also that the final value is just the mean average of the value for every frame, which may be displaced by a few extreme values - perhaps the median value would be better here).

The main question is, when you order by hand what are you choosing based on? - pitch, brightness, most prominent spectral area etc., and then to model that in your analysis...

I'm not sure centroid is actually going to suit your needs. When you describe low to high earlier in the thread, it doesn't sound like it's brightness you are hearing, but of course I may be wrong...

Alex

julien breval's icon

Quote: AlexHarker wrote on Thu, 18 September 2008 21:32
----------------------------------------------------
> The main question is, when you order by hand what are you choosing based on? - pitch, brightness, most prominent spectral area etc., and then to model that in your analysis...
----------------------------------------------------
Well, I tried some other descriptors in CataRT, including the "pitch" descriptor, but none seems to order the samples like I usually do manually.

I have wandered into analysis only a few times (mostly for phase-vocoder time stretching in Pure Data) but usually it's not my cup of tea.

I prefer ordering the samples manually, it won't be perfect because of the huge number of samples this time, but at least it will work for the project.

AlexHarker's icon

Quote: julien breval wrote on Thu, 18 September 2008 13:55
----------------------------------------------------
> Well, I tried some other descriptors in CataRT, including the "pitch" descriptor, but none seems to order the samples like I usually do manually.

One final point. The centroid calculation in cataRT seems to be set to use the info only between 50Hz and 3kHz. Are you using very transient or high frequency sounds? If so, it's possible you might want to extend the range of this calculation. Thought it might be worth asking.

Alex

julien breval's icon

Quote: AlexHarker wrote on Thu, 18 September 2008 22:10
----------------------------------------------------
Are you using very transient or high frequency sounds?
----------------------------------------------------
of course, as these are synthetic percussive sounds

it might be the problem ...

AlexHarker's icon

Quote: julien breval wrote on Thu, 18 September 2008 14:42
----------------------------------------------------
> of course, as these are synthetic percussive sounds
>
> it might be the problem ...
>

Form the main patch try going into these subpatchers:

catarT.import (the one for the corpus you're using) -> analyse -> compute_desc

Above the centroid box are two number boxes that set the range in Hz - I can't see how they are being set, but they default to 50 / 3000 - try increasing the 3000 before you do the analysis - I'd be interested to know if it gives you better results or not.

Alex

Diemo Schwarz's icon

Salut Julien, dear Alex,

thanks for this interesting application for CataRT, and the profound and
detailed discussion. (I didn't know there are such knowledgable CataRTists out
there.)

You might profit from a hybrid approach, having CataRT analyse your sounds, and
then edit values in the unitdata file when they don't seem to correspond to what
you're hearing. The module catart.unitviewer could eventually be made into a
direct descriptor editor.

The crash on importing a folder is fixed in CataRT-0.9.7, which I just put up on
http://imtr.ircam.fr/index.php/CataRT. Also, analysis should be faster by
downsampling before pitch tracking and using vectorised code.

Regarding the descriptors, what you might be looking for, Julien, is a Chroma
histogram. Of course pitch doesn't give sensible values for noisy sounds, and
SpectralCentroid doesn't capture a tonal component, but only the spectrum as a
whole. Luckily, the next versions of CataRT (0.10) I'm working on at the moment
will allow to insert your own descriptor calculation modules (and segmentation
modules), and I have a chroma analysis patch lying around already that will be
integrated.

Alex Harker wrote:
> Quote: julien breval wrote on Thu, 18 September 2008 14:42
> ----------------------------------------------------
>> of course, as these are synthetic percussive sounds
>>
>> it might be the problem ...
>>
>
> Form the main patch try going into these subpatchers:
>
> catarT.import (the one for the corpus you're using) -> analyse -> compute_desc
>
> Above the centroid box are two number boxes that set the range in Hz - I can't see how they are being set, but they default to 50 / 3000 - try increasing the 3000 before you do the analysis - I'd be interested to know if it gives you better results or not.

They are set from preset 2.

Cheers, and see you on concat@ircam.fr...
                                ...Diemo

--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

AlexHarker's icon

Quote: Diemo Schwarz wrote on Fri, 19 September 2008 06:32
----------------------------------------------------
>
> Salut Julien, dear Alex,
>
> thanks for this interesting application for CataRT, and the profound and
> detailed discussion. (I didn't know there are such knowledgable CataRTists out
> there.)

Hi Diemo. Nice to hear from you! Very nice work by the way! Thanks for making CataRT openly available and open source.

> Regarding the descriptors, what you might be looking for, Julien, is a Chroma
> histogram...... and I have a chroma analysis patch lying around

Any chance you'd be willing to post that patch, or details of how the technique works, so that I might be able to implement it in another context I'm working on?

This isn't a technique I've come across yet, but it sounds like it might also be good for a similar application of indexing samples that I'd like to use in an upcoming piece...

Thanks

Alex

julien breval's icon

Many thanks you all for your help, especially Diemo and Alex.

I will try to change the analysis parameters to see if I get better results. If not, I will really be interested in the chroma analysis. Please keep on working on this :)
The project I am working on ends on early october so I thought of ordering all the samples manually too.

-j