Skip to content

Commit

Permalink
Add location test
Browse files Browse the repository at this point in the history
  • Loading branch information
abique committed Dec 20, 2024
1 parent 4c39a5e commit d05b1f1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 9 deletions.
2 changes: 2 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ add_library(
plugs/undo-test/undo-test.hxx
plugs/scratch-memory/scratch-memory.cc
plugs/scratch-memory/scratch-memory.hh
plugs/location/location.cc
plugs/location/location.hh
smoothed-value.hh
sample-delay.cc
sample-delay.hh
Expand Down
20 changes: 11 additions & 9 deletions plugins/clap-entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
#include "plugs/dc-offset/dc-offset.hh"
#include "plugs/gain/gain.hh"
#include "plugs/latency/latency.hh"
#include "plugs/location/location.hh"
#include "plugs/offline-latency/offline-latency.hh"
#include "plugs/realtime-requirement/realtime-requirement.hh"
#include "plugs/scratch-memory/scratch-memory.hh"
#include "plugs/svf/svf-plug.hh"
#include "plugs/synth/synth.hh"
#include "plugs/track-info/track-info.hh"
#include "plugs/transport/transport-info.hh"
#include "plugs/undo-test/undo-test.hxx"
#include "plugs/scratch-memory/scratch-memory.hh"

struct PluginEntry {
using create_func = std::function<const clap_plugin *(const clap_host &)>;
Expand All @@ -44,21 +45,22 @@ static void addPlugin() {
static bool clap_init(const char *plugin_path) {
g_pluginPath = plugin_path;

addPlugin<clap::Synth>();
addPlugin<clap::AdsrPlug>();
addPlugin<clap::CharCheck>();
addPlugin<clap::DcOffset>();
addPlugin<clap::TransportInfo>();
addPlugin<clap::Gain>();
addPlugin<clap::CharCheck>();
addPlugin<clap::AdsrPlug>();
addPlugin<clap::SvfPlug>();
addPlugin<clap::Latency>();
addPlugin<clap::Location>();
addPlugin<clap::OfflineLatency>();
addPlugin<clap::RealtimeRequirement>();
addPlugin<clap::ScratchMemory>();
addPlugin<clap::SvfPlug>();
addPlugin<clap::Synth>();
addPlugin<clap::TrackInfo>();
addPlugin<clap::UndoTest<true, true>>();
addPlugin<clap::UndoTest<true, false>>();
addPlugin<clap::TransportInfo>();
addPlugin<clap::UndoTest<false, false>>();
addPlugin<clap::ScratchMemory>();
addPlugin<clap::UndoTest<true, false>>();
addPlugin<clap::UndoTest<true, true>>();
return true;
}

Expand Down
56 changes: 56 additions & 0 deletions plugins/plugs/location/location.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <cstring>
#include <sstream>

#include "location.hh"

namespace clap {
class LocationModule final : public Module {
public:
LocationModule(Location &plugin) : Module(plugin, "", 0) {}

clap_process_status process(const Context &c, uint32_t numFrames) noexcept override {
return CLAP_PROCESS_SLEEP;
}
};

const clap_plugin_descriptor *Location::descriptor() {
static const char *features[] = {
CLAP_PLUGIN_FEATURE_UTILITY, CLAP_PLUGIN_FEATURE_ANALYZER, nullptr};

static const clap_plugin_descriptor desc = {CLAP_VERSION,
"com.github.free-audio.clap.location",
"Location Test",
"clap",
"https://github.com/free-audio/clap",
nullptr,
nullptr,
"1",
"Displays current plugin location",
features};

return &desc;
}

Location::Location(const std::string &pluginPath, const clap_host &host)
: CorePlugin(PathProvider::create(pluginPath, "track-info"), descriptor(), host) {
_rootModule = std::make_unique<LocationModule>(*this);
}

void Location::locationSetLocation(const clap_plugin_location_element_t *path,
uint32_t num_elements) noexcept {
std::ostringstream loc;

loc << "plugin location: [";
for (uint32_t i = 0; i < num_elements; ++i) {
auto &elt = path[i];

loc << "{ " << "kind: " << elt.kind << ", name: " << elt.name << ", id: " << elt.id
<< ", index: " << elt.index << ", color: {" << elt.color.red << ", " << elt.color.green
<< ", " << elt.color.blue << ", " << elt.color.alpha << " }, " << " }, ";
}
loc << "]";
auto msg = loc.str();

_host.log(CLAP_LOG_INFO, msg.c_str());
}
} // namespace clap
19 changes: 19 additions & 0 deletions plugins/plugs/location/location.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "../../core-plugin.hh"

namespace clap {
class Location final : public CorePlugin {
private:
using super = CorePlugin;

public:
Location(const std::string &pluginPath, const clap_host &host);

bool implementsLocation() const noexcept override { return true; }
void locationSetLocation(const clap_plugin_location_element_t *path,
uint32_t num_elements) noexcept override;

static const clap_plugin_descriptor *descriptor();
};
} // namespace clap

0 comments on commit d05b1f1

Please sign in to comment.