We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › compare array contents for similarity
Page Index Toggle Pages: 1
compare array contents for similarity? (Read 1119 times)
compare array contents for similarity?
Dec 19th, 2009, 5:22pm
 
hi, using the echonestP5 library by melka i want to work with musical timbre data provided by the Echo Nest API.
Basically for every event in an analyzed song, it spits out a segment object containing a float[12] with arbitrary values in it, ranging from -x to +x. So i'm having a lot of these arrays, with values inside representing certain aspects of timbre (index 0 is average loudness, index 1 is brightness, index 2 is 'flatness' etc...).

I'd like to be able to compare the contents of these arrays for similarity, i.e.
need a way to find out how this:
Code:
{10, 30, 120, 40, 20, -80, 20, 0} 



is more similar to this:
Code:
{12, 20, 140, 30, 60, -10, 30, 4} 



than to this:
Code:
{-20, 60, 10, -10, 10, -10, 30, -80} 



any suggestions? the values in these arrays are weighted somehow, so i can't just sum them up and look at the difference... the weighting should make it into the similarity comparison....
Re: compare array contents for similarity?
Reply #1 - Dec 19th, 2009, 6:29pm
 
Maybe try figuring out the average percent difference between each index instead of just summing them up.  Once you have that set up, you can make it a weighted average, and play around with the weight of each index.  Adjust the values until the code agrees with your ears (or at least comes close).
Re: compare array contents for similarity?
Reply #2 - Dec 20th, 2009, 8:24am
 
thanks... yeah, doing the weighted average thing and it kinda works:
http://www.youtube.com/watch?v=JxMdRQqhhDs

so now it's a lot of experimenting with values as you said, i guess things will get a bit more complicated when comparing different songs's timbres to each other..
Re: compare array contents for similarity?
Reply #3 - Dec 20th, 2009, 12:52pm
 
You could probably use some sort of machine learning algorithm to have the computer train itself.  You'd need to create a decently large data set where each entry contains three songs, along with the choice you manually made about which pair is more similar.
Page Index Toggle Pages: 1