Abstracting AudioThumbnail Interface

Hi Jules, I was wondering if you would consider making the interface to AudioThumbnail abstract. The reason for this is that I have a few AudioThumbnail type classes that generate different types of waveform view (some coloured, some multi-band etc). Previously I have had to create specialised thumbnail caches (e.g. ColouredAudioThumbnailCache, MultibandAudioThumbnailCache) and AudioThumbnailImages (a wrapper class from my module to easily handle interactive waveforms) which leads to 3 times the number of classes actually needed and a lot of repeated, incompatible code.

I thought about making some AudioThumbnail methods virtual but that doesn’t seem clean because the waveforms could be generated internally in many different ways. AudioThumbnail is evidence of this with many internal private classes. Having a common base class means I can easily swap between waveform types on the fly and they all behave the same way.

I have implemented these changes in a local copy of the library and the number of changes is surprisingly small and user impact nil. If you would consider this I’ll tidy up the comments and post the files for integration but a quick rundown is as follows:

  • Create a new AudioThumbnailBase class, inherit from ChangeBroadcaster & AudioFormatWriter::ThreadedWriter::IncomingDataReceiver
  • Provide a protected default constructor
  • Add all the AudioThumbnail methods and make them pure virtual
  • Modify AudioThumbnail to inherit only from AudioThumbnailBase
  • Modify AudioThumbnailCache load and store methods to take a reference to AudioThumbnailBase rather than AudioThumbnail

It is then up to the user to implement all the methods in the best way they see fit and the data will be serialised correctly as the implementation of loadFrom and saveTo come from the child class which stores the thumb data as one big MemoryBlock.

There is plenty of scope for use here: high-res waveforms when zoomed in that draw diagonal lines between samples, coloured waveforms akin to Traktor or Melodyne, dual layered waveforms with pitch information, sonogram waveforms…

What do you think? Or have any better ideas?

Thanks a lot, Dave.

Hi Dave

Sounds fun, but I’m trying not to make any big changes right now, I’m just getting things stable… Can you remind me again after I’ve got a new release out, and I’m sure we can figure something out!

Yeh I thought that was the situation, will do.

Just gonna give this a little nudge to put it back on your radar now that 2.0 is out and before you get too deep into AAX. Its not urgent but probably a lot less of a job than a new plugin format.

Thanks Dave. Sure, if you want to let me take a look I can probably find time to do that, it doesn’t sound too hard.