-
Notifications
You must be signed in to change notification settings - Fork 5
/
anira-clap-demo.h
95 lines (69 loc) · 2.95 KB
/
anira-clap-demo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef ANIRA_CLAP_PLUGIN_EXAMPLE_H
#define ANIRA_CLAP_PLUGIN_EXAMPLE_H
#include <iostream>
#include <clap/helpers/plugin.hh>
#include <clap/helpers/plugin-proxy.hh>
#include <atomic>
#include <array>
#include <unordered_map>
#include <memory>
#include <anira/anira.h>
#include "../../extras/models/hybrid-nn/HybridNNConfig.h"
#include "../../extras/models/hybrid-nn/HybridNNPrePostProcessor.h"
#include "../../extras/models/hybrid-nn/HybridNNBypassProcessor.h"
#include "utils/DryWetMixer.h"
namespace clap_plugin_example
{
struct AniraClapPluginExample : public clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>
{
AniraClapPluginExample(const clap_host *host);
~AniraClapPluginExample();
static clap_plugin_descriptor m_desc;
bool activate(double sampleRate, uint32_t minFrameCount,
uint32_t maxFrameCount) noexcept override;
enum ParamIds : uint32_t
{
pmDryWet = 14256,
pmBackend = 14257
};
static constexpr int m_number_params = 2;
bool implementsParams() const noexcept override { return true; }
bool isValidParamId(clap_id paramId) const noexcept override;
uint32_t paramsCount() const noexcept override;
bool paramsInfo(uint32_t paramIndex, clap_param_info *info) const noexcept override;
bool paramsValue(clap_id paramId, double *value) noexcept override;
bool paramsValueToText(clap_id paramId, double value, char *display,
uint32_t size) noexcept override;
protected:
bool paramsTextToValue(clap_id paramId, const char *display, double *value) noexcept override;
public:
bool implementsAudioPorts() const noexcept override { return true; }
uint32_t audioPortsCount(bool isInput) const noexcept override;
bool audioPortsInfo(uint32_t index, bool isInput,
clap_audio_port_info *info) const noexcept override;
clap_process_status process(const clap_process *process) noexcept override;
void checkForEvents(const clap_process *process);
void handleInboundEvent(const clap_event_header_t *evt);
void paramsFlush(const clap_input_events *in, const clap_output_events *out) noexcept override;
bool implementsLatency() const noexcept override;
uint32_t latencyGet() const noexcept override;
private:
double m_param_dry_wet{100.0}, m_param_backend{3};
std::unordered_map<clap_id, double *> m_param_to_value;
uint32_t m_plugin_latency;
anira::ContextConfig m_anira_context;
anira::InferenceConfig m_inference_config = hybridnn_config;
HybridNNPrePostProcessor m_pp_processor;
HybridNNBypassProcessor m_bypass_processor;
anira::InferenceHandler m_inference_handler;
utils::DryWetMixer m_dry_wet_mixer;
enum Backend {
OnnxRuntime,
LibTorch,
TensorFlowLite,
Bypassed
};
};
} // namespace clap_plugin_example
#endif //ANIRA_CLAP_PLUGIN_EXAMPLE_H