AudioThumbnail and AudioSampleBuffer


#1

Hello Juce’s people
I’m starting again to use Juce, and i have a small problem.
When i try using AudioThumbnail with a file (like in demo) all is perfect. But when i want to use it with a AudioSampleBuffer, it didn’t work perfect. the waveform look like very square (like if there is only 2 ou 3 values)
Here a “not-complete-but-most-of-code” of my example :
do you see something wrong ? is AudioSampleBuffer can be draw in a AudioThumbnail ?

Thank you

// init
AudioThumbnail thumbnail ;
AudioFormatReader* fileInput

// choose a file
FileChooser fc ... ;
File selectedFile = fc.getResult();
fileInput = formatManager.createReaderFor(selectedFile);

// load in a buffer
int64 length = fileInput->lengthInSamples;
AudioSampleBuffer buffer(1, length);
buffer.readFromAudioReader(fileInput, 0, length, 0, true, false);

// load in thumbnail
thumbnail.reset(1, 44100, buffer.getNumSamples());
thumbnail.addBlock(0, buffer, 0, buffer.getNumSamples());  

// draw it
startTime = 0;
endTime = thumbnail.getTotalLength(); 
thumbnail.drawChannels (g, getLocalBounds().reduced (2, 2), startTime, endTime, 1.0f);

#2

Have you stepped through to check all the numbers? There’s probably just something silly going wrong. And obviously make sure that you’re using the latest version, because I added that feature fairly recently - if your version is a few months old, you might have caught it at a stage where it wasn’t quite finished.


#3

Hello Jules !

i’m stupid :smiley:
the first parameter “sourceSamplesPerThumbnailSample”, if i define it to 1024, and if i have only 4000 samples … i have “only” 4 thumbnail sample, so, it look like very square :oops:

All is perfect now :slight_smile: