File: lv2ttl_gen.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 (180 lines) | stat: -rw-r--r-- 6,520 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * 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: 25 дек. 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_UTIL_LV2TTL_GEN_LV2TTL_GEN_H_
#define LSP_PLUG_IN_PLUG_FW_UTIL_LV2TTL_GEN_LV2TTL_GEN_H_

#include <lsp-plug.in/plug-fw/version.h>

#include <lsp-plug.in/common/types.h>
#include <lsp-plug.in/common/status.h>
#include <lsp-plug.in/lltl/parray.h>
#include <lsp-plug.in/plug-fw/meta/types.h>
#include <lsp-plug.in/stdlib/stdio.h>
#include <lsp-plug.in/stdlib/string.h>


#define LV2TTL_PLUGIN_PREFIX                "plug"
#define LV2TTL_PLUGIN_UI_PREFIX             "plug_ui"
#define LV2TTL_PORT_GROUP_PREFIX            "plug_pg"
#define LV2TTL_PORTS_PREFIX                 "plug_p"
#define LV2TTL_DEVELOPERS_PREFIX            "plug_dev"

// Different LV2 UI classes for different platforms
#if defined(PLATFORM_LINUX) || defined(PLATFORM_BSD)
    #define LV2TTL_UI_CLASS                             "X11UI"
#elif defined(PLATFORM_WINDOWS)
    #define LV2TTL_UI_CLASS                             "WindowsUI"
#elif defined(PLATFORM_MACOSX)
    #define LV2TTL_UI_CLASS                             "CocoaUI"
#elif defined(PLATFORM_UNIX_COMPATIBLE)
    #define LV2TTL_UI_CLASS                             "X11UI"
#else
    #error "Could not determine LV2 UI class for target platform"
#endif

namespace lsp
{
    namespace lv2ttl_gen
    {
        //-----------------------------------------------------------------------------
        enum requirements_t
        {
            REQ_PATCH       = 1 << 0,
            REQ_STATE       = 1 << 1,
            REQ_LV2UI       = 1 << 2,
            REQ_PORT_GROUPS = 1 << 3,
            REQ_WORKER      = 1 << 4,
            REQ_MIDI_IN     = 1 << 5,
            REQ_MIDI_OUT    = 1 << 6,
            REQ_PATCH_WR    = 1 << 7,
            REQ_INSTANCE    = 1 << 8,
            REQ_TIME        = 1 << 9,
            REQ_IDISPLAY    = 1 << 10,
            REQ_OSC_IN      = 1 << 11,
            REQ_OSC_OUT     = 1 << 12,
            REQ_MAP_PATH    = 1 << 13,

            REQ_PATH_MASK   = REQ_PATCH | REQ_STATE | REQ_MAP_PATH | REQ_WORKER | REQ_PATCH_WR,
            REQ_MIDI        = REQ_MIDI_IN | REQ_MIDI_OUT
        };

        typedef struct plugin_group_t
        {
            int            id;
            const char    *name;
        } plugin_group_t;

        typedef struct plugin_unit_t
        {
            int             id;             // Internal ID from metadata
            const char     *name;           // LV2 name of the unit
            const char     *label;          // Custom label of the unit (if name is not present)
            const char     *render;         // Formatting of the unit (if name is not present)
        } plugin_unit_t;

        typedef struct cmdline_t
        {
            const char     *out_dir;        // Output directory
            const char     *lv2_binary;     // The name of the LV2 binary file
            const char     *lv2ui_binary;   // The name of the LV2 UI binary file
        } cmdline_t;

        //-----------------------------------------------------------------------------
        extern const plugin_group_t plugin_groups[];

        extern const plugin_unit_t plugin_units[];

        /**
         * Parse command-line arguments
         * @param cfg command line configuration
         * @param argc number of command line arguments
         * @param argv list of command line arguments
         * @return status of operation
         */
        status_t parse_cmdline(cmdline_t *cfg, int argc, const char **argv);

        /**
         * Generate TTL file for the plugin's UI
         * @param out output file stream
         * @param requirements plugin requirements (flags of requirements_t enum)
         * @param meta plugin metadata
         * @param manifest package manifest metadata
         * @param cmd command line arguments
         */
        void write_plugin_ui_ttl(
            FILE *out,
            size_t requirements,
            const meta::plugin_t &meta,
            const meta::package_t *manifest,
            const cmdline_t *cmd);

        /**
         * Generate TTL file for the plugin
         * @param out output file stream
         * @param requirements plugin requirements (flags of requirements_t enum)
         * @param meta plugin metadata
         * @param manifest package manifest metadata
         * @param cmd command line arguments
         */
        void write_plugin_ttl(
            FILE *out,
            size_t requirements,
            const meta::plugin_t &m,
            const meta::package_t *manifest,
            const cmdline_t *cmd);

        /**
         * Generate plugin TTL files
         * @param meta plugin metadata
         * @param manifest package manifest metadata
         * @param cmd command line arguments
         */
        void gen_plugin_ttl_files(
            const meta::plugin_t &m,
            const meta::package_t *manifest,
            const cmdline_t *cmd);

        /**
         * Generate the TTL manifest file
         * @param manifest package manifest metadata
         * @param plugins list of plugins
         * @param cmd command line arguments
         */
        void gen_manifest(
            const meta::package_t *manifest,
            const lltl::parray<meta::plugin_t> &plugins,
            const cmdline_t *cmd);

        /**
         * The main function of utility
         * @param argc number of command-line arguments
         * @param argv list of command-line arguments
         * @return status of operation
         */
        status_t main(int argc, const char **argv);

    } /* namespace lv2ttl_gen */
} /* namespace lsp */



#endif /* LSP_PLUG_IN_PLUG_FW_UTIL_LV2TTL_GEN_LV2TTL_GEN_H_ */