mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-17 19:24:52 -04:00
Core: Replace global Qt declarations with standard equivalents (#6821)
* Replace qAbs with std::abs * Replace qBound with std::clamp * Replace qMax with std::max * Replace qMin with std::min * Replace qRound with std::round * Replace qgetenv with std::getenv --------- Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
This commit is contained in:
@@ -456,10 +456,10 @@ void SampleBuffer::normalizeSampleRate(const sample_rate_t srcSR, bool keepSetti
|
||||
{
|
||||
auto oldRateToNewRateRatio = static_cast<float>(audioEngineSampleRate()) / oldRate;
|
||||
|
||||
m_startFrame = qBound(0, f_cnt_t(m_startFrame * oldRateToNewRateRatio), m_frames);
|
||||
m_endFrame = qBound(m_startFrame, f_cnt_t(m_endFrame * oldRateToNewRateRatio), m_frames);
|
||||
m_loopStartFrame = qBound(0, f_cnt_t(m_loopStartFrame * oldRateToNewRateRatio), m_frames);
|
||||
m_loopEndFrame = qBound(m_loopStartFrame, f_cnt_t(m_loopEndFrame * oldRateToNewRateRatio), m_frames);
|
||||
m_startFrame = std::clamp(f_cnt_t(m_startFrame * oldRateToNewRateRatio), 0, m_frames);
|
||||
m_endFrame = std::clamp(f_cnt_t(m_endFrame * oldRateToNewRateRatio), m_startFrame, m_frames);
|
||||
m_loopStartFrame = std::clamp(f_cnt_t(m_loopStartFrame * oldRateToNewRateRatio), 0, m_frames);
|
||||
m_loopEndFrame = std::clamp(f_cnt_t(m_loopEndFrame * oldRateToNewRateRatio), m_loopStartFrame, m_frames);
|
||||
m_sampleRate = audioEngineSampleRate();
|
||||
}
|
||||
}
|
||||
@@ -736,7 +736,7 @@ bool SampleBuffer::play(
|
||||
|
||||
|
||||
// this holds the index of the first frame to play
|
||||
f_cnt_t playFrame = qMax(state->m_frameIndex, startFrame);
|
||||
f_cnt_t playFrame = std::max(state->m_frameIndex, startFrame);
|
||||
|
||||
if (loopMode == LoopOff)
|
||||
{
|
||||
@@ -915,12 +915,12 @@ sampleFrame * SampleBuffer::getSampleFragment(
|
||||
}
|
||||
else if (loopMode == LoopOn)
|
||||
{
|
||||
f_cnt_t copied = qMin(frames, loopEnd - index);
|
||||
f_cnt_t copied = std::min(frames, loopEnd - index);
|
||||
memcpy(*tmp, m_data + index, copied * BYTES_PER_FRAME);
|
||||
f_cnt_t loopFrames = loopEnd - loopStart;
|
||||
while (copied < frames)
|
||||
{
|
||||
f_cnt_t todo = qMin(frames - copied, loopFrames);
|
||||
f_cnt_t todo = std::min(frames - copied, loopFrames);
|
||||
memcpy(*tmp + copied, m_data + loopStart, todo * BYTES_PER_FRAME);
|
||||
copied += todo;
|
||||
}
|
||||
@@ -936,7 +936,7 @@ sampleFrame * SampleBuffer::getSampleFragment(
|
||||
|
||||
if (currentBackwards)
|
||||
{
|
||||
copied = qMin(frames, pos - loopStart);
|
||||
copied = std::min(frames, pos - loopStart);
|
||||
for (int i = 0; i < copied; i++)
|
||||
{
|
||||
(*tmp)[i][0] = m_data[pos - i][0];
|
||||
@@ -947,7 +947,7 @@ sampleFrame * SampleBuffer::getSampleFragment(
|
||||
}
|
||||
else
|
||||
{
|
||||
copied = qMin(frames, loopEnd - pos);
|
||||
copied = std::min(frames, loopEnd - pos);
|
||||
memcpy(*tmp, m_data + pos, copied * BYTES_PER_FRAME);
|
||||
pos += copied;
|
||||
if (pos == loopEnd) { currentBackwards = true; }
|
||||
@@ -957,7 +957,7 @@ sampleFrame * SampleBuffer::getSampleFragment(
|
||||
{
|
||||
if (currentBackwards)
|
||||
{
|
||||
f_cnt_t todo = qMin(frames - copied, pos - loopStart);
|
||||
f_cnt_t todo = std::min(frames - copied, pos - loopStart);
|
||||
for (int i = 0; i < todo; i++)
|
||||
{
|
||||
(*tmp)[copied + i][0] = m_data[pos - i][0];
|
||||
@@ -969,7 +969,7 @@ sampleFrame * SampleBuffer::getSampleFragment(
|
||||
}
|
||||
else
|
||||
{
|
||||
f_cnt_t todo = qMin(frames - copied, loopEnd - pos);
|
||||
f_cnt_t todo = std::min(frames - copied, loopEnd - pos);
|
||||
memcpy(*tmp + copied, m_data + pos, todo * BYTES_PER_FRAME);
|
||||
pos += todo;
|
||||
copied += todo;
|
||||
@@ -1085,8 +1085,8 @@ void SampleBuffer::visualize(
|
||||
|
||||
const float trueRmsData = (rmsData[0] + rmsData[1]) / 2 / fpp;
|
||||
const float sqrtRmsData = sqrt(trueRmsData);
|
||||
const float maxRmsData = qBound(minData, sqrtRmsData, maxData);
|
||||
const float minRmsData = qBound(minData, -sqrtRmsData, maxData);
|
||||
const float maxRmsData = std::clamp(sqrtRmsData, minData, maxData);
|
||||
const float minRmsData = std::clamp(-sqrtRmsData, minData, maxData);
|
||||
|
||||
// If nbFrames >= w, we can use curPixel to calculate X
|
||||
// but if nbFrames < w, we need to calculate it proportionally
|
||||
@@ -1291,7 +1291,7 @@ QString & SampleBuffer::toBase64(QString & dst) const
|
||||
|
||||
while (frameCnt < m_frames)
|
||||
{
|
||||
f_cnt_t remaining = qMin<f_cnt_t>(FRAMES_PER_BUF, m_frames - frameCnt);
|
||||
f_cnt_t remaining = std::min<f_cnt_t>(FRAMES_PER_BUF, m_frames - frameCnt);
|
||||
FLAC__int32 buf[FRAMES_PER_BUF * DEFAULT_CHANNELS];
|
||||
for (f_cnt_t f = 0; f < remaining; ++f)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user