AudioThumbnail and AudioSampleBuffer

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

-cpr

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.

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.

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

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

Rail

1 Like

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

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

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

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

Rail

sorry to revive this, but has it been addressed or is there a solution to get the same thumbnails in both cases?