AudioThumbnail and AudioSampleBuffer


#1

Is it possible to use AudioThumbnail to display data from an AudioSampleBuffer?

-cpr


#2

Not in its current form. It could be altered to take data from other sources, but at the moment it’s really geared towards files.


#3

ok. I think I’ll cobble together a new version for now. My needs actually require that I be able to draw pieces of the waveform in a different order (ie. sliced), or even backwards.


#4

Has the answer to this question changed for JUCE v4.3.0?


#5

You can use AudioThumbnail::reset() and AudioThumbnail::addBlock()

Rail


#6

I have however found that the AudioThumbnail drawn differs between the setSource and addBlock methods…


void CWaveformWindow::setFile (const File& file, AudioSampleBuffer* pBuffer)
{
    :
m_Thumbnail.reset (pBuffer->getNumChannels(), m_pParent->getSampleRate(), pBuffer->getNumSamples());
            
m_Thumbnail.addBlock (0, *pBuffer, 0, pBuffer->getNumSamples());
    :
}

versus:


void CWaveformWindow::setFile (const File& file, AudioSampleBuffer* pBuffer)
{
    :
m_Thumbnail.setSource (new FileInputSource (file));
    :
}

I’ll try and make time tomorrow to track down the difference.

Cheers,

Rail


#7

Look like the number of samples taken as a block is smaller in the second image


#8

samplesPerThumbSample is 256 for both methods.

The data length is the same for both methods as well…

setSource:

addBlock:

I’ll get back to checking this out later tonight.

Cheers,

Rail


#9

I suspect it has something to do with the timeToThumbSampleFactor in AudioThumbnail::refillCache() but haven’t quite figured it out yet…

Rail