Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
messmerd committed Nov 7, 2024
1 parent b7ed5a0 commit 0dec314
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 27 deletions.
5 changes: 3 additions & 2 deletions include/ClapAudioPorts.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "lmms_export.h"
#include "PluginIssue.h"
#include "PluginPortConfig.h"
#include "SampleFrame.h"

namespace lmms
{
Expand Down Expand Up @@ -114,8 +115,8 @@ class LMMS_EXPORT ClapAudioPorts final

auto extensionId() const -> std::string_view override { return CLAP_EXT_AUDIO_PORTS; }

void copyBuffersFromCore(const sampleFrame* buffer, fpp_t frames);
void copyBuffersToCore(sampleFrame* buffer, fpp_t frames) const;
void copyBuffersFromCore(const SampleFrame* buffer, fpp_t frames);
void copyBuffersToCore(SampleFrame* buffer, fpp_t frames) const;

private:
auto hostExtImpl() const -> const clap_host_audio_ports* override { return nullptr; } // not impl for host yet
Expand Down
16 changes: 6 additions & 10 deletions plugins/ClapEffect/ClapEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ ClapEffect::ClapEffect(Model* parent, const Descriptor::SubPluginFeatures::Key*
, m_tempOutputSamples(Engine::audioEngine()->framesPerPeriod())
{
connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged, this,
[&] { m_tempOutputSamples.reserve(Engine::audioEngine()->framesPerPeriod()); });
[&] { m_tempOutputSamples.resize(Engine::audioEngine()->framesPerPeriod()); });
}

bool ClapEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
auto ClapEffect::processImpl(SampleFrame* buf, const fpp_t frames) -> ProcessStatus
{
ClapInstance* instance = m_controls.m_instance.get();

if (!isEnabled() || !isRunning() || !instance) { return false; }
assert(instance != nullptr);
assert(frames <= static_cast<fpp_t>(m_tempOutputSamples.size()));

instance->audioPorts().copyBuffersFromCore(buf, frames);
Expand All @@ -87,8 +86,8 @@ bool ClapEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
instance->copyModelsToCore();
instance->audioPorts().copyBuffersToCore(m_tempOutputSamples.data(), frames);

sampleFrame* leftSamples = m_tempOutputSamples.data();
sampleFrame* rightSamples = m_tempOutputSamples.data();
SampleFrame* leftSamples = m_tempOutputSamples.data();
SampleFrame* rightSamples = m_tempOutputSamples.data();
switch (instance->audioPorts().portConfig<false>())
{
case PluginPortConfig::Config::LeftOnly:
Expand All @@ -98,7 +97,6 @@ bool ClapEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
default: break;
}

double outSum = 0.0;
bool corrupt = wetLevel() < 0.f; // #3261 - if wet < 0, bash wet := 0, dry := 1
const float dry = corrupt ? 1.f : dryLevel();
const float wet = corrupt ? 0.f : wetLevel();
Expand All @@ -109,11 +107,9 @@ bool ClapEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
buf[f][1] = dry * buf[f][1] + wet * rightSamples[f][1];
auto left = static_cast<double>(buf[f][0]);
auto right = static_cast<double>(buf[f][1]);
outSum += left * left + right * right;
}
checkGate(outSum / frames);

return isRunning();
return ProcessStatus::ContinueIfNotQuiet;
}

} // namespace lmms
4 changes: 2 additions & 2 deletions plugins/ClapEffect/ClapEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ClapEffect : public Effect
//! Must be checked after ctor or reload
auto isValid() const -> bool { return m_controls.isValid(); }

auto processAudioBuffer(sampleFrame* buf, const fpp_t frames) -> bool override;
auto processImpl(SampleFrame* buf, const fpp_t frames) -> ProcessStatus override;
auto controls() -> EffectControls* override { return &m_controls; }

auto clapControls() -> ClapFxControls* { return &m_controls; }
Expand All @@ -52,7 +52,7 @@ class ClapEffect : public Effect
private:
ClapFxControls m_controls;

std::vector<sampleFrame> m_tempOutputSamples;
std::vector<SampleFrame> m_tempOutputSamples;
};

} // namespace lmms
Expand Down
2 changes: 1 addition & 1 deletion plugins/ClapInstrument/ClapInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ auto ClapInstrument::handleMidiEvent(const MidiEvent& event, const TimePos& time
return true;
}

void ClapInstrument::play(sampleFrame* buffer)
void ClapInstrument::play(SampleFrame* buffer)
{
if (!m_instance) { return; }

Expand Down
2 changes: 1 addition & 1 deletion plugins/ClapInstrument/ClapInstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ClapInstrument : public Instrument
*/
auto hasNoteInput() const -> bool override;
auto handleMidiEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset) -> bool override;
void play(sampleFrame* buffer) override;
void play(SampleFrame* buffer) override;

auto instantiateView(QWidget* parent) -> gui::PluginView* override;

Expand Down
1 change: 1 addition & 0 deletions src/core/PresetDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ auto PresetDatabase::findOrLoadPresets(std::string_view file) -> std::vector<con
loadPresets(location, file, presets);

std::vector<const Preset*> results;
results.reserve(presets.size());
for (const auto& preset : presets)
{
results.push_back(&preset);
Expand Down
12 changes: 6 additions & 6 deletions src/core/clap/ClapAudioPorts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace lmms
namespace
{
template<bool stereo>
inline void copyBuffersHostToPlugin(const sampleFrame* hostBuf, float** pluginBuf,
inline void copyBuffersHostToPlugin(const SampleFrame* hostBuf, float** pluginBuf,
unsigned channel, fpp_t frames)
{
for (fpp_t f = 0; f < frames; ++f)
Expand All @@ -47,7 +47,7 @@ namespace
}
}

inline void copyBuffersStereoHostToMonoPlugin(const sampleFrame* hostBuf, float** pluginBuf,
inline void copyBuffersStereoHostToMonoPlugin(const SampleFrame* hostBuf, float** pluginBuf,
unsigned channel, fpp_t frames)
{
for (fpp_t f = 0; f < frames; ++f)
Expand All @@ -57,7 +57,7 @@ namespace
}

template<bool stereo>
inline void copyBuffersPluginToHost(float** pluginBuf, sampleFrame* hostBuf,
inline void copyBuffersPluginToHost(float** pluginBuf, SampleFrame* hostBuf,
std::uint64_t constantMask, unsigned channel, fpp_t frames)
{
const bool isLeftConstant = (constantMask & (1 << 0)) != 0;
Expand All @@ -79,7 +79,7 @@ namespace
}
}

inline void copyBuffersMonoPluginToStereoHost(float** pluginBuf, sampleFrame* hostBuf,
inline void copyBuffersMonoPluginToStereoHost(float** pluginBuf, SampleFrame* hostBuf,
std::uint64_t constantMask, unsigned channel, fpp_t frames)
{
const bool isConstant = (constantMask & (1 << 0)) != 0;
Expand Down Expand Up @@ -364,7 +364,7 @@ auto ClapAudioPorts::checkSupported(const clap_plugin_audio_ports& ext) -> bool
return ext.count && ext.get;
}

void ClapAudioPorts::copyBuffersFromCore(const sampleFrame* buffer, fpp_t frames)
void ClapAudioPorts::copyBuffersFromCore(const SampleFrame* buffer, fpp_t frames)
{
switch (portConfig<true>())
{
Expand All @@ -389,7 +389,7 @@ void ClapAudioPorts::copyBuffersFromCore(const sampleFrame* buffer, fpp_t frames
}
}

void ClapAudioPorts::copyBuffersToCore(sampleFrame* buffer, fpp_t frames) const
void ClapAudioPorts::copyBuffersToCore(SampleFrame* buffer, fpp_t frames) const
{
switch (portConfig<false>())
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/clap/ClapParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ auto ClapParams::rescan(clap_param_rescan_flags flags) -> bool
std::unordered_set<clap_id> paramIds(count * 2);
bool needToUpdateParamsCache = false;

for (std::int32_t idx = 0; idx < count; ++idx)
for (std::uint32_t idx = 0; idx < count; ++idx)
{
clap_param_info info{};
info.id = CLAP_INVALID_ID;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/ClapViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include "CustomTextKnob.h"
#include "embed.h"
#include "Engine.h"
#include "FontHelper.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "lmms_math.h"
#include "MainWindow.h"
#include "PixmapButton.h"
Expand Down Expand Up @@ -153,7 +153,7 @@ ClapViewBase::ClapViewBase(QWidget* pluginWidget, ClapInstance* instance)
m_toggleUIButton->setCheckable(true);
m_toggleUIButton->setChecked(false);
m_toggleUIButton->setIcon(embed::getIconPixmap("zoom"));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), 8));
m_toggleUIButton->setFont(adjustedToPixelSize(m_toggleUIButton->font(), SMALL_FONT_SIZE));
btnBox->addWidget(m_toggleUIButton);
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/PresetSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ void PresetSelector::updateMenu()
for (int idx = 0; idx < static_cast<int>(presets.size()); ++idx)
{
auto presetAction = new QAction{this};
connect(presetAction, &QAction::triggered, this, [=] { selectPreset(idx); });
connect(presetAction, &QAction::triggered, this, [this, idx] { selectPreset(idx); });

const auto isActive = m_presets->presetIndex().value_or(-1) == idx;
const auto isActive = static_cast<int>(m_presets->presetIndex().value_or(-1)) == idx;
if (isActive)
{
auto font = presetAction->font();
Expand Down

0 comments on commit 0dec314

Please sign in to comment.