Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix errors
  • Loading branch information
sakertooth committed Jul 3, 2024
commit 8e4092109781d5e8d966c71ba814bdb098741fc2
4 changes: 2 additions & 2 deletions plugins/AudioFileProcessor/AudioFileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ QString AudioFileProcessor::nodeName() const



auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> int
auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> f_cnt_t
{
// If we can play indefinitely, use the default beat note duration
if (static_cast<Sample::Loop>(m_loopModel.value()) != Sample::Loop::Off) { return 0; }
Expand All @@ -292,7 +292,7 @@ auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> int
: m_nextPlayStartPoint;
const auto duration = m_sample.endFrame() - startFrame;

return static_cast<int>(std::floor(duration * freqFactor));
return static_cast<f_cnt_t>(std::floor(duration * freqFactor));
}


Expand Down
4 changes: 2 additions & 2 deletions plugins/AudioFileProcessor/AudioFileProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AudioFileProcessor : public Instrument

QString nodeName() const override;

auto beatLen(NotePlayHandle* note) const -> int override;
auto beatLen(NotePlayHandle* note) const -> f_cnt_t override;

float desiredReleaseTimeMs() const override
{
Expand Down Expand Up @@ -89,7 +89,7 @@ private slots:


signals:
void isPlaying( lmms::f_cnt_t _current_frame );
void isPlaying(f_cnt_t _current_frame);
void sampleUpdated();

private:
Expand Down
17 changes: 9 additions & 8 deletions plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ConfigManager.h"
#include "gui_templates.h"
#include "SampleWaveform.h"
#include "lmms_basics.h"

#include <QPainter>
#include <QMouseEvent>
Expand Down Expand Up @@ -57,7 +58,7 @@ void AudioFileProcessorWaveView::setTo(f_cnt_t to)

void AudioFileProcessorWaveView::setFrom(f_cnt_t from)
{
m_from = std::max(from, 0);
m_from = std::max<f_cnt_t>(from, 0);
}

f_cnt_t AudioFileProcessorWaveView::range() const
Expand Down Expand Up @@ -347,19 +348,19 @@ void AudioFileProcessorWaveView::zoom(const bool out)
const f_cnt_t d_from = start - m_from;
const f_cnt_t d_to = m_to - end;

const f_cnt_t step = qMax(1, qMax(d_from, d_to) / 10);
const f_cnt_t step = std::max<f_cnt_t>(1, std::max(d_from, d_to) / 10);
const f_cnt_t step_from = (out ? - step : step);
const f_cnt_t step_to = (out ? step : - step);

const double comp_ratio = double(qMin(d_from, d_to))
/ qMax(1, qMax(d_from, d_to));
const double comp_ratio = static_cast<double>(std::min(d_from, d_to)) / std::max<f_cnt_t>(1, qMax(d_from, d_to));

const auto boundedFrom = std::clamp(m_from + step_from, 0, start);
const auto boundedTo = std::clamp(m_to + step_to, end, frames);
const auto boundedFrom = std::clamp<f_cnt_t>(m_from + step_from, 0, start);
const auto boundedTo = std::clamp<f_cnt_t>(m_to + step_to, end, frames);

const auto toStep = static_cast<f_cnt_t>(step_from * (boundedTo == m_to ? 1 : comp_ratio));
const auto newFrom
= (out && d_from < d_to) || (!out && d_to < d_from) ? boundedFrom : std::clamp(m_from + toStep, 0, start);
const auto newFrom = (out && d_from < d_to) || (!out && d_to < d_from)
? boundedFrom
: std::clamp<f_cnt_t>(m_from + toStep, 0, start);

const auto fromStep = static_cast<f_cnt_t>(step_to * (boundedFrom == m_from ? 1 : comp_ratio));
const auto newTo
Expand Down
5 changes: 3 additions & 2 deletions plugins/Lb302/Lb302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

// Need to include this first to ensure we get M_PI in MinGW with C++11
#include "lmms_basics.h"
#define _USE_MATH_DEFINES
#include <cmath>

Expand Down Expand Up @@ -750,8 +751,8 @@ void Lb302Synth::playNote( NotePlayHandle * _n, SampleFrame* _working_buffer )
m_notes.prepend( _n );
}
m_notesMutex.unlock();
release_frame = qMax( release_frame, _n->framesLeft() + _n->offset() );

release_frame = std::max<f_cnt_t>(release_frame, _n->framesLeft() + _n->offset());
}


Expand Down
7 changes: 4 additions & 3 deletions plugins/MultitapEcho/MultitapEcho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "MultitapEcho.h"
#include "embed.h"
#include "lmms_basics.h"
#include "plugin_export.h"

namespace lmms
Expand Down Expand Up @@ -118,8 +119,8 @@ bool MultitapEchoEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frame
}

// add dry buffer - never swap inputs for dry
m_buffer.writeAddingMultiplied( buf, 0, frames, dryGain );
m_buffer.writeAddingMultiplied(buf, static_cast<f_cnt_t>(0), frames, dryGain);

// swapped inputs?
if( swapInputs )
{
Expand Down Expand Up @@ -176,4 +177,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data )
}


} // namespace lmms
} // namespace lmms
3 changes: 2 additions & 1 deletion plugins/Vibed/VibratingString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "interpolation.h"
#include "AudioEngine.h"
#include "Engine.h"
#include "lmms_basics.h"

#include <algorithm>
#include <cstdlib>
Expand Down Expand Up @@ -99,7 +100,7 @@ void VibratingString::resample(const float* src, f_cnt_t srcFrames, f_cnt_t dstF
{
const float srcFrameFloat = frame * static_cast<float>(srcFrames) / dstFrames;
const float fracPos = srcFrameFloat - static_cast<f_cnt_t>(srcFrameFloat);
const f_cnt_t srcFrame = std::clamp(static_cast<f_cnt_t>(srcFrameFloat), 1, srcFrames - 3);
const f_cnt_t srcFrame = std::clamp<f_cnt_t>(static_cast<f_cnt_t>(srcFrameFloat), 1, srcFrames - 3);
Comment thread
sakertooth marked this conversation as resolved.
Outdated
m_impulse[frame] = cubicInterpolate(
src[srcFrame - 1],
src[srcFrame + 0],
Expand Down
3 changes: 2 additions & 1 deletion src/core/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "MixHelpers.h"
#include "denormals.h"

#include "lmms_basics.h"
#include "lmmsconfig.h"

#include "AudioEngineWorkerThread.h"
Expand Down Expand Up @@ -288,7 +289,7 @@ void AudioEngine::pushInputFrames( SampleFrame* _ab, const f_cnt_t _frames )

if( frames + _frames > size )
{
size = std::max(size * 2, frames + _frames);
size = std::max<f_cnt_t>(size * 2, frames + _frames);
auto ab = new SampleFrame[size];
memcpy( ab, buf, frames * sizeof( SampleFrame ) );
delete [] buf;
Expand Down
3 changes: 2 additions & 1 deletion src/core/Instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "DummyInstrument.h"
#include "InstrumentTrack.h"
#include "lmms_basics.h"
#include "lmms_constants.h"


Expand Down Expand Up @@ -185,7 +186,7 @@ void Instrument::applyRelease( SampleFrame* buf, const NotePlayHandle * _n )
const auto releaseFrames = desiredReleaseFrames();

const auto endFrame = _n->framesLeft();
const auto startFrame = std::max(0, endFrame - releaseFrames);
const auto startFrame = std::max<f_cnt_t>(0, endFrame - releaseFrames);

for (auto f = startFrame; f < endFrame && f < fpp; f++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/audio/AudioSdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) :
// to convert the buffers
#endif
m_audioHandle.channels = channels();
m_audioHandle.samples = std::max(1024, audioEngine()->framesPerPeriod() * 2);
m_audioHandle.samples = std::max<fpp_t>(1024, audioEngine()->framesPerPeriod() * 2);

m_audioHandle.callback = sdlAudioCallback;
m_audioHandle.userdata = this;
Expand Down