Skip to content

Commit

Permalink
CLAP context menus in helpers; and owkr. Plus a patch (#108)
Browse files Browse the repository at this point in the history
* CLAP context menus in helpers; and owkr. Plus a patch

* unambig
  • Loading branch information
baconpaul authored Jan 8, 2025
1 parent 987a68a commit 66c3994
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 5 deletions.
Binary file added resources/factory_patches/Keys/Salty Saily.mp3
Binary file not shown.
6 changes: 5 additions & 1 deletion src/clap/six-sines-clap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct SixSinesClap : public plugHelper_t, sst::clap_juce_shim::EditorProvider
{
engine = std::make_unique<Synth>();

engine->clapHost = h;

clapJuceShim = std::make_unique<sst::clap_juce_shim::ClapJuceShim>(this);
clapJuceShim->setResizable(false);
}
Expand Down Expand Up @@ -343,8 +345,10 @@ struct SixSinesClap : public plugHelper_t, sst::clap_juce_shim::EditorProvider
ADD_SHIM_LINUX_TIMER(clapJuceShim)
std::unique_ptr<juce::Component> createEditor() override
{
return std::make_unique<baconpaul::six_sines::ui::SixSinesEditor>(
auto res = std::make_unique<baconpaul::six_sines::ui::SixSinesEditor>(
engine->audioToUi, engine->uiToAudio, [this]() { _host.paramsRequestFlush(); });
res->clapHost = _host.host();
return res;
}

bool registerOrUnregisterTimer(clap_id &id, int ms, bool reg) override
Expand Down
3 changes: 1 addition & 2 deletions src/dsp/matrix_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ struct MatrixNodeFrom : public EnvelopeSupport<Patch::MatrixNode>,
}
}


if (isrm)
{
// we want op * ( 1 - depth ) + op * rm * depth or
// op * ( 1 + depth ( rm - 1 ) )
// since the multiplier of depth is rmLevel and it starts at one that means
for (int i=0; i<blockSize; ++i)
for (int i = 0; i < blockSize; ++i)
{
onto.rmLevel[i] += modlev[i] * (from.output[i] - 1.0);
}
Expand Down
2 changes: 2 additions & 0 deletions src/synth/synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ struct Synth
sst::basic_blocks::dsp::VUPeak vuPeak;
int32_t updateVuEvery{(int32_t)(48000 * 2.5 / 60 / blockSize)}; // approx
int32_t lastVuUpdate{updateVuEvery};

const clap_host_t *clapHost{nullptr};
};
} // namespace baconpaul::six_sines
#endif // SYNTH_H
20 changes: 19 additions & 1 deletion src/ui/patch-data-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ struct PatchDiscrete : jdat::Discrete
int getMax() const override { return static_cast<int>(std::round(p->meta.maxVal)); }
};

inline const juce::Identifier &getParamComponentPropertyId()
{
static juce::Identifier idIndex{"sixsines-paramid"};
return idIndex;
}
inline void setParamIdOn(juce::Component *c, uint32_t pid)
{
c->getProperties().set(getParamComponentPropertyId(), (juce::int64)pid);
}
inline std::optional<uint32_t> getParamIdFrom(juce::Component *c)
{
auto hasidx = c->getProperties().getVarPointer(getParamComponentPropertyId());
if (hasidx)
return (uint32_t)((juce::int64)(*hasidx));
return std::nullopt;
}

template <typename P, typename T, typename Q, typename... Args>
void createComponent(SixSinesEditor &e, P &panel, const Param &parm, std::unique_ptr<T> &cm,
std::unique_ptr<Q> &pc, Args... args)
Expand Down Expand Up @@ -197,7 +214,7 @@ void createComponent(SixSinesEditor &e, P &panel, const Param &parm, std::unique
}
};
cm->setSource(pc.get());

setParamIdOn(cm.get(), id);
e.componentByID[id] = juce::Component::SafePointer<juce::Component>(cm.get());
e.panelSelectGestureFor[cm.get()] = [args..., &panel]() { panel.beginEdit(args...); };
}
Expand Down Expand Up @@ -233,6 +250,7 @@ void createRescaledComponent(SixSinesEditor &e, P &panel, const Param &parm, std
e.hideTooltip();
};
cm->setSource(rc.get());
setParamIdOn(cm.get(), id);

e.componentByID[id] = juce::Component::SafePointer<juce::Component>(cm.get());
e.panelSelectGestureFor[cm.get()] = [args..., &panel]() { panel.beginEdit(args...); };
Expand Down
9 changes: 9 additions & 0 deletions src/ui/six-sines-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "six-sines-editor.h"

#include "sst/clap_juce_shim/menu_helper.h"

#include "finetune-sub-panel.h"
#include "patch-data-bindings.h"
#include "main-panel.h"
Expand Down Expand Up @@ -496,6 +498,13 @@ void SixSinesEditor::popupMenuForContinuous(jcmp::ContinuousParamEditor *e)
w->repaint();
});

// I could also stick the param id onto the component properties I guess
auto pid = getParamIdFrom(e);
if (pid.has_value())
{
sst::clap_juce_shim::populateMenuForClapParam(p, *pid, clapHost);
}

p.showMenuAsync(juce::PopupMenu::Options().withParentComponent(this));
}

Expand Down
2 changes: 2 additions & 0 deletions src/ui/six-sines-editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ struct SixSinesEditor : jcmp::WindowPanel
std::unique_ptr<sst::jucegui::accessibility::FocusDebugger> focusDebugger;

std::unordered_map<juce::Component *, std::function<void()>> panelSelectGestureFor;

const clap_host_t *clapHost{nullptr};
};

struct HasEditor
Expand Down

0 comments on commit 66c3994

Please sign in to comment.