Filtered AudioThumbnail


#1

Hi all, I am writing an application that needs to display an audio thumbnail that is comprised of three frequency bands. Rather than write my own thumbnail class I though I could use a customized AudioThumbnail subclass. My plan was to create a subclass of AudioThumbnail and include some IIRFilters in it then process the samples before they get stored, probably before the for loop in generateSection().

I know I will have to hack away quite a bit to get it to create and store three different thumbnails but at the moment I am just trying to apply a single filter. (I think I could layer up three separately filtered AudioThumbnails in my waveform view components anyway).

The problem that I am having is that generateSection() is private so can not be overridden . Would it be possible to make this public so we can change what gets passed to the drawing code?

I may have missed something major here to do with inheritance, bare with me as I have only been doing this a while. If anyone can think of any better methods your ideas are welcome.

Cheers,
Dave.


#2

Gosh, that’s really be bending the class quite a lot - it’s only designed to store one item of data per time interval. Why not use 3 thumbnails, and give each one an input source that produces appropriately filtered data?


#3

I thought that would be the case. I suppose I’m trying to bend the class to much.

Am I right in thinking to get a filtered audio file I would have to do this:

  • Load the file into a memory block
  • Convert the data in the memory block to float
  • Filter the block with an IIR filter
  • Convert the data back to the appropriate audio format
  • Write the memory block to a new temp file
  • Use this new file as the input to the thumbnail
  • Make sure to delete the file and the memory block

This just seems like a lot of work to do 3 times in order to just load an audio file with the appropriate thumbnail. If dealing with wav files this could be 40MB of memory being shifted around every couple of minutes. Or is there a simpler way of filtering an input source that I’m missing?

I think the best and most efficient way to do this would be to create my own thumbnail class that filters the audio data before the low-res data is stored.

Thanks for the help.


#4

You wouldn’t have to mess around with temp files or memory blocks - you could just make it stream directly from the file through a filter, and into the thumbnail. But yes, it’d be almost 3 times slower than doing it with a specially designed thumbnail class.