File: wrapper.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (141 lines) | stat: -rw-r--r-- 6,405 bytes parent folder | download
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2021 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-plugin-fw
 * Created on: 8 дек. 2021 г.
 *
 * lsp-plugin-fw is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-plugin-fw is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-plugin-fw. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_PLUG_FW_WRAP_VST2_WRAPPER_H_
#define LSP_PLUG_IN_PLUG_FW_WRAP_VST2_WRAPPER_H_

#include <lsp-plug.in/plug-fw/version.h>
#include <lsp-plug.in/plug-fw/core/KVTDispatcher.h>
#include <lsp-plug.in/plug-fw/core/KVTStorage.h>
#include <lsp-plug.in/plug-fw/core/SamplePlayer.h>
#include <lsp-plug.in/plug-fw/meta/types.h>
#include <lsp-plug.in/plug-fw/plug.h>
#include <lsp-plug.in/plug-fw/ui.h>
#include <lsp-plug.in/plug-fw/wrap/vst2/chunk.h>
#include <lsp-plug.in/plug-fw/wrap/vst2/defs.h>
#include <lsp-plug.in/plug-fw/wrap/vst2/ports.h>

#include <lsp-plug.in/ipc/Mutex.h>
#include <lsp-plug.in/lltl/parray.h>

namespace lsp
{
    namespace vst2
    {
        class UIWrapper;

        class Wrapper: public plug::IWrapper
        {
            private:
                Wrapper & operator = (const Wrapper &);
                Wrapper(const Wrapper &);

                friend class UIWrapper;

            private:
                AEffect                            *pEffect;
                audioMasterCallback                 pMaster;
                ipc::IExecutor                     *pExecutor;
                vst2::chunk_t                       sChunk;
                bool                                bUpdateSettings;
                UIWrapper                          *pUIWrapper;
                float                               fLatency;
                uatomic_t                           nDumpReq;
                uatomic_t                           nDumpResp;
                vst2::Port                         *pBypass;

                lltl::parray<vst2::AudioPort>       vAudioPorts;    // List of audio ports
                lltl::parray<vst2::ParameterPort>   vParams;        // List of controllable parameters
                lltl::parray<vst2::Port>            vPorts;         // List of all created VST ports
                lltl::parray<vst2::Port>            vSortedPorts;   // List of all created VST ports ordered by unique id
                lltl::parray<vst2::Port>            vProxyPorts;    // List of all created VST proxy ports
                lltl::parray<meta::port_t>          vGenMetadata;   // Generated metadata

                core::SamplePlayer                 *pSamplePlayer;  // Sample player

                core::KVTStorage                    sKVT;
                ipc::Mutex                          sKVTMutex;

                meta::package_t                    *pPackage;

            private:
                vst2::Port                 *create_port(lltl::parray<plug::IPort> *plugin_ports, const meta::port_t *port, const char *postfix);

            protected:
                status_t                    check_vst_bank_header(const fxBank *bank, size_t size);
                status_t                    check_vst_program_header(const fxProgram *prog, size_t size);
                void                        deserialize_v1(const fxBank *bank);
                void                        deserialize_v2_v3(const uint8_t *data, size_t bytes);
                void                        deserialize_new_chunk_format(const uint8_t *data, size_t bytes);
                void                        sync_position();
                status_t                    serialize_port_data();

            public:
                Wrapper(
                    plug::Module *plugin,
                    resource::ILoader *loader,
                    AEffect *effect,
                    audioMasterCallback callback
                );
                virtual ~Wrapper() override;

                status_t                        init();
                void                            destroy();

            public:
                inline vst2::ParameterPort     *parameter_port(size_t index);
                vst2::Port                     *find_by_id(const char *id);

                inline void                     open();
                void                            run(float** inputs, float** outputs, size_t samples);
                void                            run_legacy(float** inputs, float** outputs, size_t samples);
                void                            process_events(const VstEvents *e);
                inline void                     set_sample_rate(float sr);
                inline void                     set_block_size(size_t size);
                inline void                     mains_changed(VstIntPtr value);
                inline bool                     has_bypass() const;
                inline void                     set_bypass(bool bypass);

                inline void                     set_ui_wrapper(UIWrapper *ui);

                inline UIWrapper               *ui_wrapper();

                size_t                          serialize_state(const void **dst, bool program);

                void                            deserialize_state(const void *data, size_t size);

                void                            request_state_dump();

                inline core::SamplePlayer      *sample_player();

            public:
                virtual ipc::IExecutor         *executor() override;
                virtual core::KVTStorage       *kvt_lock() override;
                virtual core::KVTStorage       *kvt_trylock() override;
                virtual bool                    kvt_release() override;
                virtual const meta::package_t  *package() const override;
        };
    } /* namespace vst2 */
} /* namespace lsp */



#endif /* LSP_PLUG_IN_PLUG_FW_WRAP_VST2_WRAPPER_H_ */