Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/plugins/CloneChannel/DistrhoPluginCloneChannel.cpp @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 /* | |
2 * DISTRHO CloneChannel - Copyright (C) 2023 Przemysław R. Pietraszczyk | |
3 * Based on DPF'ied SoulForce. | |
4 * Copyright (C) 2006 Niall Moody | |
5 * Copyright (C) 2015-2022 Filipe Coelho <falktx@falktx.com> | |
6 * | |
7 * Permission is hereby granted, free of charge, to any person obtaining a | |
8 * copy of this software and associated documentation files (the "Software"), | |
9 * to deal in the Software without restriction, including without limitation | |
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
11 * and/or sell copies of the Software, and to permit persons to whom the | |
12 * Software is furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be included in | |
15 * all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
23 * DEALINGS IN THE SOFTWARE. | |
24 */ | |
25 #include <stdio.h> | |
26 #include "DistrhoPluginCloneChannel.hpp" | |
27 | |
28 START_NAMESPACE_DISTRHO | |
29 | |
30 // ----------------------------------------------------------------------- | |
31 | |
32 DistrhoPluginCloneChannel::DistrhoPluginCloneChannel() | |
33 : Plugin(kParameterCount, kProgramCount, 0) | |
34 { | |
35 // set initial values | |
36 loadProgram(0); | |
37 } | |
38 | |
39 // ----------------------------------------------------------------------- | |
40 // Init | |
41 | |
42 void DistrhoPluginCloneChannel::initAudioPort(bool input, uint32_t index, AudioPort& port) | |
43 { | |
44 port.groupId = kPortGroupStereo; | |
45 | |
46 Plugin::initAudioPort(input, index, port); | |
47 } | |
48 | |
49 void DistrhoPluginCloneChannel::initParameter(uint32_t index, Parameter& parameter) | |
50 { | |
51 parameter.hints = kParameterIsAutomatable; | |
52 parameter.ranges.min = 0.0f; | |
53 parameter.ranges.max = 1.0f; | |
54 | |
55 switch (index) | |
56 { | |
57 case kParameterSource: | |
58 parameter.hints |= kParameterIsBoolean; | |
59 parameter.name = "left/right"; | |
60 parameter.symbol = "left/right"; | |
61 parameter.ranges.def = 0.0f; | |
62 break; | |
63 case kParameterSource2: | |
64 parameter.hints |= kParameterIsBoolean; | |
65 parameter.name = "clone/move"; | |
66 parameter.symbol = "clone/move"; | |
67 parameter.ranges.def = 0.0f; | |
68 break; | |
69 } | |
70 } | |
71 | |
72 void DistrhoPluginCloneChannel::initProgramName(uint32_t index, String& programName) | |
73 { | |
74 switch(index) | |
75 { | |
76 case kProgramDefault: | |
77 programName = "Default"; | |
78 break; | |
79 case kProgramStayDown: | |
80 programName = "Stay Down"; | |
81 break; | |
82 case kProgramLookingForTheWorld: | |
83 programName = "Looking for the World"; | |
84 break; | |
85 case kProgramGuerillaLove: | |
86 programName = "Guerilla Love"; | |
87 break; | |
88 case kProgramTumbleToThePower: | |
89 programName = "Tumble to the Power"; | |
90 break; | |
91 case kProgramDoYourselfFavour: | |
92 programName = "Do Yourself a Favour"; | |
93 break; | |
94 case kProgramPastIsPast: | |
95 programName = "Past is Past"; | |
96 break; | |
97 case kProgramYouAndOnlyYou: | |
98 programName = "You and Only You"; | |
99 break; | |
100 case kProgramCloneChannel: | |
101 programName = "Clone Channel"; | |
102 break; | |
103 } | |
104 } | |
105 | |
106 // ----------------------------------------------------------------------- | |
107 // Internal data | |
108 | |
109 float DistrhoPluginCloneChannel::getParameterValue(uint32_t index) const | |
110 { | |
111 return parameters[index]; | |
112 } | |
113 | |
114 void DistrhoPluginCloneChannel::setParameterValue(uint32_t index, float value) | |
115 { | |
116 asm("nop"); | |
117 } | |
118 | |
119 void DistrhoPluginCloneChannel::loadProgram(uint32_t index) | |
120 { | |
121 switch(index) | |
122 { | |
123 case kProgramDefault: | |
124 parameters[kParameterSource] = 0.0f; | |
125 parameters[kParameterSource2] = 0.0f; | |
126 break; | |
127 case kProgramStayDown: | |
128 parameters[kParameterSource] = 0.0f; | |
129 parameters[kParameterSource2] = 0.0f; | |
130 break; | |
131 case kProgramLookingForTheWorld: | |
132 parameters[kParameterSource] = 0.0f; | |
133 parameters[kParameterSource2] = 0.0f; | |
134 break; | |
135 case kProgramGuerillaLove: | |
136 parameters[kParameterSource] = 0.0f; | |
137 parameters[kParameterSource2] = 0.0f; | |
138 break; | |
139 case kProgramTumbleToThePower: | |
140 parameters[kParameterSource] = 0.0f; | |
141 parameters[kParameterSource2] = 0.0f; | |
142 break; | |
143 case kProgramDoYourselfFavour: | |
144 parameters[kParameterSource] = 1.0f; | |
145 parameters[kParameterSource2] = 1.0f; | |
146 break; | |
147 case kProgramPastIsPast: | |
148 parameters[kParameterSource] = 1.0f; | |
149 parameters[kParameterSource2] = 1.0f; | |
150 break; | |
151 case kProgramYouAndOnlyYou: | |
152 parameters[kParameterSource] = 0.0f; | |
153 parameters[kParameterSource2] = 0.0f; | |
154 break; | |
155 case kProgramCloneChannel: | |
156 parameters[kParameterSource] = 1.0f; | |
157 parameters[kParameterSource2] = 1.0f; | |
158 break; | |
159 } | |
160 } | |
161 | |
162 // ----------------------------------------------------------------------- | |
163 // Process | |
164 | |
165 void DistrhoPluginCloneChannel::run(const float** inputs, float** outputs, uint32_t frames) | |
166 { | |
167 | |
168 // Calculate audio. | |
169 for (uint32_t i=0; i<frames; ++i) | |
170 { | |
171 if (parameters[kParameterSource2] < 0.5f) { | |
172 // do lewego | |
173 if (parameters[kParameterSource] < 0.5f) { | |
174 outputs[0][i] = inputs[1][i]; | |
175 outputs[1][i] = inputs[1][i]; | |
176 } | |
177 // do prawego | |
178 if (parameters[kParameterSource] > 0.5f) { | |
179 outputs[0][i] = inputs[0][i]; | |
180 outputs[1][i] = inputs[0][i]; | |
181 } | |
182 } | |
183 // move | |
184 else if (parameters[kParameterSource2] > 0.5f) { | |
185 // na lewy | |
186 if (parameters[kParameterSource] < 0.5f) { | |
187 outputs[0][i] = inputs[1][i]; | |
188 outputs[1][i] = 0.0f; | |
189 } | |
190 // na prawy | |
191 if (parameters[kParameterSource] > 0.5f) { | |
192 outputs[0][i] = 0.0f; | |
193 outputs[1][i] = inputs[0][i]; | |
194 } | |
195 } | |
196 } | |
197 } | |
198 | |
199 // ----------------------------------------------------------------------- | |
200 | |
201 Plugin* createPlugin() | |
202 { | |
203 return new DistrhoPluginCloneChannel(); | |
204 } | |
205 | |
206 // ----------------------------------------------------------------------- | |
207 | |
208 END_NAMESPACE_DISTRHO |