Skip to content

Commit a45f6b9

Browse files
committed
More work
1 parent 11917e9 commit a45f6b9

24 files changed

Lines changed: 3216 additions & 1241 deletions

examples/graphics/source/examples/AudioFileDemo.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
class AudioFileWaveform : public yup::AudioViewComponent
4040
{
4141
public:
42-
AudioFileWaveform()
42+
AudioFileWaveform (std::shared_ptr<yup::AudioPeakProfileCache> cacheToUse)
43+
: yup::AudioViewComponent (std::move (cacheToUse))
4344
{
4445
addAndMakeVisible (playhead);
4546
playhead.setVisible (false);
@@ -134,12 +135,14 @@ class AudioFileDemo : public yup::Component
134135
public:
135136
AudioFileDemo()
136137
: Component ("AudioFileDemo")
138+
, waveformCache (std::make_shared<yup::AudioPeakProfileCache>())
137139
, loadButton ("Load Audio")
138140
, playButton ("Play")
139141
, stopButton ("Stop")
140142
, saveButton ("Save As")
141143
, loopButton ("Loop")
142144
, labelsButton ("Labels")
145+
, waveformDisplay (waveformCache)
143146
{
144147
formatManager.registerDefaultFormats (
145148
yup::AudioFormatType::all & ~yup::AudioFormatType::coreAudio);
@@ -148,6 +151,9 @@ class AudioFileDemo : public yup::Component
148151
deviceManager.addAudioCallback (&sourcePlayer);
149152
sourcePlayer.setSource (&transportSource);
150153

154+
// Configure the waveform cache
155+
waveformCache->setThreadPool (&waveformThreadPool);
156+
151157
setupUi();
152158
}
153159

@@ -271,8 +277,6 @@ class AudioFileDemo : public yup::Component
271277

272278
addAndMakeVisible (waveformDisplay);
273279
waveformDisplay.setSelectable (true);
274-
waveformDisplay.getThumbnail().setThreadPool (&waveformThreadPool);
275-
waveformDisplay.getThumbnail().setBackgroundCalculationEnabled (true);
276280
waveformDisplay.setChannelLabelsVisible (labelsButton.getToggleState());
277281
}
278282

@@ -357,7 +361,7 @@ class AudioFileDemo : public yup::Component
357361
memorySource = std::make_unique<yup::MemoryAudioSource> (audioBuffer, false, loopEnabled);
358362
transportSource.setSource (memorySource.get(), 0, nullptr, loadedSampleRate, numChannels);
359363

360-
waveformDisplay.setAudioBuffer (&audioBuffer, loadedSampleRate);
364+
waveformDisplay.setSource (&audioBuffer, loadedSampleRate);
361365
waveformDisplay.setPlayhead (0.0, audioLengthSeconds);
362366
updateStatus ("Loaded " + file.getFileName() + " | " + yup::String (numChannels)
363367
+ " ch | " + yup::String (loadedSampleRate, 1) + " Hz | "
@@ -440,7 +444,9 @@ class AudioFileDemo : public yup::Component
440444
yup::AudioTransportSource transportSource;
441445
std::unique_ptr<yup::MemoryAudioSource> memorySource;
442446
yup::AudioBuffer<float> audioBuffer;
447+
443448
yup::ThreadPool waveformThreadPool;
449+
std::shared_ptr<yup::AudioPeakProfileCache> waveformCache;
444450

445451
yup::TextButton loadButton;
446452
yup::TextButton playButton;

0 commit comments

Comments
 (0)