@@ -51,7 +51,8 @@ FileReader::FileReader() : GenericProcessor ("File Reader"),
51
51
m_sysSampleRate (44100 ),
52
52
playbackActive (true ),
53
53
gotNewFile (true ),
54
- loopPlayback (true )
54
+ loopPlayback (true ),
55
+ sampleRateWarningShown (false )
55
56
{
56
57
/* Add built-in file source (Binary Format) */
57
58
supportedExtensions.set (" oebin" , 1 );
@@ -500,8 +501,32 @@ void FileReader::updateSettings()
500
501
adm.getAudioDeviceSetup (ads);
501
502
m_sysSampleRate = ads.sampleRate ;
502
503
m_bufferSize = ads.bufferSize ;
504
+
505
+ if (m_sysSampleRate < 44100.0 )
506
+ {
507
+ if (! sampleRateWarningShown)
508
+ {
509
+ LOGE (" File Reader: Sample rate is less than 44100 Hz. Disabling processor." );
510
+
511
+ if (! headlessMode)
512
+ {
513
+ AlertWindow::showMessageBox (AlertWindow::WarningIcon,
514
+ " [File Reader] Invalid Sample Rate" ,
515
+ " The sample rate of the audio device is less than 44.1 kHz. File Reader is disabled."
516
+ " \n\n Try adjusting the sample rate in the audio settings by clicking the 'Latency' button in the Control Panel "
517
+ " and setting it to 44.1 kHz or higher. After making this change, please remove and re-add the File Reader to the signal chain." );
518
+ }
519
+
520
+ sampleRateWarningShown = true ;
521
+ }
522
+
523
+ isEnabled = false ;
524
+ return ;
525
+ }
526
+
503
527
if (m_bufferSize == 0 )
504
528
m_bufferSize = 1024 ;
529
+
505
530
m_samplesPerBuffer.set (m_bufferSize * (getDefaultSampleRate () / m_sysSampleRate));
506
531
507
532
bufferA.malloc (currentNumChannels * m_bufferSize * BUFFER_WINDOW_CACHE_SIZE);
@@ -602,7 +627,7 @@ void FileReader::process (AudioBuffer<float>& buffer)
602
627
603
628
if (! playbackActive && playbackSamplePos + samplesNeededPerBuffer > stopSample)
604
629
{
605
- samplesNeededPerBuffer = int (stopSample - playbackSamplePos);
630
+ samplesNeededPerBuffer = int (stopSample - playbackSamplePos);
606
631
switchNeeded = true ;
607
632
}
608
633
else
@@ -745,7 +770,7 @@ void FileReader::readAndFillBufferCache (HeapBlock<float>& cacheBuffer)
745
770
// if reached end of file stream
746
771
if ((currentSample + samplesToRead) > stopSample)
747
772
{
748
- samplesToRead = int (stopSample - currentSample);
773
+ samplesToRead = int (stopSample - currentSample);
749
774
if (samplesToRead > 0 )
750
775
input->readData (cacheBuffer + samplesRead * currentNumChannels, samplesToRead);
751
776
0 commit comments