Skip to content

Commit

Permalink
Add member variable for base sample rate and inline sample rate gette…
Browse files Browse the repository at this point in the history
…r functions (#7552)

Co-authored-by: saker <sakertooth@gmail.com>
  • Loading branch information
Rossmaxx and sakertooth authored Oct 30, 2024
1 parent b5de1d5 commit 9912fd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
19 changes: 16 additions & 3 deletions include/AudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <memory>
#include <vector>

#include "AudioDevice.h"
#include "lmms_basics.h"
#include "SampleFrame.h"
#include "LocklessList.h"
Expand Down Expand Up @@ -235,9 +236,20 @@ class LMMS_EXPORT AudioEngine : public QObject
}


sample_rate_t baseSampleRate() const;
sample_rate_t outputSampleRate() const;
sample_rate_t inputSampleRate() const;
sample_rate_t baseSampleRate() const { return m_baseSampleRate; }


sample_rate_t outputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() : m_baseSampleRate;
}


sample_rate_t inputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() : m_baseSampleRate;
}


inline float masterGain() const
{
Expand Down Expand Up @@ -361,6 +373,7 @@ class LMMS_EXPORT AudioEngine : public QObject
SampleFrame* m_inputBuffer[2];
f_cnt_t m_inputBufferFrames[2];
f_cnt_t m_inputBufferSize[2];
sample_rate_t m_baseSampleRate;
int m_inputBufferRead;
int m_inputBufferWrite;

Expand Down
29 changes: 1 addition & 28 deletions src/core/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static thread_local bool s_renderingThread = false;
AudioEngine::AudioEngine( bool renderOnly ) :
m_renderOnly( renderOnly ),
m_framesPerPeriod( DEFAULT_BUFFER_SIZE ),
m_baseSampleRate(std::max(ConfigManager::inst()->value("audioengine", "samplerate").toInt(), 44100)),
m_inputBufferRead( 0 ),
m_inputBufferWrite( 1 ),
m_outputBufferRead(nullptr),
Expand Down Expand Up @@ -241,34 +242,6 @@ void AudioEngine::stopProcessing()



sample_rate_t AudioEngine::baseSampleRate() const
{
sample_rate_t sr = ConfigManager::inst()->value( "audioengine", "samplerate" ).toInt();
if( sr < 44100 )
{
sr = 44100;
}
return sr;
}




sample_rate_t AudioEngine::outputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
baseSampleRate();
}




sample_rate_t AudioEngine::inputSampleRate() const
{
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
baseSampleRate();
}

bool AudioEngine::criticalXRuns() const
{
return cpuLoad() >= 99 && Engine::getSong()->isExporting() == false;
Expand Down

0 comments on commit 9912fd8

Please sign in to comment.