LMMS
Loading...
Searching...
No Matches
ladspa_wrap.h
Go to the documentation of this file.
1/* Calf DSP Library
2 * API wrappers for LADSPA/DSSI
3 *
4 * Copyright (C) 2007-2008 Krzysztof Foltman
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02111-1307, USA.
20 */
21#ifndef __CALF_LADSPA_WRAP_H
22#define __CALF_LADSPA_WRAP_H
23
24#if USE_LADSPA
25
26#include <string.h>
27#include <ladspa.h>
28#if USE_DSSI
29#include <dssi.h>
30#endif
31#include "giface.h"
32#include "preset.h"
33
34namespace calf_plugins {
35
36struct ladspa_plugin_metadata_set;
38struct ladspa_instance: public plugin_ctl_iface
39{
40 audio_module_iface *module;
41 const plugin_metadata_iface *metadata;
42 ladspa_plugin_metadata_set *ladspa;
43 bool activate_flag;
44 float **ins, **outs, **params;
45 int sample_rate;
46#if USE_DSSI
47 dssi_feedback_sender *feedback_sender;
48#endif
49
50 ladspa_instance(audio_module_iface *_module, ladspa_plugin_metadata_set *_ladspa, int sample_rate);
51 virtual ~ladspa_instance();
52 virtual const line_graph_iface *get_line_graph_iface() const { return module->get_line_graph_iface(); }
53 virtual const phase_graph_iface *get_phase_graph_iface() const { return module->get_phase_graph_iface(); }
54 virtual float get_param_value(int param_no);
55 virtual void set_param_value(int param_no, float value);
56 virtual bool activate_preset(int bank, int program);
57 virtual char *configure(const char *key, const char *value);
58 virtual float get_level(unsigned int port) { return 0.f; }
59 virtual void execute(int cmd_no) {
60 module->execute(cmd_no);
61 }
62 virtual void send_configures(send_configure_iface *sci) {
63 module->send_configures(sci);
64 }
65 virtual int send_status_updates(send_updates_iface *sui, int last_serial) { return module->send_status_updates(sui, last_serial); }
66 void run(unsigned long SampleCount);
67#if USE_DSSI
69 void process_dssi_event(snd_seq_event_t &event);
70 void run_synth(unsigned long SampleCount, snd_seq_event_t *Events, unsigned long EventCount);
71#endif
72 virtual const plugin_metadata_iface *get_metadata_iface() const
73 {
74 return metadata;
75 }
76};
77
79struct ladspa_plugin_metadata_set
80{
84 LADSPA_Descriptor descriptor_for_dssi;
85#if USE_DSSI
88 DSSI_Program_Descriptor dssi_default_program;
89
90 std::vector<plugin_preset> *presets;
91 std::vector<DSSI_Program_Descriptor> *preset_descs;
92#endif
93
94 int input_count, output_count, param_count;
95 const plugin_metadata_iface *metadata;
96
97 ladspa_plugin_metadata_set();
98 void prepare(const plugin_metadata_iface *md, LADSPA_Handle (*cb_instantiate)(const struct _LADSPA_Descriptor * Descriptor, unsigned long sample_rate));
99 void prepare_dssi();
100 ~ladspa_plugin_metadata_set();
101};
102
104template<class Module>
105struct ladspa_wrapper
106{
107 static ladspa_plugin_metadata_set output;
108
109private:
110 ladspa_wrapper(const plugin_metadata_iface *md)
111 {
112 output.prepare(md, cb_instantiate);
113 }
114
115public:
117 static LADSPA_Handle cb_instantiate(const struct _LADSPA_Descriptor * Descriptor, unsigned long sample_rate)
118 {
119 return new ladspa_instance(new Module, &output, sample_rate);
120 }
121
123 static ladspa_plugin_metadata_set &get() {
124 static ladspa_wrapper instance(new typename Module::metadata_class);
125 return instance.output;
126 }
127};
128
129};
130
131#endif
132
133#endif
static const LV2_Descriptor descriptor
Definition bindings_test_plugin.c:165
static void run(LV2_Handle instance, uint32_t n_samples)
Definition bindings_test_plugin.c:112
unsigned md
Definition inflate.c:944
struct _DSSI_Descriptor DSSI_Descriptor
const DSSI_Descriptor * dssi_descriptor(unsigned long Index)
Definition DSSIaudiooutput.cpp:129
struct _DSSI_Program_Descriptor DSSI_Program_Descriptor
static PuglViewHint int value
Definition pugl.h:1708
void * LADSPA_Handle
Definition ladspa.h:363
struct _LADSPA_Descriptor LADSPA_Descriptor
Definition benchmark.cpp:53
auto & get(ProcessorChain< Processors... > &chain) noexcept
Definition juce_ProcessorChain.h:133
Instrument * ins
Definition HydrogenImport.cpp:138
struct snd_seq_event snd_seq_event_t
Interface for host-GUI-plugin interaction (should be really split in two, but ... meh).
Definition giface.h:389
ZCONST char * key
Definition crypt.c:587