This is some great feedback. I did not know the memory use of all these
George, just to warn you, the code you listed would be a huge memory hog
for long passages. If there is any way to read one sample at a time to
get or even just approximate the result you are looking for, that would
be much recommended.
I do not know if that is possible for your calculation, but here is an
example of how you might be able to free up some memory for a different
One could generate an average sound level measure by reading all items
into memory, adding them all up, then dividing by the number of samples.
That is the memory-hungry way to do it.
You can also do the average by reading each sample, adding it to a
running total, and incrementing a counter of the number of samples each
time. That way you just need one sample, the total, and a counter in
memory at any one time. This is a memory-efficient way to do it.
I do not know enough about L10 and L90 to tell you how to do this (and I
do not feel like trying to work out the math). If there is a workaround
to calculate them or approximate them one sample at a time, I would
strongly recommend using it. Your plug-in will run MUCH faster and more
reliably if you can allow Nyquist to free each sample after you read it.
At the very least, you should add code to set the "s" to nil when you
have read it into an array or list, so Nyquist can free the samples.
Anything to reduce the memory drain will help.
Roger Dannenberg wrote:
> Sounds are "about" 4 bytes per sample because the samples are in
> lists of arrays (C data structures) that have some overhead. The
> overhead is probably about 1%.
> LISP ARRAYs of FLONUMs take about 14 bytes per number (4 for each
> ARRAY element + 10 for the FLONUM each element points to), but as I
> write this I'm wondering if the doubles in FLONUMs aren't 8-byte
> aligned, adding 6 more bytes to each number.
> SORT works on lists, but not on arrays, so you can either write a
> sort routine or convert the array to a list. A LIST is 10 bytes per
> element (or maybe 16 if the cells are 8-byte aligned -- I don't know).
> If you copy from the array, the FLONUMs in the list will be shared, so
> they don't add additional memory.
Alex S. Brown, PMP
http://www.alexsbrown.com - Free PM Articles
http://www.rlprj.com - PM Speaking and Teaching
ahttps://www.xing.com/profile/AlexS_Brown OpenBC/XING Professional Networking
http://www.linkedin.com/in/alexsbrown LinkedIn Networking