commit 184ea1faaa873d0ae47b069f7016e7b45ee846b2
parent f0dc0ce102fe2f1173e36e3371c2966fb0eb9b32
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Wed, 15 Sep 2021 13:53:24 +0200
Add new transport info plugin and refactor
Diffstat:
10 files changed, 211 insertions(+), 108 deletions(-)
diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt
@@ -20,10 +20,13 @@ add_library(
remote-gui.hh
remote-gui.cc
- dc-offset/dc-offset.hh
- dc-offset/dc-offset.cc
- gain/gain.hh
- gain/gain.cc)
+ plugs/dc-offset/dc-offset.hh
+ plugs/dc-offset/dc-offset.cc
+ plugs/gain/gain.hh
+ plugs/gain/gain.cc
+ plugs/transport/transport-info.hh
+ plugs/transport/transport-info.cc)
+
target_link_libraries(clap-plugins clap-plugin-glue clap-io Boost::serialization Boost::iostreams)
target_link_libraries(clap-plugins -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linux-clap-plugins.version)
target_link_libraries(clap-plugins -Wl,-z,defs)
diff --git a/examples/plugins/clap-entry.cc b/examples/plugins/clap-entry.cc
@@ -6,8 +6,9 @@
#include <sstream>
#include <vector>
-#include "dc-offset/dc-offset.hh"
-#include "gain/gain.hh"
+#include "plugs/dc-offset/dc-offset.hh"
+#include "plugs/gain/gain.hh"
+#include "plugs/transport/transport-info.hh"
#include "path-provider.hh"
struct PluginEntry {
@@ -36,6 +37,7 @@ static bool clap_init(const char *plugin_path) {
addPlugin<clap::Gain>();
addPlugin<clap::DcOffset>();
+ addPlugin<clap::TransportInfo>();
return true;
}
diff --git a/examples/plugins/dc-offset/dc-offset.cc b/examples/plugins/dc-offset/dc-offset.cc
@@ -1,101 +0,0 @@
-#include <cstring>
-
-#include "../parameter-interpolator.hh"
-#include "dc-offset.hh"
-
-namespace clap {
- const clap_plugin_descriptor *DcOffset::descriptor() {
- static const clap_plugin_descriptor desc = {
-
- CLAP_VERSION,
- "com.github.free-audio.clap.dc-offset",
- "dc offset",
- "clap",
- "https://github.com/free-audio/clap",
- nullptr,
- nullptr,
- "0.1",
- "example DC offset plugin",
- "utility",
- CLAP_PLUGIN_AUDIO_EFFECT
-
- };
- return &desc;
- }
-
- enum {
- kParamIdOffset = 0,
- };
-
- DcOffset::DcOffset(const std::string &pluginPath, const clap_host *host)
- : CorePlugin(PathProvider::create(pluginPath, "dc-offset"), descriptor(), host) {
- _parameters.addParameter(clap_param_info{
- kParamIdOffset,
- CLAP_PARAM_IS_MODULATABLE | CLAP_PARAM_REQUIRES_PROCESS,
- nullptr,
- "offset",
- "/",
- -1,
- 1,
- 0,
- });
-
- _offsetParam = _parameters.getById(kParamIdOffset);
- }
-
- bool DcOffset::init() noexcept {
- if (!super::init())
- return false;
-
- defineAudioPorts();
- return true;
- }
-
- void DcOffset::defineAudioPorts() noexcept {
- assert(!isActive());
-
- _channelCount = trackChannelCount();
-
- clap_audio_port_info info;
- info.id = 0;
- strncpy(info.name, "main", sizeof(info.name));
- info.is_main = true;
- info.is_cv = false;
- info.sample_size = 32;
- info.in_place = true;
- info.channel_count = _channelCount;
- info.channel_map = CLAP_CHMAP_UNSPECIFIED;
-
- _audioInputs.clear();
- _audioInputs.push_back(info);
- _audioOutputs.clear();
- _audioOutputs.push_back(info);
- }
-
- clap_process_status DcOffset::process(const clap_process *process) noexcept {
- float **in = process->audio_inputs[0].data32;
- float **out = process->audio_outputs[0].data32;
- uint32_t evCount = process->in_events->size(process->in_events);
- uint32_t nextEvIndex = 0;
- uint32_t N = process->frames_count;
-
- processGuiEvents(process);
-
- /* foreach frames */
- for (uint32_t i = 0; i < process->frames_count;) {
-
- N = processEvents(process, nextEvIndex, evCount, i);
-
- /* Process as many samples as possible until the next event */
- for (; i < N; ++i) {
- const float offset = _offsetParam->step();
- for (int c = 0; c < _channelCount; ++c)
- out[c][i] = in[c][i] + offset;
- }
- }
-
- _pluginToGuiQueue.producerDone();
-
- return CLAP_PROCESS_CONTINUE_IF_NOT_QUIET;
- }
-} // namespace clap
-\ No newline at end of file
diff --git a/examples/plugins/plugs/dc-offset/dc-offset.cc b/examples/plugins/plugs/dc-offset/dc-offset.cc
@@ -0,0 +1,101 @@
+#include <cstring>
+
+#include "../../parameter-interpolator.hh"
+#include "dc-offset.hh"
+
+namespace clap {
+ const clap_plugin_descriptor *DcOffset::descriptor() {
+ static const clap_plugin_descriptor desc = {
+
+ CLAP_VERSION,
+ "com.github.free-audio.clap.dc-offset",
+ "DC Offset",
+ "clap",
+ "https://github.com/free-audio/clap",
+ nullptr,
+ nullptr,
+ "0.1",
+ "Example DC Offset plugin",
+ "utility",
+ CLAP_PLUGIN_AUDIO_EFFECT
+
+ };
+ return &desc;
+ }
+
+ enum {
+ kParamIdOffset = 0,
+ };
+
+ DcOffset::DcOffset(const std::string &pluginPath, const clap_host *host)
+ : CorePlugin(PathProvider::create(pluginPath, "dc-offset"), descriptor(), host) {
+ _parameters.addParameter(clap_param_info{
+ kParamIdOffset,
+ CLAP_PARAM_IS_MODULATABLE | CLAP_PARAM_REQUIRES_PROCESS,
+ nullptr,
+ "offset",
+ "/",
+ -1,
+ 1,
+ 0,
+ });
+
+ _offsetParam = _parameters.getById(kParamIdOffset);
+ }
+
+ bool DcOffset::init() noexcept {
+ if (!super::init())
+ return false;
+
+ defineAudioPorts();
+ return true;
+ }
+
+ void DcOffset::defineAudioPorts() noexcept {
+ assert(!isActive());
+
+ _channelCount = trackChannelCount();
+
+ clap_audio_port_info info;
+ info.id = 0;
+ strncpy(info.name, "main", sizeof(info.name));
+ info.is_main = true;
+ info.is_cv = false;
+ info.sample_size = 32;
+ info.in_place = true;
+ info.channel_count = _channelCount;
+ info.channel_map = CLAP_CHMAP_UNSPECIFIED;
+
+ _audioInputs.clear();
+ _audioInputs.push_back(info);
+ _audioOutputs.clear();
+ _audioOutputs.push_back(info);
+ }
+
+ clap_process_status DcOffset::process(const clap_process *process) noexcept {
+ float **in = process->audio_inputs[0].data32;
+ float **out = process->audio_outputs[0].data32;
+ uint32_t evCount = process->in_events->size(process->in_events);
+ uint32_t nextEvIndex = 0;
+ uint32_t N = process->frames_count;
+
+ processGuiEvents(process);
+
+ /* foreach frames */
+ for (uint32_t i = 0; i < process->frames_count;) {
+
+ N = processEvents(process, nextEvIndex, evCount, i);
+
+ /* Process as many samples as possible until the next event */
+ for (; i < N; ++i) {
+ const float offset = _offsetParam->step();
+ for (int c = 0; c < _channelCount; ++c)
+ out[c][i] = in[c][i] + offset;
+ }
+ }
+
+ _pluginToGuiQueue.producerDone();
+
+ return CLAP_PROCESS_CONTINUE_IF_NOT_QUIET;
+ }
+} // namespace clap
+\ No newline at end of file
diff --git a/examples/plugins/dc-offset/dc-offset.hh b/examples/plugins/plugs/dc-offset/dc-offset.hh
diff --git a/examples/plugins/gain/gain.cc b/examples/plugins/plugs/gain/gain.cc
diff --git a/examples/plugins/gain/gain.hh b/examples/plugins/plugs/gain/gain.hh
diff --git a/examples/plugins/plugs/transport/transport-info.cc b/examples/plugins/plugs/transport/transport-info.cc
@@ -0,0 +1,40 @@
+#include <cstring>
+
+#include "../../parameter-interpolator.hh"
+#include "transport-info.hh"
+
+namespace clap {
+ const clap_plugin_descriptor *TransportInfo::descriptor() {
+ static const clap_plugin_descriptor desc = {
+
+ CLAP_VERSION,
+ "com.github.free-audio.clap.transport-info",
+ "Transport Info",
+ "clap",
+ "https://github.com/free-audio/clap",
+ nullptr,
+ nullptr,
+ "0.1",
+ "Displays transport info",
+ "utility",
+ CLAP_PLUGIN_AUDIO_EFFECT
+
+ };
+ return &desc;
+ }
+
+ enum {
+ kParamIdOffset = 0,
+ };
+
+ TransportInfo::TransportInfo(const std::string &pluginPath, const clap_host *host)
+ : CorePlugin(PathProvider::create(pluginPath, "transport-info"), descriptor(), host) {}
+
+ clap_process_status TransportInfo::process(const clap_process *process) noexcept {
+ processGuiEvents(process);
+
+ _pluginToGuiQueue.producerDone();
+
+ return CLAP_PROCESS_CONTINUE_IF_NOT_QUIET;
+ }
+} // namespace clap
+\ No newline at end of file
diff --git a/examples/plugins/plugs/transport/transport-info.hh b/examples/plugins/plugs/transport/transport-info.hh
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "../../core-plugin.hh"
+
+namespace clap {
+ class TransportInfo final : public CorePlugin {
+ private:
+ using super = CorePlugin;
+
+ public:
+ TransportInfo(const std::string& pluginPath, const clap_host *host);
+
+ static const clap_plugin_descriptor *descriptor();
+
+ protected:
+ clap_process_status process(const clap_process *process) noexcept override;
+ };
+} // namespace clap
+\ No newline at end of file
diff --git a/examples/plugins/qml/transport-info/main.qml b/examples/plugins/qml/transport-info/main.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.1
+import QtQuick.Controls 2.1
+import clap 1.0
+
+Rectangle {
+ width: 400
+ height: 600
+ color: "#f8f8f8"
+
+ Text {
+ text: "Has transport: " + transport.hasTransport + "\n"
+ + (!transport.hasTransport ? "" :
+ + "Is playing: " + transport.isPlaying + "\n"
+ + "Is recording: " + transport.isRecording + "\n"
+ + "Is loop active: " + transport.isLoopActive + "\n"
+ + (!(transport.isLoopActive && transport.hasBeatsTimeline) ? "" :
+ + "Loop (beats): " + transport.loopStartBeats + " .. " + transport.loopEndBeats)
+ + (!(transport.isLoopActive && transport.hasSecondsTimeline) ? "" :
+ + "Loop (seconds): " + transport.loopStartSeconds + " .. " + transport.loopEndSeconds)
+ + "Is within preroll: " + transport.isWithinPreroll + "\n"
+ + "Has tempo: " + transport.hasTempo + "\n"
+ + (!transport.hasTempo ? "" :
+ + "Tempo (bpm): " + transport.tempo)
+ + "Has beats timeline: " + transport.hasBeatsTimeline + "\n"
+ + (!transport.hasBeatsTimeline ? "" :
+ + "song position (beats): " + transport.songPositionBeats)
+ + (!transport.hasSecondsTimeline ? "" :
+ + "song position (seconds): " + transport.songPositionSeconds)
+ + "Has Time Signature: " + transport.hasTimeSignature + "\n"
+ + (!transport.hasTimeSignature ? "" :
+ + "Time Signature: " + transport.timeSignatureNumerator + "/" + transport.timeSignatureDenominator)
+ )
+ }
+
+ Component.onCompleted: {
+ transport.isSubscribed = true;
+ }
+}