Skip to content

Commit

Permalink
Fixed length and zoom factor
Browse files Browse the repository at this point in the history
  • Loading branch information
ffAudio committed Jul 31, 2023
1 parent d7ac9e9 commit f2d9c6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Examples/PlayerExample/Source/AudioThumbnail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ void WaveformDisplay::paint (juce::Graphics& g)
g.setColour (juce::Colours::red);

if (thumbnail)
thumbnail->drawChannels (g, getLocalBounds().reduced (3), 0.0, 10.0, 1.0);
{
auto peak = thumbnail->getApproximatePeak();
thumbnail->drawChannels (g, getLocalBounds().reduced (3), 0.0, thumbnail->getTotalLength(), peak > 0.0f ? 1.0f / peak : 1.0f);
}
else
g.drawFittedText (TRANS ("No File"), getLocalBounds(), juce::Justification::centred, 1);
}
Expand All @@ -79,6 +82,9 @@ void WaveformDisplay::updateAudioFile()
return;
}

if (!audioThumb->getAudioFile().existsAsFile())
return;

thumbnail = std::make_unique<juce::AudioThumbnail> (256, audioThumb->getManager(), audioThumb->getCache());
thumbnail->setSource (new juce::FileInputSource (audioThumb->getAudioFile()));
thumbnail->addChangeListener (this);
Expand Down

0 comments on commit f2d9c6c

Please sign in to comment.