2 Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3 Copyright (C) 2006 Paul Davis
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2 of the License, or (at your option)
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_luaproc_h__
21 #define __ardour_luaproc_h__
27 #include "pbd/reallocpool.h"
28 #include "pbd/stateful.h"
30 #include "ardour/types.h"
31 #include "ardour/plugin.h"
32 #include "ardour/luascripting.h"
34 #include "lua/luastate.h"
35 #include "LuaBridge/LuaBridge.h"
39 class LIBARDOUR_API LuaProc : public ARDOUR::Plugin {
41 LuaProc (AudioEngine&, Session&, const std::string&);
42 LuaProc (const LuaProc &);
45 /* Plugin interface */
47 std::string unique_id() const { return get_info()->unique_id; }
48 const char* name() const { return get_info()->name.c_str(); }
49 const char* label() const { return get_info()->name.c_str(); }
50 const char* maker() const { return get_info()->creator.c_str(); }
52 uint32_t parameter_count() const;
53 float default_value (uint32_t port);
54 void set_parameter (uint32_t port, float val);
55 float get_parameter (uint32_t port) const;
56 int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
57 uint32_t nth_parameter (uint32_t port, bool& ok) const;
59 std::string get_docs () const { return _docs; }
60 std::string get_parameter_docs (uint32_t) const;
62 std::set<Evoral::Parameter> automatable() const;
65 void deactivate () { }
68 int set_block_size (pframes_t /*nframes*/) { return 0; }
69 framecnt_t signal_latency() const { return 0; }
71 int connect_and_run (BufferSet& bufs,
72 ChanMapping in, ChanMapping out,
73 pframes_t nframes, framecnt_t offset);
75 std::string describe_parameter (Evoral::Parameter);
76 void print_parameter (uint32_t, char*, uint32_t len) const;
77 boost::shared_ptr<ScalePoints> get_scale_points(uint32_t port_index) const;
79 bool parameter_is_audio (uint32_t) const { return false; }
80 bool parameter_is_control (uint32_t) const { return true; }
81 bool parameter_is_input (uint32_t) const;
82 bool parameter_is_output (uint32_t) const;
84 std::string state_node_name() const { return "luaproc"; }
85 void add_state (XMLNode *) const;
86 int set_state (const XMLNode&, int version);
87 int set_script_from_state (const XMLNode&);
89 bool load_preset (PresetRecord) { return false; }
90 bool has_editor() const { return false; }
92 bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
93 bool configure_io (ChanCount in, ChanCount out);
95 ChanCount output_streams() const { return _configured_out; }
96 ChanCount input_streams() const { return _configured_in; }
98 std::string do_save_preset (std::string) { return ""; }
99 void do_remove_preset (std::string) { }
103 void find_presets () { }
105 /* END Plugin interface */
107 const std::string& script() const { return _script; }
110 PBD::ReallocPool _mempool;
112 luabridge::LuaRef * _lua_dsp;
113 luabridge::LuaRef * _lua_params;
116 bool _lua_does_channelmapping;
120 void lua_print (std::string s);
122 std::vector<std::pair<bool, int> > _ctrl_params;
123 float* _control_data;
126 ChanCount _configured_in;
127 ChanCount _configured_out;
129 bool _has_midi_input;
130 bool _has_midi_output;
132 #ifdef WITH_LUAPROC_STATS
133 int64_t _stats_avg[2];
134 int64_t _stats_max[2];
139 class LIBARDOUR_API LuaPluginInfo : public PluginInfo
142 LuaPluginInfo (LuaScriptInfoPtr lsi);
143 ~LuaPluginInfo () { };
145 PluginPtr load (Session& session);
146 std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
148 bool is_instrument () const { return false; }
149 bool reconfigurable_io() const { return true; }
152 typedef boost::shared_ptr<LuaPluginInfo> LuaPluginInfoPtr;
154 } // namespace ARDOUR
156 #endif // __ardour_luaproc_h__