Skip to content

Commit 5706680

Browse files
committed
Update FileReader initialization
1 parent d678090 commit 5706680

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

Source/Processors/FileReader/FileReader.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -192,33 +192,6 @@ bool FileReader::startAcquisition()
192192
if (!isEnabled)
193193
return false;
194194

195-
/* Set the timestamp to start of playback and reset loop counter */
196-
totalSamplesAcquired = startSample;
197-
loopCount = 0;
198-
199-
/* Setup internal buffer based on audio device settings */
200-
AudioDeviceManager& adm = AccessClass::getAudioComponent()->deviceManager;
201-
AudioDeviceManager::AudioDeviceSetup ads;
202-
adm.getAudioDeviceSetup(ads);
203-
m_sysSampleRate = ads.sampleRate;
204-
m_bufferSize = ads.bufferSize;
205-
if (m_bufferSize == 0) m_bufferSize = 1024;
206-
m_samplesPerBuffer.set(m_bufferSize * (getDefaultSampleRate() / m_sysSampleRate));
207-
208-
bufferA.malloc(currentNumChannels * m_bufferSize * BUFFER_WINDOW_CACHE_SIZE);
209-
bufferB.malloc(currentNumChannels * m_bufferSize * BUFFER_WINDOW_CACHE_SIZE);
210-
211-
/* Reset stream to start of playback */
212-
input->seekTo (startSample);
213-
currentSample = startSample;
214-
215-
/* Pre-fills the front buffer with a blocking read */
216-
readAndFillBufferCache(bufferA);
217-
218-
readBuffer = &bufferB;
219-
bufferCacheWindow = 0;
220-
m_shouldFillBackBuffer.set(false);
221-
222195
static_cast<FileReaderEditor*> (getEditor())->startTimer(100);
223196

224197
/* Start asynchronous file reading thread */
@@ -324,7 +297,7 @@ void FileReader::setActiveRecording (int index)
324297

325298
for (int i = 0; i < currentNumChannels; ++i)
326299
{
327-
channelInfo.add (input->getChannelInfo (index, i));
300+
channelInfo.add (input->getChannelInfo (index, i));
328301
}
329302

330303
static_cast<FileReaderEditor*> (getEditor())->setTotalTime (samplesToMilliseconds (currentNumTotalSamples));
@@ -440,6 +413,33 @@ void FileReader::updateSettings()
440413

441414
isEnabled = true;
442415

416+
/* Set the timestamp to start of playback and reset loop counter */
417+
totalSamplesAcquired = startSample;
418+
loopCount = 0;
419+
420+
/* Setup internal buffer based on audio device settings */
421+
AudioDeviceManager& adm = AccessClass::getAudioComponent()->deviceManager;
422+
AudioDeviceManager::AudioDeviceSetup ads;
423+
adm.getAudioDeviceSetup(ads);
424+
m_sysSampleRate = ads.sampleRate;
425+
m_bufferSize = ads.bufferSize;
426+
if (m_bufferSize == 0) m_bufferSize = 1024;
427+
m_samplesPerBuffer.set(m_bufferSize * (getDefaultSampleRate() / m_sysSampleRate));
428+
429+
bufferA.malloc(currentNumChannels * m_bufferSize * BUFFER_WINDOW_CACHE_SIZE);
430+
bufferB.malloc(currentNumChannels * m_bufferSize * BUFFER_WINDOW_CACHE_SIZE);
431+
432+
/* Reset stream to start of playback */
433+
input->seekTo(startSample);
434+
currentSample = startSample;
435+
436+
/* Pre-fills the front buffer with a blocking read */
437+
readAndFillBufferCache(bufferA);
438+
439+
readBuffer = &bufferB;
440+
bufferCacheWindow = 0;
441+
m_shouldFillBackBuffer.set(false);
442+
443443
}
444444

445445
int FileReader::getPlaybackStart()

Source/Processors/FileReader/FileSource.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ FileSource::FileSource()
2929
, numRecords (0)
3030
, activeRecord (-1)
3131
, filename ("")
32+
, loopCount (0)
3233
{
3334
}
3435

0 commit comments

Comments
 (0)