1use crate::{error::ConversionError, object::sound::types::sound_mod_target};
2use serde::{Deserialize, Serialize};
3
4#[derive(
6 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
7)]
8pub enum ControlInModTarget {
9 #[default]
11 Unset,
12 LfoMultiplier,
14 LfoWaveform,
16 LfoTrigMode,
18 LfoSpeed,
20 LfoFade,
22 LfoPhase,
24 LfoDepth,
26 SampleTune,
28 SampleFineTune,
30 SampleSlice,
32 SampleBitReduction,
34 SampleStart,
36 SampleEnd,
38 SampleLoop,
40 SampleLevel,
42 FilterEnvelope,
44 FilterAttack,
46 FilterDecay,
48 FilterSustain,
50 FilterRelease,
52 FilterFrequency,
54 FilterResonance,
56 AmpAttack,
58 AmpHold,
60 AmpDecay,
62 AmpOverdrive,
64 AmpVolume,
66 AmpPan,
68 AmpAccent,
70 AmpDelaySend,
72 AmpReverbSend,
74}
75
76impl TryFrom<&str> for ControlInModTarget {
77 type Error = ConversionError;
78 fn try_from(value: &str) -> Result<Self, Self::Error> {
79 match value {
80 "unset" => Ok(Self::Unset),
81 "lfomultiplier" => Ok(Self::LfoMultiplier),
82 "lfowaveform" => Ok(Self::LfoWaveform),
83 "lfotrigmode" => Ok(Self::LfoTrigMode),
84 "lfospeed" => Ok(Self::LfoSpeed),
85 "lfofade" => Ok(Self::LfoFade),
86 "lfophase" => Ok(Self::LfoPhase),
87 "lfodepth" => Ok(Self::LfoDepth),
88 "sampletune" => Ok(Self::SampleTune),
89 "samplefinetune" => Ok(Self::SampleFineTune),
90 "sampleslice" => Ok(Self::SampleSlice),
91 "samplebitreduction" => Ok(Self::SampleBitReduction),
92 "samplestart" => Ok(Self::SampleStart),
93 "sampleend" => Ok(Self::SampleEnd),
94 "sampleloop" => Ok(Self::SampleLoop),
95 "samplelevel" => Ok(Self::SampleLevel),
96 "filterenvelope" => Ok(Self::FilterEnvelope),
97 "filterattack" => Ok(Self::FilterAttack),
98 "filterdecay" => Ok(Self::FilterDecay),
99 "filtersustain" => Ok(Self::FilterSustain),
100 "filterrelease" => Ok(Self::FilterRelease),
101 "filterfrequency" => Ok(Self::FilterFrequency),
102 "filterresonance" => Ok(Self::FilterResonance),
103 "ampattack" => Ok(Self::AmpAttack),
104 "amphold" => Ok(Self::AmpHold),
105 "ampdecay" => Ok(Self::AmpDecay),
106 "ampoverdrive" => Ok(Self::AmpOverdrive),
107 "ampvolume" => Ok(Self::AmpVolume),
108 "amppan" => Ok(Self::AmpPan),
109 "ampaccent" => Ok(Self::AmpAccent),
110 "ampdelaysend" => Ok(Self::AmpDelaySend),
111 "ampreverbsend" => Ok(Self::AmpReverbSend),
112 _ => Err(ConversionError::Range {
113 value: value.to_string(),
114 type_name: "ControlInModTarget".to_string(),
115 }),
116 }
117 }
118}
119
120impl From<ControlInModTarget> for &str {
121 fn from(value: ControlInModTarget) -> Self {
122 match value {
123 ControlInModTarget::Unset => "unset",
124 ControlInModTarget::LfoMultiplier => "lfomultiplier",
125 ControlInModTarget::LfoWaveform => "lfowaveform",
126 ControlInModTarget::LfoTrigMode => "lfotrigmode",
127 ControlInModTarget::LfoSpeed => "lfospeed",
128 ControlInModTarget::LfoFade => "lfofade",
129 ControlInModTarget::LfoPhase => "lfophase",
130 ControlInModTarget::LfoDepth => "lfodepth",
131 ControlInModTarget::SampleTune => "sampletune",
132 ControlInModTarget::SampleFineTune => "samplefinetune",
133 ControlInModTarget::SampleSlice => "sampleslice",
134 ControlInModTarget::SampleBitReduction => "samplebitreduction",
135 ControlInModTarget::SampleStart => "samplestart",
136 ControlInModTarget::SampleEnd => "sampleend",
137 ControlInModTarget::SampleLoop => "sampleloop",
138 ControlInModTarget::SampleLevel => "samplelevel",
139 ControlInModTarget::FilterEnvelope => "filterenvelope",
140 ControlInModTarget::FilterAttack => "filterattack",
141 ControlInModTarget::FilterDecay => "filterdecay",
142 ControlInModTarget::FilterSustain => "filtersustain",
143 ControlInModTarget::FilterRelease => "filterrelease",
144 ControlInModTarget::FilterFrequency => "filterfrequency",
145 ControlInModTarget::FilterResonance => "filterresonance",
146 ControlInModTarget::AmpAttack => "ampattack",
147 ControlInModTarget::AmpHold => "amphold",
148 ControlInModTarget::AmpDecay => "ampdecay",
149 ControlInModTarget::AmpOverdrive => "ampoverdrive",
150 ControlInModTarget::AmpVolume => "ampvolume",
151 ControlInModTarget::AmpPan => "amppan",
152 ControlInModTarget::AmpAccent => "ampaccent",
153 ControlInModTarget::AmpDelaySend => "ampdelaysend",
154 ControlInModTarget::AmpReverbSend => "ampreverbsend",
155 }
156 }
157}
158
159impl TryFrom<u8> for ControlInModTarget {
160 type Error = ConversionError;
161 fn try_from(value: u8) -> Result<Self, Self::Error> {
162 use sound_mod_target::*;
163 match value {
164 NONE => Ok(Self::Unset),
165 LFO_MULTIPLIER => Ok(Self::LfoMultiplier),
166 LFO_WAVEFORM => Ok(Self::LfoWaveform),
167 LFO_TRIGMODE => Ok(Self::LfoTrigMode),
168 LFO_SPEED => Ok(Self::LfoSpeed),
169 LFO_FADE => Ok(Self::LfoFade),
170 LFO_PHASE => Ok(Self::LfoPhase),
171 LFO_DEPTH => Ok(Self::LfoDepth),
172 SMP_TUN => Ok(Self::SampleTune),
173 SMP_FIN => Ok(Self::SampleFineTune),
174 SMP_SMP => Ok(Self::SampleSlice),
175 SMP_BR => Ok(Self::SampleBitReduction),
176 SMP_STA => Ok(Self::SampleStart),
177 SMP_END => Ok(Self::SampleEnd),
178 SMP_LOP => Ok(Self::SampleLoop),
179 SMP_LEV => Ok(Self::SampleLevel),
180 FLT_ENV => Ok(Self::FilterEnvelope),
181 FLT_ATK => Ok(Self::FilterAttack),
182 FLT_DEC => Ok(Self::FilterDecay),
183 FLT_SUS => Ok(Self::FilterSustain),
184 FLT_REL => Ok(Self::FilterRelease),
185 FLT_FRQ => Ok(Self::FilterFrequency),
186 FLT_RES => Ok(Self::FilterResonance),
187 AMP_ATK => Ok(Self::AmpAttack),
188 AMP_HLD => Ok(Self::AmpHold),
189 AMP_DEC => Ok(Self::AmpDecay),
190 AMP_OVR => Ok(Self::AmpOverdrive),
191 AMP_VOL => Ok(Self::AmpVolume),
192 AMP_PAN => Ok(Self::AmpPan),
193 AMP_ACC => Ok(Self::AmpAccent),
194 AMP_DLY => Ok(Self::AmpDelaySend),
195 AMP_REV => Ok(Self::AmpReverbSend),
196 _ => Err(ConversionError::Range {
197 value: value.to_string(),
198 type_name: "ControlInModTarget".to_string(),
199 }),
200 }
201 }
202}
203
204impl From<ControlInModTarget> for u8 {
205 fn from(value: ControlInModTarget) -> Self {
206 use sound_mod_target::*;
207 match value {
208 ControlInModTarget::Unset => NONE,
209 ControlInModTarget::LfoMultiplier => LFO_MULTIPLIER,
210 ControlInModTarget::LfoWaveform => LFO_WAVEFORM,
211 ControlInModTarget::LfoTrigMode => LFO_TRIGMODE,
212 ControlInModTarget::LfoSpeed => LFO_SPEED,
213 ControlInModTarget::LfoFade => LFO_FADE,
214 ControlInModTarget::LfoPhase => LFO_PHASE,
215 ControlInModTarget::LfoDepth => LFO_DEPTH,
216 ControlInModTarget::SampleTune => SMP_TUN,
217 ControlInModTarget::SampleFineTune => SMP_FIN,
218 ControlInModTarget::SampleSlice => SMP_SMP,
219 ControlInModTarget::SampleBitReduction => SMP_BR,
220 ControlInModTarget::SampleStart => SMP_STA,
221 ControlInModTarget::SampleEnd => SMP_END,
222 ControlInModTarget::SampleLoop => SMP_LOP,
223 ControlInModTarget::SampleLevel => SMP_LEV,
224 ControlInModTarget::FilterEnvelope => FLT_ENV,
225 ControlInModTarget::FilterAttack => FLT_ATK,
226 ControlInModTarget::FilterDecay => FLT_DEC,
227 ControlInModTarget::FilterSustain => FLT_SUS,
228 ControlInModTarget::FilterRelease => FLT_REL,
229 ControlInModTarget::FilterFrequency => FLT_FRQ,
230 ControlInModTarget::FilterResonance => FLT_RES,
231 ControlInModTarget::AmpAttack => AMP_ATK,
232 ControlInModTarget::AmpHold => AMP_HLD,
233 ControlInModTarget::AmpDecay => AMP_DEC,
234 ControlInModTarget::AmpOverdrive => AMP_OVR,
235 ControlInModTarget::AmpVolume => AMP_VOL,
236 ControlInModTarget::AmpPan => AMP_PAN,
237 ControlInModTarget::AmpAccent => AMP_ACC,
238 ControlInModTarget::AmpDelaySend => AMP_DLY,
239 ControlInModTarget::AmpReverbSend => AMP_REV,
240 }
241 }
242}
243
244#[derive(
246 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
247)]
248pub enum FxLfoDestination {
249 #[default]
250 Unset,
251 DelayTime,
252 DelayPingPong,
253 DelayStereoWidth,
254 DelayFeedback,
255 DelayHpFilter,
256 DelayLpFilter,
257 DelayReverbSend,
258 DelayMixVolume,
259 DelayOverdrive,
260 ReverbPreDelay,
261 ReverbDecay,
262 ReverbShelvingFreq,
263 ReverbShelvingGain,
264 ReverbHpFilter,
265 ReverbLpFilter,
266 ReverbMixVolume,
267 DistortionAmount,
268 DistortionSymmetry,
269 CompressorThreshold,
270 CompressorAttack,
271 CompressorRelease,
272 CompressorRatio,
273 CompressorSideChainEq,
274 CompressorMakeUpGain,
275 CompressorDryWetMix,
276 CompressorVolume,
277}
278
279impl TryFrom<&str> for FxLfoDestination {
280 type Error = ConversionError;
281 fn try_from(value: &str) -> Result<Self, Self::Error> {
282 match value {
283 "unset" => Ok(Self::Unset),
284 "delaytime" => Ok(Self::DelayTime),
285 "delaypingpong" => Ok(Self::DelayPingPong),
286 "delaystereowidth" => Ok(Self::DelayStereoWidth),
287 "delayfeedback" => Ok(Self::DelayFeedback),
288 "delayhpfilter" => Ok(Self::DelayHpFilter),
289 "delaylpfilter" => Ok(Self::DelayLpFilter),
290 "delayreverbsend" => Ok(Self::DelayReverbSend),
291 "delaymixvolume" => Ok(Self::DelayMixVolume),
292 "delayoverdrive" => Ok(Self::DelayOverdrive),
293 "reverbpredelay" => Ok(Self::ReverbPreDelay),
294 "reverbdecay" => Ok(Self::ReverbDecay),
295 "reverbshelvingfreq" => Ok(Self::ReverbShelvingFreq),
296 "reverbshelvinggain" => Ok(Self::ReverbShelvingGain),
297 "reverbhpfilter" => Ok(Self::ReverbHpFilter),
298 "reverblpfilter" => Ok(Self::ReverbLpFilter),
299 "reverbmixvolume" => Ok(Self::ReverbMixVolume),
300 "distortionamount" => Ok(Self::DistortionAmount),
301 "distortionsymmetry" => Ok(Self::DistortionSymmetry),
302 "compressorthreshold" => Ok(Self::CompressorThreshold),
303 "compressorattack" => Ok(Self::CompressorAttack),
304 "compressorrelease" => Ok(Self::CompressorRelease),
305 "compressorratio" => Ok(Self::CompressorRatio),
306 "compressorsidechaineq" => Ok(Self::CompressorSideChainEq),
307 "compressormakeupgain" => Ok(Self::CompressorMakeUpGain),
308 "compressordrywetmix" => Ok(Self::CompressorDryWetMix),
309 "compressorvolume" => Ok(Self::CompressorVolume),
310 _ => Err(ConversionError::Range {
311 value: value.to_string(),
312 type_name: "FxLfoDestination".to_string(),
313 }),
314 }
315 }
316}
317
318impl From<FxLfoDestination> for &str {
319 fn from(value: FxLfoDestination) -> Self {
320 match value {
321 FxLfoDestination::Unset => "unset",
322 FxLfoDestination::DelayTime => "delaytime",
323 FxLfoDestination::DelayPingPong => "delaypingpong",
324 FxLfoDestination::DelayStereoWidth => "delaystereowidth",
325 FxLfoDestination::DelayFeedback => "delayfeedback",
326 FxLfoDestination::DelayHpFilter => "delayhpfilter",
327 FxLfoDestination::DelayLpFilter => "delaylpfilter",
328 FxLfoDestination::DelayReverbSend => "delayreverbsend",
329 FxLfoDestination::DelayMixVolume => "delaymixvolume",
330 FxLfoDestination::DelayOverdrive => "delayoverdrive",
331 FxLfoDestination::ReverbPreDelay => "reverbpredelay",
332 FxLfoDestination::ReverbDecay => "reverbdecay",
333 FxLfoDestination::ReverbShelvingFreq => "reverbshelvingfreq",
334 FxLfoDestination::ReverbShelvingGain => "reverbshelvinggain",
335 FxLfoDestination::ReverbHpFilter => "reverbhpfilter",
336 FxLfoDestination::ReverbLpFilter => "reverblpfilter",
337 FxLfoDestination::ReverbMixVolume => "reverbmixvolume",
338 FxLfoDestination::DistortionAmount => "distortionamount",
339 FxLfoDestination::DistortionSymmetry => "distortionsymmetry",
340 FxLfoDestination::CompressorThreshold => "compressorthreshold",
341 FxLfoDestination::CompressorAttack => "compressorattack",
342 FxLfoDestination::CompressorRelease => "compressorrelease",
343 FxLfoDestination::CompressorRatio => "compressorratio",
344 FxLfoDestination::CompressorSideChainEq => "compressorsidechaineq",
345 FxLfoDestination::CompressorMakeUpGain => "compressormakeupgain",
346 FxLfoDestination::CompressorDryWetMix => "compressordrywetmix",
347 FxLfoDestination::CompressorVolume => "compressorvolume",
348 }
349 }
350}
351
352impl TryFrom<u8> for FxLfoDestination {
353 type Error = ConversionError;
354 fn try_from(value: u8) -> Result<Self, Self::Error> {
355 match value {
357 37 => Ok(Self::Unset),
358 0 => Ok(Self::DelayTime),
359 1 => Ok(Self::DelayPingPong),
360 2 => Ok(Self::DelayStereoWidth),
361 3 => Ok(Self::DelayFeedback),
362 4 => Ok(Self::DelayHpFilter),
363 5 => Ok(Self::DelayLpFilter),
364 6 => Ok(Self::DelayReverbSend),
365 7 => Ok(Self::DelayMixVolume),
366 8 => Ok(Self::DelayOverdrive),
367 10 => Ok(Self::ReverbPreDelay),
368 11 => Ok(Self::ReverbDecay),
369 12 => Ok(Self::ReverbShelvingFreq),
370 13 => Ok(Self::ReverbShelvingGain),
371 14 => Ok(Self::ReverbHpFilter),
372 15 => Ok(Self::ReverbLpFilter),
373 16 => Ok(Self::ReverbMixVolume),
374 18 => Ok(Self::DistortionAmount),
375 19 => Ok(Self::DistortionSymmetry),
376 21 => Ok(Self::CompressorThreshold),
377 22 => Ok(Self::CompressorAttack),
378 23 => Ok(Self::CompressorRelease),
379 24 => Ok(Self::CompressorRatio),
380 25 => Ok(Self::CompressorSideChainEq),
381 26 => Ok(Self::CompressorMakeUpGain),
382 27 => Ok(Self::CompressorDryWetMix),
383 28 => Ok(Self::CompressorVolume),
384 _ => Err(ConversionError::Range {
385 value: value.to_string(),
386 type_name: "FxLfoDestination".to_string(),
387 }),
388 }
389 }
390}
391
392impl From<FxLfoDestination> for u8 {
393 fn from(value: FxLfoDestination) -> Self {
394 match value {
395 FxLfoDestination::Unset => 37,
396 FxLfoDestination::DelayTime => 0,
397 FxLfoDestination::DelayPingPong => 1,
398 FxLfoDestination::DelayStereoWidth => 2,
399 FxLfoDestination::DelayFeedback => 3,
400 FxLfoDestination::DelayHpFilter => 4,
401 FxLfoDestination::DelayLpFilter => 5,
402 FxLfoDestination::DelayReverbSend => 6,
403 FxLfoDestination::DelayMixVolume => 7,
404 FxLfoDestination::DelayOverdrive => 8,
405 FxLfoDestination::ReverbPreDelay => 10,
406 FxLfoDestination::ReverbDecay => 11,
407 FxLfoDestination::ReverbShelvingFreq => 12,
408 FxLfoDestination::ReverbShelvingGain => 13,
409 FxLfoDestination::ReverbHpFilter => 14,
410 FxLfoDestination::ReverbLpFilter => 15,
411 FxLfoDestination::ReverbMixVolume => 16,
412 FxLfoDestination::DistortionAmount => 18,
413 FxLfoDestination::DistortionSymmetry => 19,
414 FxLfoDestination::CompressorThreshold => 21,
415 FxLfoDestination::CompressorAttack => 22,
416 FxLfoDestination::CompressorRelease => 23,
417 FxLfoDestination::CompressorRatio => 24,
418 FxLfoDestination::CompressorSideChainEq => 25,
419 FxLfoDestination::CompressorMakeUpGain => 26,
420 FxLfoDestination::CompressorDryWetMix => 27,
421 FxLfoDestination::CompressorVolume => 28,
422 }
423 }
424}
425
426#[derive(
428 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
429)]
430pub enum FxDelayTimeOnTheGrid {
431 _128th,
432 _64th,
433 _64thDotted,
434 _32nd,
435 _32ndDotted,
436 _16th,
437 _16thDotted,
438 _8th,
439 _8thDotted,
440 #[default]
441 Quarter,
442 QuarterDotted,
443 Half,
444 HalfDotted,
445 Whole,
446 NotOnTheGrid(u8),
447}
448
449impl TryFrom<&str> for FxDelayTimeOnTheGrid {
450 type Error = ConversionError;
451 fn try_from(value: &str) -> Result<Self, Self::Error> {
452 match value {
454 "128th" => Ok(Self::_128th),
455 "64th" => Ok(Self::_64th),
456 "64thdotted" => Ok(Self::_64thDotted),
457 "32nd" => Ok(Self::_32nd),
458 "32nddotted" => Ok(Self::_32ndDotted),
459 "16th" => Ok(Self::_16th),
460 "16thdotted" => Ok(Self::_16thDotted),
461 "8th" => Ok(Self::_8th),
462 "8thdotted" => Ok(Self::_8thDotted),
463 "quarter" => Ok(Self::Quarter),
464 "quarterdotted" => Ok(Self::QuarterDotted),
465 "half" => Ok(Self::Half),
466 "halfdotted" => Ok(Self::HalfDotted),
467 "whole" => Ok(Self::Whole),
468 _ => Err(ConversionError::Range {
469 value: value.to_string(),
470 type_name: "FxDelayTimeOnTheGrid".to_string(),
471 }),
472 }
473 }
474}
475
476#[allow(clippy::fallible_impl_from)]
479impl From<FxDelayTimeOnTheGrid> for &str {
480 fn from(value: FxDelayTimeOnTheGrid) -> Self {
481 match value {
482 FxDelayTimeOnTheGrid::_128th => "128th",
483 FxDelayTimeOnTheGrid::_64th => "64th",
484 FxDelayTimeOnTheGrid::_64thDotted => "64thdotted",
485 FxDelayTimeOnTheGrid::_32nd => "32nd",
486 FxDelayTimeOnTheGrid::_32ndDotted => "32nddotted",
487 FxDelayTimeOnTheGrid::_16th => "16th",
488 FxDelayTimeOnTheGrid::_16thDotted => "16thdotted",
489 FxDelayTimeOnTheGrid::_8th => "8th",
490 FxDelayTimeOnTheGrid::_8thDotted => "8thdotted",
491 FxDelayTimeOnTheGrid::Quarter => "quarter",
492 FxDelayTimeOnTheGrid::QuarterDotted => "quarterdotted",
493 FxDelayTimeOnTheGrid::Half => "half",
494 FxDelayTimeOnTheGrid::HalfDotted => "halfdotted",
495 FxDelayTimeOnTheGrid::Whole => "whole",
496 FxDelayTimeOnTheGrid::NotOnTheGrid(val) => {
497 panic!("Not on the grid delay time: {val}")
498 }
499 }
500 }
501}
502
503impl From<FxDelayTimeOnTheGrid> for u8 {
505 fn from(value: FxDelayTimeOnTheGrid) -> Self {
506 match value {
507 FxDelayTimeOnTheGrid::_128th => 0,
508 FxDelayTimeOnTheGrid::_64th => 1,
509 FxDelayTimeOnTheGrid::_64thDotted => 2,
510 FxDelayTimeOnTheGrid::_32nd => 3,
511 FxDelayTimeOnTheGrid::_32ndDotted => 5,
512 FxDelayTimeOnTheGrid::_16th => 7,
513 FxDelayTimeOnTheGrid::_16thDotted => 11,
514 FxDelayTimeOnTheGrid::_8th => 15,
515 FxDelayTimeOnTheGrid::_8thDotted => 24,
516 FxDelayTimeOnTheGrid::Quarter => 32,
517 FxDelayTimeOnTheGrid::QuarterDotted => 48,
518 FxDelayTimeOnTheGrid::Half => 64,
519 FxDelayTimeOnTheGrid::HalfDotted => 80,
520 FxDelayTimeOnTheGrid::Whole => 128,
521 FxDelayTimeOnTheGrid::NotOnTheGrid(val) => val,
522 }
523 }
524}
525
526#[derive(
528 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
529)]
530pub enum FxCompAttack {
531 #[default]
533 _0_03,
534 _0_1,
536 _0_3,
538 _1,
540 _3,
542 _10,
544 _30,
546}
547
548impl TryFrom<&str> for FxCompAttack {
549 type Error = ConversionError;
550 fn try_from(value: &str) -> Result<Self, Self::Error> {
551 match value {
552 "0.03" => Ok(Self::_0_03),
553 "0.1" => Ok(Self::_0_1),
554 "0.3" => Ok(Self::_0_3),
555 "1" => Ok(Self::_1),
556 "3" => Ok(Self::_3),
557 "10" => Ok(Self::_10),
558 "30" => Ok(Self::_30),
559 _ => Err(ConversionError::Range {
560 value: value.to_string(),
561 type_name: "FxCompAttack".to_string(),
562 }),
563 }
564 }
565}
566
567impl From<FxCompAttack> for &str {
568 fn from(value: FxCompAttack) -> Self {
569 match value {
570 FxCompAttack::_0_03 => "0.03",
571 FxCompAttack::_0_1 => "0.1",
572 FxCompAttack::_0_3 => "0.3",
573 FxCompAttack::_1 => "1",
574 FxCompAttack::_3 => "3",
575 FxCompAttack::_10 => "10",
576 FxCompAttack::_30 => "30",
577 }
578 }
579}
580
581impl From<FxCompAttack> for u8 {
582 fn from(value: FxCompAttack) -> Self {
583 match value {
584 FxCompAttack::_0_03 => 0,
585 FxCompAttack::_0_1 => 1,
586 FxCompAttack::_0_3 => 2,
587 FxCompAttack::_1 => 3,
588 FxCompAttack::_3 => 4,
589 FxCompAttack::_10 => 5,
590 FxCompAttack::_30 => 6,
591 }
592 }
593}
594
595impl TryFrom<u8> for FxCompAttack {
596 type Error = ConversionError;
597 fn try_from(value: u8) -> Result<Self, Self::Error> {
598 match value {
599 0 => Ok(Self::_0_03),
600 1 => Ok(Self::_0_1),
601 2 => Ok(Self::_0_3),
602 3 => Ok(Self::_1),
603 4 => Ok(Self::_3),
604 5 => Ok(Self::_10),
605 6 => Ok(Self::_30),
606 _ => Err(ConversionError::Range {
607 value: value.to_string(),
608 type_name: "FxCompAttack".to_string(),
609 }),
610 }
611 }
612}
613
614#[derive(
616 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
617)]
618pub enum FxCompRelease {
619 _0_1,
621 _0_2,
623 #[default]
624 _0_4,
626 _0_6,
628 _1,
630 _2,
632 A1,
634 A2,
636}
637
638impl TryFrom<&str> for FxCompRelease {
639 type Error = ConversionError;
640 fn try_from(value: &str) -> Result<Self, Self::Error> {
641 match value {
642 "0.1" => Ok(Self::_0_1),
643 "0.2" => Ok(Self::_0_2),
644 "0.4" => Ok(Self::_0_4),
645 "0.6" => Ok(Self::_0_6),
646 "1" => Ok(Self::_1),
647 "2" => Ok(Self::_2),
648 "A1" => Ok(Self::A1),
649 "A2" => Ok(Self::A2),
650 _ => Err(ConversionError::Range {
651 value: value.to_string(),
652 type_name: "FxCompRelease".to_string(),
653 }),
654 }
655 }
656}
657
658impl From<FxCompRelease> for &str {
659 fn from(value: FxCompRelease) -> Self {
660 match value {
661 FxCompRelease::_0_1 => "0.1",
662 FxCompRelease::_0_2 => "0.2",
663 FxCompRelease::_0_4 => "0.4",
664 FxCompRelease::_0_6 => "0.6",
665 FxCompRelease::_1 => "1",
666 FxCompRelease::_2 => "2",
667 FxCompRelease::A1 => "A1",
668 FxCompRelease::A2 => "A2",
669 }
670 }
671}
672
673impl From<FxCompRelease> for u8 {
674 fn from(value: FxCompRelease) -> Self {
675 match value {
676 FxCompRelease::_0_1 => 0,
677 FxCompRelease::_0_2 => 1,
678 FxCompRelease::_0_4 => 2,
679 FxCompRelease::_0_6 => 3,
680 FxCompRelease::_1 => 4,
681 FxCompRelease::_2 => 5,
682 FxCompRelease::A1 => 6,
683 FxCompRelease::A2 => 7,
684 }
685 }
686}
687
688impl TryFrom<u8> for FxCompRelease {
689 type Error = ConversionError;
690 fn try_from(value: u8) -> Result<Self, Self::Error> {
691 match value {
692 0 => Ok(Self::_0_1),
693 1 => Ok(Self::_0_2),
694 2 => Ok(Self::_0_4),
695 3 => Ok(Self::_0_6),
696 4 => Ok(Self::_1),
697 5 => Ok(Self::_2),
698 6 => Ok(Self::A1),
699 7 => Ok(Self::A2),
700 _ => Err(ConversionError::Range {
701 value: value.to_string(),
702 type_name: "FxCompRelease".to_string(),
703 }),
704 }
705 }
706}
707
708#[derive(
710 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
711)]
712pub enum FxCompRatio {
713 #[default]
714 _1B2,
716 _1B4,
718 _1B8,
720 Max,
722}
723
724impl TryFrom<&str> for FxCompRatio {
725 type Error = ConversionError;
726 fn try_from(value: &str) -> Result<Self, Self::Error> {
727 match value {
728 "1:2" => Ok(Self::_1B2),
729 "1:4" => Ok(Self::_1B4),
730 "1:8" => Ok(Self::_1B8),
731 "max" => Ok(Self::Max),
732 _ => Err(ConversionError::Range {
733 value: value.to_string(),
734 type_name: "FxCompRatio".to_string(),
735 }),
736 }
737 }
738}
739
740impl From<FxCompRatio> for &str {
741 fn from(value: FxCompRatio) -> Self {
742 match value {
743 FxCompRatio::_1B2 => "1:2",
744 FxCompRatio::_1B4 => "1:4",
745 FxCompRatio::_1B8 => "1:8",
746 FxCompRatio::Max => "max",
747 }
748 }
749}
750
751impl From<FxCompRatio> for u8 {
752 fn from(value: FxCompRatio) -> Self {
753 match value {
754 FxCompRatio::_1B2 => 0,
755 FxCompRatio::_1B4 => 1,
756 FxCompRatio::_1B8 => 2,
757 FxCompRatio::Max => 3,
758 }
759 }
760}
761
762impl TryFrom<u8> for FxCompRatio {
763 type Error = ConversionError;
764 fn try_from(value: u8) -> Result<Self, Self::Error> {
765 match value {
766 0 => Ok(Self::_1B2),
767 1 => Ok(Self::_1B4),
768 2 => Ok(Self::_1B8),
769 3 => Ok(Self::Max),
770 _ => Err(ConversionError::Range {
771 value: value.to_string(),
772 type_name: "FxCompRatio".to_string(),
773 }),
774 }
775 }
776}
777
778#[derive(
780 Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
781)]
782pub enum FxCompSideChainEq {
783 Off,
784 #[default]
785 Lpf,
786 Hpf,
787 Hit,
788}
789
790impl TryFrom<&str> for FxCompSideChainEq {
791 type Error = ConversionError;
792 fn try_from(value: &str) -> Result<Self, Self::Error> {
793 match value {
794 "off" => Ok(Self::Off),
795 "lpf" => Ok(Self::Lpf),
796 "hpf" => Ok(Self::Hpf),
797 "hit" => Ok(Self::Hit),
798 _ => Err(ConversionError::Range {
799 value: value.to_string(),
800 type_name: "FxCompSideChainEq".to_string(),
801 }),
802 }
803 }
804}
805
806impl From<FxCompSideChainEq> for &str {
807 fn from(value: FxCompSideChainEq) -> Self {
808 match value {
809 FxCompSideChainEq::Off => "off",
810 FxCompSideChainEq::Lpf => "lpf",
811 FxCompSideChainEq::Hpf => "hpf",
812 FxCompSideChainEq::Hit => "hit",
813 }
814 }
815}
816
817impl From<FxCompSideChainEq> for u8 {
818 fn from(value: FxCompSideChainEq) -> Self {
819 match value {
820 FxCompSideChainEq::Off => 0,
821 FxCompSideChainEq::Lpf => 1,
822 FxCompSideChainEq::Hpf => 2,
823 FxCompSideChainEq::Hit => 3,
824 }
825 }
826}
827
828impl TryFrom<u8> for FxCompSideChainEq {
829 type Error = ConversionError;
830 fn try_from(value: u8) -> Result<Self, Self::Error> {
831 match value {
832 0 => Ok(Self::Off),
833 1 => Ok(Self::Lpf),
834 2 => Ok(Self::Hpf),
835 3 => Ok(Self::Hit),
836 _ => Err(ConversionError::Range {
837 value: value.to_string(),
838 type_name: "FxCompSideChainEq".to_string(),
839 }),
840 }
841 }
842}