Skip to content

Commit

Permalink
Revert "Fix errors"
Browse files Browse the repository at this point in the history
This reverts commit 8e40921.
  • Loading branch information
sakertooth committed Jul 4, 2024
1 parent 5b5e4b7 commit 1374831
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 27 deletions.
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 -> f_cnt_t
auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> int
{
// 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 -> f_cnt_t
: m_nextPlayStartPoint;
const auto duration = m_sample.endFrame() - startFrame;

return static_cast<f_cnt_t>(std::floor(duration * freqFactor));
return static_cast<int>(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 -> f_cnt_t override;
auto beatLen(NotePlayHandle* note) const -> int override;

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


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

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

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

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

f_cnt_t AudioFileProcessorWaveView::range() const
Expand Down Expand Up @@ -348,19 +347,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 = std::max<f_cnt_t>(1, std::max(d_from, d_to) / 10);
const f_cnt_t step = qMax(1, qMax(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 = static_cast<double>(std::min(d_from, d_to)) / std::max<f_cnt_t>(1, qMax(d_from, d_to));
const double comp_ratio = double(qMin(d_from, d_to))
/ qMax(1, qMax(d_from, d_to));

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 boundedFrom = std::clamp(m_from + step_from, 0, start);
const auto boundedTo = std::clamp(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<f_cnt_t>(m_from + toStep, 0, start);
const auto newFrom
= (out && d_from < d_to) || (!out && d_to < d_from) ? boundedFrom : std::clamp(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: 2 additions & 3 deletions plugins/Lb302/Lb302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/

// 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 @@ -751,8 +750,8 @@ void Lb302Synth::playNote( NotePlayHandle * _n, SampleFrame* _working_buffer )
m_notes.prepend( _n );
}
m_notesMutex.unlock();

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


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

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

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

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

m_buffer.writeAddingMultiplied( buf, 0, frames, dryGain );
// swapped inputs?
if( swapInputs )
{
Expand Down Expand Up @@ -177,4 +176,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data )
}


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

#include <algorithm>
#include <cstdlib>
Expand Down Expand Up @@ -100,7 +99,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<f_cnt_t>(static_cast<f_cnt_t>(srcFrameFloat), 1, srcFrames - 3);
const f_cnt_t srcFrame = std::clamp(static_cast<f_cnt_t>(srcFrameFloat), 1, srcFrames - 3);
m_impulse[frame] = cubicInterpolate(
src[srcFrame - 1],
src[srcFrame + 0],
Expand Down
3 changes: 1 addition & 2 deletions src/core/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "MixHelpers.h"
#include "denormals.h"

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

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

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

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


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

const auto endFrame = _n->framesLeft();
const auto startFrame = std::max<f_cnt_t>(0, endFrame - releaseFrames);
const auto startFrame = std::max(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<fpp_t>(1024, audioEngine()->framesPerPeriod() * 2);
m_audioHandle.samples = std::max(1024, audioEngine()->framesPerPeriod() * 2);

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

0 comments on commit 1374831

Please sign in to comment.