Debian Codegraph @

src/engine/effect.h

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef _EFFECT_H
21 #define _EFFECT_H
22
23 #include <stdlib.h>
24 #include "../ta-utils.h"
25
26 class DivEngine;
27
28 class DivEffect {
29 protected:
30 DivEngine* parent;
31 public:
32 /**
33 * fill a buffer with sound data.
34 * @param in pointers to input buffers.
35 * @param out pointers to output buffers.
36 * @param len the amount of samples in input and output.
37 */
38 virtual void acquire(float** in, float** out, size_t len);
39
40 /**
41 * reset the state of this effect.
42 */
43 virtual void reset();
44
45 /**
46 * get the number of inputs this effect requests.
47 * @return number of inputs. SHALL NOT be less than zero.
48 */
49 virtual int getInputCount();
50
51 /**
52 * get the number of outputs this effect provides.
53 * @return number of outputs. SHALL NOT be less than one.
54 */
55 virtual int getOutputCount();
56
57 /**
58 * called when the sample rate changes.
59 * @param rate the new sample rate.
60 */
61 virtual void rateChanged(double rate);
62
63 /**
64 * get the value of a parameter.
65 * @param param parameter ID.
66 * @return a String with the value.
67 * @throws std::out_of_range if the parameter ID is out of range.
68 */
69 virtual String getParam(size_t param);
70
71 /**
72 * set the value of a parameter.
73 * @param param parameter ID.
74 * @param value the value.
75 * @return whether the parameter was set successfully.
76 */
77 virtual bool setParam(size_t param, String value);
78
79 /**
80 * get a list of parameters.
81 * @return a C string with a list of parameters, or NULL if there are none.
82 * PARAMETER TYPES
83 *
84 * Parameter
85 * id:type:name:description:[...]
86 * type may be one of the following:
87 * - s: string
88 * - i: integer
89 * - I: integer slider
90 * - r: integer list (radio button)
91 * - R: integer list (combo box)
92 * - h: integer hex
93 * - f: float
94 * - F: float slider
95 * - d: double
96 * - D: double slider
97 * - b: boolean (checkbox)
98 * - t: boolean (toggle button)
99 * - x: X/Y integer
100 * - X: X/Y float
101 * - c: color (RGB)
102 * - C: color (RGBA)
103 * - B: button
104 *
105 * SameLine
106 * !s
107 *
108 * Separator
109 * ---
110 *
111 * Indent/Unindent
112 * > Indent
113 * < Unindent
114 *
115 * TreeNode
116 * >> Begin
117 * << End
118 *
119 * Tabs
120 * >TABBAR BeginTabBar
121 * >TAB:name Begin
122 * <TAB End
123 * <TABBAR EndTabBar
124 *
125 * Text
126 * TEXT:text (static text)
127 * TEXTF:id (dynamic text)
128 *
129 * NOTES
130 *
131 * use a new line to separate parameters.
132 * use `\:` if you need a colon.
133 */
134 virtual const char* getParams();
135
136 /**
137 * get the number of parameters.
138 * @return count.
139 */
140 virtual size_t getParamCount();
141
142 /**
143 * get a dynamic text.
144 * @param id the text ID.
145 * @return a String with the text.
146 * @throws std::out_of_range if the text ID is out of range.
147 */
148 virtual String getDynamicText(size_t id);
149
150 /**
151 * load effect data.
152 * @param version effect data version. may be zero.
153 * @param data effect data. may be NULL.
154 * @param len effect data length. may be zero.
155 * @return whether loading was successful.
156 */
157 virtual bool load(unsigned short version, const unsigned char* data, size_t len);
158
159 /**
160 * save effect data.
161 * @param version effect data version.
162 * @param len effect data length.
163 * @return a pointer to effect data. this must be de-allocated manually.
164 * may also return NULL if it can't save.
165 */
166 virtual unsigned char* save(unsigned short* version, size_t* len);
167
168 /**
169 * initialize this DivEffect.
170 * @param parent the parent DivEngine.
171 * @param version effect data version. may be zero.
172 * @param data effect data. may be NULL.
173 * @param len effect data length. may be zero.
174 * @return whether initialization was successful.
175 */
176 virtual bool init(DivEngine* parent, double rate, unsigned short version, const unsigned char* data, size_t len);
177
178 /**
179 * quit the DivEffect.
180 */
181 virtual void quit();
182
183 virtual ~DivEffect();
184 };
185
186 // additional notes:
187 // - we don't have a GUI API yet, but that will be added when I make the plugin bridge.
188
189 #endif