Certainly. Here is the script (to launch with the Spectrum object selected):
################################
#Get to x$ a table containing 1st column: frequencies and 2nd column: energy
#This chunk is ugly, but I do not know of a faster way to go from the result of "List" to a Table object
x$ = List: "no", "yes", "no", "no", "yes", "no"
x$ > test.txt
Read from file: "test.txt"
deleteFile: "test.txt"
#Append a cumulative energy column and fill in the blanks (knowing that the 2nd row contains the energy in pa^2/hz^2)
Append column: "cumul"
Formula: "cumul", "if row=1 then self[col-1] else self[row-1,col]+self[col-1] fi"
#Loop that runs 3 times, 1 for each quartile
for i from 1 to 3
quantile = i*0.25
#Retrieve total energy (cumulative energy at last row)
n = Get number of rows
sum = Get value: n, "cumul"
#Cumulative energy to be found
treshold = sum*quantile
#Ugly test to go through the table faster:
#split it into 2, save the previous higher
#bracket, and search to find the range
#which should contain the desired cumulative
#energy value
currLowBracket = n div 2
prevHighBracket = n
ok = 1
while ok
test = Get value: currLowBracket, "cumul"
#if test value is still over treshold,
#it means we have to lower the high bracket
if test > treshold
prevHighBracket = currLowBracket
currLowBracket = currLowBracket div 2
#if not, we've found the right range to look in
else
ok = 0
endif
endwhile
#When range is found, go through subsection
#of the Table to find value
#As soon as test is over treshold, we have
#found our row
foundRow = currLowBracket
while test < treshold
test = Get value: foundRow, "cumul"
foundRow = foundRow + 1
endwhile
frequencyOfQuartile = Get value: foundRow, "freq(Hz)"
appendInfoLine: quantile, " = ", round(frequencyOfQuartile), " Hz"
endfor
appendInfoLine: "END OF SCRIPT"
################################
Now, this script is not particularly optimized, that's for sure. But it gives out values that could be real. We've actually checked with Matlab and though there is a small displacement between values (Matlab gives them around 20 to 30 Hz lower each), there is an agreement. What seems to be the problem really is the "seewave" package for R, which gives very different values. I may have been wrong to use it as a reference, or may have misused its parameters.
As a side note, if there is a quicker way to execute this procedure (without going with a Table object, maybe, but I don't know how that would be done), I would be very interested. For the longest sound we have to measure (i.e. the most detailed spectrum), it takes about 4 seconds to give results, given the table's dimensions.
Moreover, I know it is not particulary precise to retrieve the frequency of the row in which the treshold has been passed rather than to try a kind of "interpolation", but I do not know how I would go about that.
Thanks again for your time,
Xavier St-Gelais