-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |