rbox_setting/lib.rs
1// Copyright (C) 2026 Dylan Jones
2// SPDX-License-Identifier: GPL-3.0-only
3
4//! Rekordbox `*SETTING.DAT` file handler.
5//!
6//! These files are either present in the `%APPDATA%\Pioneer\rekordbox6` directory on the machine
7//! running Rekordbox, or in the `PIONEER` directory of a USB drive (device exports).
8//!
9//! Rekordbox stores the user settings in `*SETTING.DAT` files, which also get exported to USB
10//! devices. These files are either present in the `%APPDATA%\Pioneer\rekordbox6` directory on
11//! the machine running Rekordbox, or in the `PIONEER` directory of a USB drive (device exports).
12//!
13//! The setting files store the settings found on the "DJ System" > "My Settings" page of the
14//! Rekordbox preferences. These include language, LCD brightness, tempo fader range, crossfader
15//! curve and other settings for Pioneer professional DJ equipment.
16
17use binrw::{binrw, io::Cursor, BinRead, BinWrite, Endian, NullString};
18use parse_display::Display;
19
20pub type Result<T> = core::result::Result<T, SettingError>;
21
22#[derive(Debug, thiserror::Error)]
23pub enum SettingError {
24 #[error(transparent)]
25 IOError(#[from] std::io::Error),
26
27 #[error(transparent)]
28 BinReadError(#[from] binrw::error::Error),
29
30 #[error("Invalid {0} value: {1}")]
31 InvalidValue(String, String),
32
33 #[error("Not a {0} file")]
34 InvalidFile(String),
35}
36
37// -- MySetting ------------------------------------------------------------------------------------
38
39/// Found at "PLAYER > DISPLAY(INDICATOR) > ON AIR DISPLAY" of the "My Settings" page in the
40/// Rekordbox preferences.
41#[binrw]
42#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
43#[brw(repr = u8)]
44pub enum OnAirDisplay {
45 /// Named "OFF" in the Rekordbox preferences.
46 Off = 0x80,
47 /// Named "ON" in the Rekordbox preferences.
48 #[default]
49 On,
50}
51
52impl TryFrom<String> for OnAirDisplay {
53 type Error = SettingError;
54
55 fn try_from(value: String) -> core::result::Result<OnAirDisplay, Self::Error> {
56 match value.as_str() {
57 "Off" => Ok(Self::Off),
58 "On" => Ok(Self::On),
59 _ => Err(SettingError::InvalidValue("OnAirDisplay".into(), value)),
60 }
61 }
62}
63
64/// Found at "PLAYER > DISPLAY(LCD) > LCD BRIGHTNESS" of the "My Settings" page in the Rekordbox
65/// preferences.
66#[binrw]
67#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
68#[brw(repr = u8)]
69pub enum LCDBrightness {
70 /// Named "1" in the Rekordbox preferences.
71 #[display("1")]
72 One = 0x81,
73 /// Named "2" in the Rekordbox preferences.
74 #[display("2")]
75 Two,
76 /// Named "3" in the Rekordbox preferences.
77 #[display("3")]
78 #[default]
79 Three,
80 /// Named "4" in the Rekordbox preferences.
81 #[display("4")]
82 Four,
83 /// Named "5" in the Rekordbox preferences.
84 #[display("5")]
85 Five,
86}
87
88impl TryFrom<String> for LCDBrightness {
89 type Error = SettingError;
90
91 fn try_from(value: String) -> core::result::Result<LCDBrightness, Self::Error> {
92 match value.as_str() {
93 "One" => Ok(Self::One),
94 "Two" => Ok(Self::Two),
95 "Three" => Ok(Self::Three),
96 "Four" => Ok(Self::Four),
97 "Five" => Ok(Self::Five),
98 x => Err(SettingError::InvalidValue("LCDBrightness".into(), x.into())),
99 }
100 }
101}
102
103/// Found at "PLAYER > DJ SETTING > QUANTIZE" of the "My Settings" page in the Rekordbox
104/// preferences.
105#[binrw]
106#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
107#[brw(repr = u8)]
108pub enum Quantize {
109 /// Named "OFF" in the Rekordbox preferences.
110 Off = 0x80,
111 /// Named "ON" in the Rekordbox preferences.
112 #[default]
113 On,
114}
115
116impl TryFrom<String> for Quantize {
117 type Error = SettingError;
118
119 fn try_from(value: String) -> core::result::Result<Quantize, Self::Error> {
120 match value.as_str() {
121 "Off" => Ok(Self::Off),
122 "On" => Ok(Self::On),
123 _ => Err(SettingError::InvalidValue("Quantize".into(), value)),
124 }
125 }
126}
127
128/// Found at "PLAYER > DJ SETTING > AUTO CUE LEVEL" of the "My Settings" page in the Rekordbox
129/// preferences.
130#[binrw]
131#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
132#[brw(repr = u8)]
133pub enum AutoCueLevel {
134 /// Named "-78dB" in the Rekordbox preferences.
135 #[display("-78dB")]
136 Minus78dB = 0x87,
137 /// Named "-72dB" in the Rekordbox preferences.
138 #[display("-72dB")]
139 Minus72dB = 0x86,
140 /// Named "-66dB" in the Rekordbox preferences.
141 #[display("-66dB")]
142 Minus66dB = 0x85,
143 /// Named "-60dB" in the Rekordbox preferences.
144 #[display("-60dB")]
145 Minus60dB = 0x84,
146 /// Named "-54dB" in the Rekordbox preferences.
147 #[display("-54dB")]
148 Minus54dB = 0x83,
149 /// Named "-48dB" in the Rekordbox preferences.
150 #[display("-48dB")]
151 Minus48dB = 0x82,
152 /// Named "-42dB" in the Rekordbox preferences.
153 #[display("-42dB")]
154 Minus42dB = 0x81,
155 /// Named "-36dB" in the Rekordbox preferences.
156 #[display("-36dB")]
157 Minus36dB = 0x80,
158 /// Named "MEMORY" in the Rekordbox preferences.
159 #[default]
160 Memory = 0x88,
161}
162
163impl TryFrom<String> for AutoCue {
164 type Error = SettingError;
165
166 fn try_from(value: String) -> core::result::Result<AutoCue, Self::Error> {
167 match value.as_str() {
168 "Off" => Ok(Self::Off),
169 "On" => Ok(Self::On),
170 _ => Err(SettingError::InvalidValue("AutoCue".into(), value)),
171 }
172 }
173}
174
175impl TryFrom<String> for AutoCueLevel {
176 type Error = SettingError;
177
178 fn try_from(value: String) -> core::result::Result<AutoCueLevel, Self::Error> {
179 match value.as_str() {
180 "Minus78dB" => Ok(Self::Minus78dB),
181 "Minus72dB" => Ok(Self::Minus72dB),
182 "Minus66dB" => Ok(Self::Minus66dB),
183 "Minus60dB" => Ok(Self::Minus60dB),
184 "Minus54dB" => Ok(Self::Minus54dB),
185 "Minus48dB" => Ok(Self::Minus48dB),
186 "Minus42dB" => Ok(Self::Minus42dB),
187 "Minus36dB" => Ok(Self::Minus36dB),
188 "Memory" => Ok(Self::Memory),
189 _ => Err(SettingError::InvalidValue("AutoCueLevel".into(), value)),
190 }
191 }
192}
193
194/// Found at "PLAYER > DISPLAY(LCD) > LANGUAGE" of the "My Settings" page in the Rekordbox
195/// preferences.
196#[binrw]
197#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
198#[brw(repr = u8)]
199pub enum Language {
200 /// Named "English" in the Rekordbox preferences.
201 #[default]
202 English = 0x81,
203 /// Named "Français" in the Rekordbox preferences.
204 #[display("Français")]
205 French,
206 /// Named "Deutsch" in the Rekordbox preferences.
207 #[display("Deutsch")]
208 German,
209 /// Named "Italiano" in the Rekordbox preferences.
210 #[display("Italiano")]
211 Italian,
212 /// Named "Nederlands" in the Rekordbox preferences.
213 #[display("Nederlands")]
214 Dutch,
215 /// Named "Español" in the Rekordbox preferences.
216 #[display("Español")]
217 Spanish,
218 /// Named "Русский" in the Rekordbox preferences.
219 #[display("Русский")]
220 Russian,
221 /// Named "한국어" in the Rekordbox preferences.
222 #[display("한국어")]
223 Korean,
224 /// Named "简体中文" in the Rekordbox preferences.
225 ChineseSimplified,
226 #[display("简体中文")]
227 /// Named "繁體中文" in the Rekordbox preferences.
228 #[display("繁體中文")]
229 ChineseTraditional,
230 /// Named "日本語" in the Rekordbox preferences.
231 #[display("日本語")]
232 Japanese,
233 /// Named "Português" in the Rekordbox preferences.
234 #[display("Português")]
235 Portuguese,
236 /// Named "Svenska" in the Rekordbox preferences.
237 #[display("Svenska")]
238 Swedish,
239 /// Named "Čeština" in the Rekordbox preferences.
240 #[display("Čeština")]
241 Czech,
242 /// Named "Magyar" in the Rekordbox preferences.
243 #[display("Magyar")]
244 Hungarian,
245 /// Named "Dansk" in the Rekordbox preferences.
246 #[display("Dansk")]
247 Danish,
248 /// Named "Ελληνικά" in the Rekordbox preferences.
249 #[display("Ελληνικά")]
250 Greek,
251 /// Named "Türkçe" in the Rekordbox preferences.
252 #[display("Türkçe")]
253 Turkish,
254}
255
256impl TryFrom<String> for Language {
257 type Error = SettingError;
258
259 fn try_from(value: String) -> core::result::Result<Language, Self::Error> {
260 match value.as_str() {
261 "English" => Ok(Self::English),
262 "French" => Ok(Self::French),
263 "German" => Ok(Self::German),
264 "Italian" => Ok(Self::Italian),
265 "Dutch" => Ok(Self::Dutch),
266 "Spanish" => Ok(Self::Spanish),
267 "Russian" => Ok(Self::Russian),
268 "Korean" => Ok(Self::Korean),
269 "ChineseSimplified" => Ok(Self::ChineseSimplified),
270 "ChineseTraditional" => Ok(Self::ChineseTraditional),
271 "Japanese" => Ok(Self::Japanese),
272 "Portuguese" => Ok(Self::Portuguese),
273 "Swedish" => Ok(Self::Swedish),
274 "Czech" => Ok(Self::Czech),
275 "Hungarian" => Ok(Self::Hungarian),
276 "Danish" => Ok(Self::Danish),
277 "Greek" => Ok(Self::Greek),
278 "Turkish" => Ok(Self::Turkish),
279 _ => Err(SettingError::InvalidValue("Language".into(), value)),
280 }
281 }
282}
283
284/// Found at "PLAYER > DISPLAY(INDICATOR) > JOG RING BRIGHTNESS" of the "My Settings" page in the
285/// Rekordbox preferences.
286#[binrw]
287#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
288#[brw(repr = u8)]
289pub enum JogRingBrightness {
290 /// Named "OFF" in the Rekordbox preferences.
291 Off = 0x80,
292 /// Named "1 (Dark)" in the Rekordbox preferences.
293 #[display("1 (Dark)")]
294 Dark,
295 /// Named "2 (Bright)" in the Rekordbox preferences.
296 #[display("2 (Bright)")]
297 #[default]
298 Bright,
299}
300
301impl TryFrom<String> for JogRingBrightness {
302 type Error = SettingError;
303
304 fn try_from(value: String) -> core::result::Result<JogRingBrightness, Self::Error> {
305 match value.as_str() {
306 "Off" => Ok(Self::Off),
307 "Dark" => Ok(Self::Dark),
308 "Bright" => Ok(Self::Bright),
309 _ => Err(SettingError::InvalidValue(
310 "JogRingBrightness".into(),
311 value,
312 )),
313 }
314 }
315}
316
317/// Found at "PLAYER > DISPLAY(INDICATOR) > JOG RING INDICATOR" of the "My Settings" page in the
318/// Rekordbox preferences.
319#[binrw]
320#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
321#[brw(repr = u8)]
322pub enum JogRingIndicator {
323 /// Named "OFF" in the Rekordbox preferences.
324 Off = 0x80,
325 /// Named "ON" in the Rekordbox preferences.
326 #[default]
327 On,
328}
329
330impl TryFrom<String> for JogRingIndicator {
331 type Error = SettingError;
332
333 fn try_from(value: String) -> core::result::Result<JogRingIndicator, Self::Error> {
334 match value.as_str() {
335 "Off" => Ok(Self::Off),
336 "On" => Ok(Self::On),
337 _ => Err(SettingError::InvalidValue("JogRingIndicator".into(), value)),
338 }
339 }
340}
341
342/// Found at "PLAYER > DISPLAY(INDICATOR) > SLIP FLASHING" of the "My Settings" page in the
343/// Rekordbox preferences.
344#[binrw]
345#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
346#[brw(repr = u8)]
347pub enum SlipFlashing {
348 /// Named "OFF" in the Rekordbox preferences.
349 Off = 0x80,
350 /// Named "ON" in the Rekordbox preferences.
351 #[default]
352 On,
353}
354
355impl TryFrom<String> for SlipFlashing {
356 type Error = SettingError;
357
358 fn try_from(value: String) -> core::result::Result<SlipFlashing, Self::Error> {
359 match value.as_str() {
360 "Off" => Ok(Self::Off),
361 "On" => Ok(Self::On),
362 _ => Err(SettingError::InvalidValue("SlipFlashing".into(), value)),
363 }
364 }
365}
366
367/// Found at "PLAYER > DISPLAY(INDICATOR) > DISC SLOT ILLUMINATION" of the "My Settings" page in the
368/// Rekordbox preferences.
369#[binrw]
370#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
371#[brw(repr = u8)]
372pub enum DiscSlotIllumination {
373 /// Named "OFF" in the Rekordbox preferences.
374 Off = 0x80,
375 /// Named "1 (Dark)" in the Rekordbox preferences.
376 #[display("1 (Dark)")]
377 Dark,
378 /// Named "2 (Bright)" in the Rekordbox preferences.
379 #[display("2 (Bright)")]
380 #[default]
381 Bright,
382}
383
384impl TryFrom<String> for DiscSlotIllumination {
385 type Error = SettingError;
386
387 fn try_from(value: String) -> core::result::Result<DiscSlotIllumination, Self::Error> {
388 match value.as_str() {
389 "Off" => Ok(Self::Off),
390 "Dark" => Ok(Self::Dark),
391 "Bright" => Ok(Self::Bright),
392 _ => Err(SettingError::InvalidValue(
393 "DiscSlotIllumination".into(),
394 value,
395 )),
396 }
397 }
398}
399
400/// Found at "PLAYER > DJ SETTING > EJECT/LOAD LOCK" of the "My Settings" page in the Rekordbox
401/// preferences.
402#[binrw]
403#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
404#[brw(repr = u8)]
405pub enum EjectLock {
406 /// Named "UNLOCK" in the Rekordbox preferences.
407 #[default]
408 Unlock = 0x80,
409 /// Named "LOCK" in the Rekordbox preferences.
410 Lock,
411}
412
413impl TryFrom<String> for EjectLock {
414 type Error = SettingError;
415
416 fn try_from(value: String) -> core::result::Result<EjectLock, Self::Error> {
417 match value.as_str() {
418 "Unlock" => Ok(Self::Unlock),
419 "Lock" => Ok(Self::Lock),
420 _ => Err(SettingError::InvalidValue("EjectLock".into(), value)),
421 }
422 }
423}
424
425/// Found at "PLAYER > DJ SETTING > SYNC" of the "My Settings" page in the Rekordbox
426/// preferences.
427#[binrw]
428#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
429#[brw(repr = u8)]
430pub enum Sync {
431 /// Named "OFF" in the Rekordbox preferences.
432 #[default]
433 Off = 0x80,
434 /// Named "ON" in the Rekordbox preferences.
435 On,
436}
437
438impl TryFrom<String> for Sync {
439 type Error = SettingError;
440
441 fn try_from(value: String) -> core::result::Result<Sync, Self::Error> {
442 match value.as_str() {
443 "Off" => Ok(Self::Off),
444 "On" => Ok(Self::On),
445 _ => Err(SettingError::InvalidValue("Sync".into(), value)),
446 }
447 }
448}
449
450/// Found at "PLAYER > DJ SETTING > PLAY MODE / AUTO PLAY MODE" of the "My Settings" page in the
451/// Rekordbox preferences.
452#[binrw]
453#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
454#[brw(repr = u8)]
455pub enum PlayMode {
456 /// Named "CONTINUE / ON" in the Rekordbox preferences.
457 #[display("Continue / On")]
458 Continue = 0x80,
459 /// Named "SINGLE / OFF" in the Rekordbox preferences.
460 #[display("Single / Off")]
461 #[default]
462 Single,
463}
464
465impl TryFrom<String> for PlayMode {
466 type Error = SettingError;
467
468 fn try_from(value: String) -> core::result::Result<PlayMode, Self::Error> {
469 match value.as_str() {
470 "Continue" => Ok(Self::Continue),
471 "Single" => Ok(Self::Single),
472 _ => Err(SettingError::InvalidValue("PlayMode".into(), value)),
473 }
474 }
475}
476
477/// Found at "PLAYER > DJ SETTING > QUANTIZE BEAT VALUE" of the "My Settings" page in the Rekordbox
478/// preferences.
479#[binrw]
480#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
481#[brw(repr = u8)]
482pub enum QuantizeBeatValue {
483 /// Named "1/8 Beat" in the Rekordbox preferences.
484 #[display("1/8 Beat")]
485 EighthBeat = 0x83,
486 /// Named "1/4 Beat" in the Rekordbox preferences.
487 #[display("1/4 Beat")]
488 QuarterBeat = 0x82,
489 /// Named "1/2 Beat" in the Rekordbox preferences.
490 #[display("1/2 Beat")]
491 HalfBeat = 0x81,
492 /// Named "1 Beat" in the Rekordbox preferences.
493 #[default]
494 #[display("1 Beat")]
495 FullBeat = 0x80,
496}
497
498impl TryFrom<String> for QuantizeBeatValue {
499 type Error = SettingError;
500
501 fn try_from(value: String) -> core::result::Result<QuantizeBeatValue, Self::Error> {
502 match value.as_str() {
503 "EighthBeat" => Ok(Self::EighthBeat),
504 "QuarterBeat" => Ok(Self::QuarterBeat),
505 "HalfBeat" => Ok(Self::HalfBeat),
506 "FullBeat" => Ok(Self::FullBeat),
507 _ => Err(SettingError::InvalidValue(
508 "QuantizeBeatValue".into(),
509 value,
510 )),
511 }
512 }
513}
514
515/// Found at "PLAYER > DJ SETTING > HOT CUE AUTO LOAD" of the "My Settings" page in the Rekordbox
516/// preferences.
517#[binrw]
518#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
519#[brw(repr = u8)]
520pub enum HotCueAutoLoad {
521 /// Named "OFF" in the Rekordbox preferences.
522 Off = 0x80,
523 /// Named "rekordbox SETTING" in the Rekordbox preferences.
524 #[display("rekordbox SETTING")]
525 RekordboxSetting = 0x82,
526 /// Named "On" in the Rekordbox preferences.
527 #[default]
528 On = 0x81,
529}
530
531impl TryFrom<String> for HotCueAutoLoad {
532 type Error = SettingError;
533
534 fn try_from(value: String) -> core::result::Result<HotCueAutoLoad, Self::Error> {
535 match value.as_str() {
536 "Off" => Ok(Self::Off),
537 "RekordboxSetting" => Ok(Self::RekordboxSetting),
538 "On" => Ok(Self::On),
539 _ => Err(SettingError::InvalidValue("HotCueAutoLoad".into(), value)),
540 }
541 }
542}
543
544/// Found at "PLAYER > DJ SETTING > HOT CUE COLOR" of the "My Settings" page in the Rekordbox
545/// preferences.
546#[binrw]
547#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
548#[brw(repr = u8)]
549pub enum HotCueColor {
550 /// Named "OFF" in the Rekordbox preferences.
551 #[default]
552 Off = 0x80,
553 /// Named "On" in the Rekordbox preferences.
554 On,
555}
556
557impl TryFrom<String> for HotCueColor {
558 type Error = SettingError;
559
560 fn try_from(value: String) -> core::result::Result<HotCueColor, Self::Error> {
561 match value.as_str() {
562 "Off" => Ok(Self::Off),
563 "On" => Ok(Self::On),
564 _ => Err(SettingError::InvalidValue("HotCueColor".into(), value)),
565 }
566 }
567}
568
569/// Found at "PLAYER > DJ SETTING > NEEDLE LOCK" of the "My Settings" page in the Rekordbox
570/// preferences.
571#[binrw]
572#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
573#[brw(repr = u8)]
574pub enum NeedleLock {
575 /// Named "UNLOCK" in the Rekordbox preferences.
576 Unlock = 0x80,
577 /// Named "LOCK" in the Rekordbox preferences.
578 #[default]
579 Lock,
580}
581
582impl TryFrom<String> for NeedleLock {
583 type Error = SettingError;
584
585 fn try_from(value: String) -> core::result::Result<NeedleLock, Self::Error> {
586 match value.as_str() {
587 "Unlock" => Ok(Self::Unlock),
588 "Lock" => Ok(Self::Lock),
589 _ => Err(SettingError::InvalidValue("NeedleLock".into(), value)),
590 }
591 }
592}
593
594/// Found at "PLAYER > DJ SETTING > TIME MODE" of the "My Settings" page in the Rekordbox
595/// preferences.
596#[binrw]
597#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
598#[brw(repr = u8)]
599pub enum TimeMode {
600 /// Named "Elapsed" in the Rekordbox preferences.
601 Elapsed = 0x80,
602 /// Named "REMAIN" in the Rekordbox preferences.
603 #[default]
604 Remain,
605}
606
607impl TryFrom<String> for TimeMode {
608 type Error = SettingError;
609
610 fn try_from(value: String) -> core::result::Result<TimeMode, Self::Error> {
611 match value.as_str() {
612 "Elapsed" => Ok(Self::Elapsed),
613 "Remain" => Ok(Self::Remain),
614 _ => Err(SettingError::InvalidValue("TimeMode".into(), value)),
615 }
616 }
617}
618
619/// Found at "PLAYER > DJ SETTING > JOG MODE" of the "My Settings" page in the Rekordbox
620/// preferences.
621#[binrw]
622#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
623#[brw(repr = u8)]
624pub enum JogMode {
625 /// Named "VINYL" in the Rekordbox preferences.
626 #[default]
627 Vinyl = 0x81,
628 /// Named "CDJ" in the Rekordbox preferences.
629 CDJ = 0x80,
630}
631
632impl TryFrom<String> for JogMode {
633 type Error = SettingError;
634
635 fn try_from(value: String) -> core::result::Result<JogMode, Self::Error> {
636 match value.as_str() {
637 "Vinyl" => Ok(Self::Vinyl),
638 "CDJ" => Ok(Self::CDJ),
639 _ => Err(SettingError::InvalidValue("JogMode".into(), value)),
640 }
641 }
642}
643
644/// Found at "PLAYER > DJ SETTING > AUTO CUE" of the "My Settings" page in the Rekordbox
645/// preferences.
646#[binrw]
647#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
648#[brw(repr = u8)]
649pub enum AutoCue {
650 /// Named "OFF" in the Rekordbox preferences.
651 Off = 0x80,
652 /// Named "ON" in the Rekordbox preferences.
653 #[default]
654 On,
655}
656
657/// Found at "PLAYER > DJ SETTING > MASTER TEMPO" of the "My Settings" page in the Rekordbox
658/// preferences.
659#[binrw]
660#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
661#[brw(repr = u8)]
662pub enum MasterTempo {
663 /// Named "OFF" in the Rekordbox preferences.
664 #[default]
665 Off = 0x80,
666 /// Named "ON" in the Rekordbox preferences.
667 On,
668}
669
670impl TryFrom<String> for MasterTempo {
671 type Error = SettingError;
672
673 fn try_from(value: String) -> core::result::Result<MasterTempo, Self::Error> {
674 match value.as_str() {
675 "Off" => Ok(Self::Off),
676 "On" => Ok(Self::On),
677 _ => Err(SettingError::InvalidValue("MasterTempo".into(), value)),
678 }
679 }
680}
681
682/// Found at "PLAYER > DJ SETTING > TEMPO RANGE" of the "My Settings" page in the Rekordbox
683/// preferences.
684#[binrw]
685#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
686#[brw(repr = u8)]
687pub enum TempoRange {
688 /// Named "±6" in the Rekordbox preferences.
689 #[display("±6%")]
690 SixPercent = 0x80,
691 /// Named "±10" in the Rekordbox preferences.
692 #[display("±10%")]
693 #[default]
694 TenPercent,
695 /// Named "±16" in the Rekordbox preferences.
696 #[display("±16%")]
697 SixteenPercent,
698 /// Named "WIDE" in the Rekordbox preferences.
699 Wide,
700}
701
702impl TryFrom<String> for TempoRange {
703 type Error = SettingError;
704
705 fn try_from(value: String) -> core::result::Result<TempoRange, Self::Error> {
706 match value.as_str() {
707 "SixPercent" => Ok(Self::SixPercent),
708 "TenPercent" => Ok(Self::TenPercent),
709 "SixteenPercent" => Ok(Self::SixteenPercent),
710 "Wide" => Ok(Self::Wide),
711 _ => Err(SettingError::InvalidValue("TempoRange".into(), value)),
712 }
713 }
714}
715
716/// Found at "PLAYER > DJ SETTING > PHASE METER" of the "My Settings" page in the Rekordbox
717/// preferences.
718#[binrw]
719#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
720#[brw(repr = u8)]
721pub enum PhaseMeter {
722 /// Named "TYPE 1" in the Rekordbox preferences.
723 #[default]
724 #[display("Type 1")]
725 Type1 = 0x80,
726 /// Named "TYPE 2" in the Rekordbox preferences.
727 #[display("Type 2")]
728 Type2,
729}
730
731impl TryFrom<String> for PhaseMeter {
732 type Error = SettingError;
733
734 fn try_from(value: String) -> core::result::Result<PhaseMeter, Self::Error> {
735 match value.as_str() {
736 "Type1" => Ok(Self::Type1),
737 "Type2" => Ok(Self::Type2),
738 _ => Err(SettingError::InvalidValue("PhaseMeter".into(), value)),
739 }
740 }
741}
742
743/// Payload of a `MYSETTING.DAT` file (40 bytes).
744#[binrw]
745#[derive(Debug, PartialEq, Eq, Clone)]
746#[brw(little)]
747pub struct MySetting {
748 /// Unknown field.
749 unknown1: [u8; 8],
750 /// "ON AIR DISPLAY" setting.
751 pub on_air_display: OnAirDisplay,
752 /// "LCD BRIGHTNESS" setting.
753 pub lcd_brightness: LCDBrightness,
754 /// "QUANTIZE" setting.
755 pub quantize: Quantize,
756 /// "AUTO CUE LEVEL" setting.
757 pub auto_cue_level: AutoCueLevel,
758 /// "LANGUAGE" setting.
759 pub language: Language,
760 /// Unknown field.
761 unknown2: u8,
762 /// "JOG RING BRIGHTNESS" setting.
763 pub jog_ring_brightness: JogRingBrightness,
764 /// "JOG RING INDICATOR" setting.
765 pub jog_ring_indicator: JogRingIndicator,
766 /// "SLIP FLASHING" setting.
767 pub slip_flashing: SlipFlashing,
768 /// Unknown field.
769 unknown3: [u8; 3],
770 /// "DISC SLOT ILLUMINATION" setting.
771 pub disc_slot_illumination: DiscSlotIllumination,
772 /// "EJECT/LOAD LOCK" setting.
773 pub eject_lock: EjectLock,
774 /// "SYNC" setting.
775 pub sync: Sync,
776 /// "PLAY MODE / AUTO PLAY MODE" setting.
777 pub play_mode: PlayMode,
778 /// Quantize Beat Value setting.
779 pub quantize_beat_value: QuantizeBeatValue,
780 /// "HOT CUE AUTO LOAD" setting.
781 pub hotcue_autoload: HotCueAutoLoad,
782 /// "HOT CUE COLOR" setting.
783 pub hotcue_color: HotCueColor,
784 /// Unknown field (apparently always 0).
785 #[br(assert(unknown4 == 0))]
786 unknown4: u16,
787 /// "NEEDLE LOCK" setting.
788 pub needle_lock: NeedleLock,
789 /// Unknown field (apparently always 0).
790 #[br(assert(unknown5 == 0))]
791 unknown5: u16,
792 /// "TIME MODE" setting.
793 pub time_mode: TimeMode,
794 /// "TIME MODE" setting.
795 pub jog_mode: JogMode,
796 /// "AUTO CUE" setting.
797 pub auto_cue: AutoCue,
798 /// "MASTER TEMPO" setting.
799 pub master_tempo: MasterTempo,
800 /// "TEMPO RANGE" setting.
801 pub tempo_range: TempoRange,
802 /// "PHASE METER" setting.
803 pub phase_meter: PhaseMeter,
804 /// Unknown field (apparently always 0).
805 #[br(assert(unknown6 == 0))]
806 unknown6: u16,
807}
808
809impl Default for MySetting {
810 fn default() -> Self {
811 Self {
812 unknown1: [0x78, 0x56, 0x34, 0x12, 0x02, 0x00, 0x00, 0x00],
813 on_air_display: OnAirDisplay::default(),
814 lcd_brightness: LCDBrightness::default(),
815 quantize: Quantize::default(),
816 auto_cue_level: AutoCueLevel::default(),
817 language: Language::default(),
818 unknown2: 0x01,
819 jog_ring_brightness: JogRingBrightness::default(),
820 jog_ring_indicator: JogRingIndicator::default(),
821 slip_flashing: SlipFlashing::default(),
822 unknown3: [0x01, 0x01, 0x01],
823 disc_slot_illumination: DiscSlotIllumination::default(),
824 eject_lock: EjectLock::default(),
825 sync: Sync::default(),
826 play_mode: PlayMode::default(),
827 quantize_beat_value: QuantizeBeatValue::default(),
828 hotcue_autoload: HotCueAutoLoad::default(),
829 hotcue_color: HotCueColor::default(),
830 unknown4: 0x0000,
831 needle_lock: NeedleLock::default(),
832 unknown5: 0x0000,
833 time_mode: TimeMode::default(),
834 jog_mode: JogMode::default(),
835 auto_cue: AutoCue::default(),
836 master_tempo: MasterTempo::default(),
837 tempo_range: TempoRange::default(),
838 phase_meter: PhaseMeter::default(),
839 unknown6: 0x0000,
840 }
841 }
842}
843
844impl MySetting {
845 fn file_name() -> String {
846 "MYSETTING.DAT".into()
847 }
848}
849
850// -- MySetting2 -----------------------------------------------------------------------------------
851
852/// Found at "PLAYER > DJ SETTING > VINYL SPEED ADJUST" of the "My Settings" page in the Rekordbox
853/// preferences.
854#[binrw]
855#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
856#[brw(repr = u8)]
857pub enum VinylSpeedAdjust {
858 /// Named "TOUCH & RELEASE" in the Rekordbox preferences.
859 #[display("Touch & Release")]
860 TouchRelease = 0x80,
861 /// Named "TOUCH" in the Rekordbox preferences.
862 #[default]
863 Touch,
864 /// Named "RELEASE" in the Rekordbox preferences.
865 Release,
866}
867
868impl TryFrom<String> for VinylSpeedAdjust {
869 type Error = SettingError;
870
871 fn try_from(value: String) -> core::result::Result<VinylSpeedAdjust, Self::Error> {
872 match value.as_str() {
873 "TouchRelease" => Ok(Self::TouchRelease),
874 "Touch" => Ok(Self::Touch),
875 "Release" => Ok(Self::Release),
876 _ => Err(SettingError::InvalidValue("VinylSpeedAdjust".into(), value)),
877 }
878 }
879}
880
881/// Found at "PLAYER > DISPLAY(LCD) > JOG DISPLAY MODE" of the "My Settings" page in the Rekordbox
882/// preferences.
883#[binrw]
884#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
885#[brw(repr = u8)]
886pub enum JogDisplayMode {
887 /// Named "AUTO" in the Rekordbox preferences.
888 #[default]
889 Auto = 0x80,
890 /// Named "INFO" in the Rekordbox preferences.
891 Info,
892 /// Named "SIMPLE" in the Rekordbox preferences.
893 Simple,
894 /// Named "ARTWORK" in the Rekordbox preferences.
895 Artwork,
896}
897
898impl TryFrom<String> for JogDisplayMode {
899 type Error = SettingError;
900
901 fn try_from(value: String) -> core::result::Result<JogDisplayMode, Self::Error> {
902 match value.as_str() {
903 "Auto" => Ok(Self::Auto),
904 "Info" => Ok(Self::Info),
905 "Simple" => Ok(Self::Simple),
906 "Artwork" => Ok(Self::Artwork),
907 _ => Err(SettingError::InvalidValue("JogDisplayMode".into(), value)),
908 }
909 }
910}
911
912/// Found at "PLAYER > DISPLAY(INDICATOR) > PAD/BUTTON BRIGHTNESS" of the "My Settings" page in the Rekordbox
913/// preferences.
914#[binrw]
915#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
916#[brw(repr = u8)]
917pub enum PadButtonBrightness {
918 /// Named "1" in the Rekordbox preferences.
919 #[display("1")]
920 One = 0x81,
921 /// Named "2" in the Rekordbox preferences.
922 #[display("2")]
923 Two,
924 /// Named "3" in the Rekordbox preferences.
925 #[display("3")]
926 #[default]
927 Three,
928 /// Named "4" in the Rekordbox preferences.
929 #[display("4")]
930 Four,
931}
932
933impl TryFrom<String> for PadButtonBrightness {
934 type Error = SettingError;
935
936 fn try_from(value: String) -> core::result::Result<PadButtonBrightness, Self::Error> {
937 match value.as_str() {
938 "One" => Ok(Self::One),
939 "Two" => Ok(Self::Two),
940 "Three" => Ok(Self::Three),
941 "Four" => Ok(Self::Four),
942 _ => Err(SettingError::InvalidValue(
943 "PadButtonBrightness".into(),
944 value,
945 )),
946 }
947 }
948}
949
950/// Found at "PLAYER > DISPLAY(LCD) > JOG LCD BRIGHTNESS" of the "My Settings" page in the Rekordbox
951/// preferences.
952#[binrw]
953#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
954#[brw(repr = u8)]
955pub enum JogLCDBrightness {
956 /// Named "1" in the Rekordbox preferences.
957 #[display("1")]
958 One = 0x81,
959 /// Named "2" in the Rekordbox preferences.
960 #[display("2")]
961 Two,
962 /// Named "3" in the Rekordbox preferences.
963 #[display("3")]
964 #[default]
965 Three,
966 /// Named "4" in the Rekordbox preferences.
967 #[display("4")]
968 Four,
969 /// Named "5" in the Rekordbox preferences.
970 #[display("5")]
971 Five,
972}
973
974impl TryFrom<String> for JogLCDBrightness {
975 type Error = SettingError;
976
977 fn try_from(value: String) -> core::result::Result<JogLCDBrightness, Self::Error> {
978 match value.as_str() {
979 "One" => Ok(Self::One),
980 "Two" => Ok(Self::Two),
981 "Three" => Ok(Self::Three),
982 "Four" => Ok(Self::Four),
983 "Five" => Ok(Self::Five),
984 _ => Err(SettingError::InvalidValue("JogLCDBrightness".into(), value)),
985 }
986 }
987}
988
989/// Found at "PLAYER > DJ SETTING > WAVEFORM DIVISIONS" of the "My Settings" page in the Rekordbox
990/// preferences.
991#[binrw]
992#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
993#[brw(repr = u8)]
994pub enum WaveformDivisions {
995 /// Named "TIME SCALE" in the Rekordbox preferences.
996 #[display("Time Scale")]
997 TimeScale = 0x80,
998 /// Named "PHRASE" in the Rekordbox preferences.
999 #[default]
1000 Phrase,
1001}
1002
1003impl TryFrom<String> for Waveform {
1004 type Error = SettingError;
1005
1006 fn try_from(value: String) -> core::result::Result<Waveform, Self::Error> {
1007 match value.as_str() {
1008 "Waveform" => Ok(Self::Waveform),
1009 "PhaseMeter" => Ok(Self::PhaseMeter),
1010 _ => Err(SettingError::InvalidValue("Waveform".into(), value)),
1011 }
1012 }
1013}
1014
1015impl TryFrom<String> for WaveformDivisions {
1016 type Error = SettingError;
1017
1018 fn try_from(value: String) -> core::result::Result<WaveformDivisions, Self::Error> {
1019 match value.as_str() {
1020 "TimeScale" => Ok(Self::TimeScale),
1021 "Phrase" => Ok(Self::Phrase),
1022 _ => Err(SettingError::InvalidValue(
1023 "WaveformDivisions".into(),
1024 value,
1025 )),
1026 }
1027 }
1028}
1029
1030/// Found at "PLAYER > DJ SETTING > WAVEFORM / PHASE METER" of the "My Settings" page in the Rekordbox
1031/// preferences.
1032#[binrw]
1033#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1034#[brw(repr = u8)]
1035pub enum Waveform {
1036 /// Named "WAVEFORM" in the Rekordbox preferences.
1037 #[default]
1038 Waveform = 0x80,
1039 /// Named "PHASE METER" in the Rekordbox preferences.
1040 #[display("Phase Meter")]
1041 PhaseMeter,
1042}
1043
1044/// Found at "PLAYER > DJ SETTING > BEAT JUMP BEAT VALUE" of the "My Settings" page in the Rekordbox
1045/// preferences.
1046#[binrw]
1047#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1048#[brw(repr = u8)]
1049pub enum BeatJumpBeatValue {
1050 /// Named "1/2 BEAT" in the Rekordbox preferences.
1051 #[display("1/2 Beat")]
1052 HalfBeat = 0x80,
1053 /// Named "1 BEAT" in the Rekordbox preferences.
1054 #[display("1 Beat")]
1055 OneBeat,
1056 /// Named "2 BEAT" in the Rekordbox preferences.
1057 #[display("2 Beat")]
1058 TwoBeat,
1059 /// Named "4 BEAT" in the Rekordbox preferences.
1060 #[display("4 Beat")]
1061 FourBeat,
1062 /// Named "8 BEAT" in the Rekordbox preferences.
1063 #[display("8 Beat")]
1064 EightBeat,
1065 /// Named "16 BEAT" in the Rekordbox preferences.
1066 #[display("16 Beat")]
1067 #[default]
1068 SixteenBeat,
1069 /// Named "32 BEAT" in the Rekordbox preferences.
1070 #[display("32 Beat")]
1071 ThirtytwoBeat,
1072 /// Named "64 BEAT" in the Rekordbox preferences.
1073 #[display("64 Beat")]
1074 SixtyfourBeat,
1075}
1076
1077impl TryFrom<String> for BeatJumpBeatValue {
1078 type Error = SettingError;
1079
1080 fn try_from(value: String) -> core::result::Result<BeatJumpBeatValue, Self::Error> {
1081 match value.as_str() {
1082 "HalfBeat" => Ok(Self::HalfBeat),
1083 "OneBeat" => Ok(Self::OneBeat),
1084 "TwoBeat" => Ok(Self::TwoBeat),
1085 "FourBeat" => Ok(Self::FourBeat),
1086 "EightBeat" => Ok(Self::EightBeat),
1087 "SixteenBeat" => Ok(Self::SixteenBeat),
1088 "ThirtytwoBeat" => Ok(Self::ThirtytwoBeat),
1089 "SixtyfourBeat" => Ok(Self::SixtyfourBeat),
1090 _ => Err(SettingError::InvalidValue(
1091 "BeatJumpBeatValue".into(),
1092 value,
1093 )),
1094 }
1095 }
1096}
1097
1098/// Payload of a `MYSETTING2.DAT` file (40 bytes).
1099#[binrw]
1100#[derive(Debug, PartialEq, Eq, Clone)]
1101#[brw(little)]
1102pub struct MySetting2 {
1103 /// "VINYL SPEED ADJUST" setting.
1104 pub vinyl_speed_adjust: VinylSpeedAdjust,
1105 /// "JOG DISPLAY MODE" setting.
1106 pub jog_display_mode: JogDisplayMode,
1107 /// "PAD/BUTTON BRIGHTNESS" setting.
1108 pub pad_button_brightness: PadButtonBrightness,
1109 /// "JOG LCD BRIGHTNESS" setting.
1110 pub jog_lcd_brightness: JogLCDBrightness,
1111 /// "WAVEFORM DIVISIONS" setting.
1112 pub waveform_divisions: WaveformDivisions,
1113 /// Unknown field (apparently always 0).
1114 #[br(assert(unknown1 == [0; 5]))]
1115 unknown1: [u8; 5],
1116 /// "WAVEFORM / PHASE METER" setting.
1117 pub waveform: Waveform,
1118 /// Unknown field.
1119 unknown2: u8,
1120 /// "BEAT JUMP BEAT VALUE" setting.
1121 pub beat_jump_beat_value: BeatJumpBeatValue,
1122 /// Unknown field (apparently always 0).
1123 #[br(assert(unknown3 == [0; 27]))]
1124 unknown3: [u8; 27],
1125}
1126
1127impl Default for MySetting2 {
1128 fn default() -> Self {
1129 Self {
1130 vinyl_speed_adjust: VinylSpeedAdjust::default(),
1131 jog_display_mode: JogDisplayMode::default(),
1132 pad_button_brightness: PadButtonBrightness::default(),
1133 jog_lcd_brightness: JogLCDBrightness::default(),
1134 waveform_divisions: WaveformDivisions::default(),
1135 unknown1: [0; 5],
1136 waveform: Waveform::default(),
1137 unknown2: 0x81,
1138 beat_jump_beat_value: BeatJumpBeatValue::default(),
1139 unknown3: [0; 27],
1140 }
1141 }
1142}
1143
1144impl MySetting2 {
1145 fn file_name() -> String {
1146 "MYSETTING2.DAT".into()
1147 }
1148}
1149
1150// -- DJMMySetting ---------------------------------------------------------------------------------
1151
1152/// Found at "MIXER > DJ SETTING > CH FADER CURVE" of the "My Settings" page in the Rekordbox
1153/// preferences.
1154#[binrw]
1155#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1156#[brw(repr = u8)]
1157pub enum ChannelFaderCurve {
1158 /// Steep volume raise when the fader is moved near the top.
1159 #[display("Steep Top")]
1160 SteepTop = 0x80,
1161 /// Linear volume raise when the fader is moved.
1162 #[display("Linear")]
1163 #[default]
1164 Linear,
1165 /// Steep volume raise when the fader is moved near the bottom.
1166 #[display("Steep Bottom")]
1167 SteepBottom,
1168}
1169
1170impl TryFrom<String> for ChannelFaderCurve {
1171 type Error = SettingError;
1172
1173 fn try_from(value: String) -> core::result::Result<ChannelFaderCurve, Self::Error> {
1174 match value.as_str() {
1175 "SteepTop" => Ok(Self::SteepTop),
1176 "Linear" => Ok(Self::Linear),
1177 "SteepBottom" => Ok(Self::SteepBottom),
1178 _ => Err(SettingError::InvalidValue(
1179 "ChannelFaderCurve".into(),
1180 value,
1181 )),
1182 }
1183 }
1184}
1185
1186/// Found at "MIXER > DJ SETTING > CROSSFADER CURVE" of the "My Settings" page in the Rekordbox
1187/// preferences.
1188#[binrw]
1189#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1190#[brw(repr = u8)]
1191pub enum CrossfaderCurve {
1192 /// Logarithmic volume raise of the other channel near the edges of the fader.
1193 #[display("Constant Power")]
1194 ConstantPower = 0x80,
1195 /// Steep linear volume raise of the other channel near the edges of the fader, no volume
1196 /// change in the center.
1197 #[display("Slow Cut")]
1198 SlowCut,
1199 /// Steep linear volume raise of the other channel near the edges of the fader, no volume
1200 /// change in the center.
1201 #[display("Fast Cut")]
1202 #[default]
1203 FastCut,
1204}
1205
1206impl TryFrom<String> for CrossfaderCurve {
1207 type Error = SettingError;
1208
1209 fn try_from(value: String) -> core::result::Result<CrossfaderCurve, Self::Error> {
1210 match value.as_str() {
1211 "ConstantPower" => Ok(Self::ConstantPower),
1212 "SlowCut" => Ok(Self::SlowCut),
1213 "FastCut" => Ok(Self::FastCut),
1214 _ => Err(SettingError::InvalidValue("CrossfaderCurve".into(), value)),
1215 }
1216 }
1217}
1218
1219/// Found at "MIXER > DJ SETTING > HEADPHONES PRE EQ" of the "My Settings" page in the
1220/// Rekordbox preferences.
1221#[binrw]
1222#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1223#[brw(repr = u8)]
1224pub enum HeadphonesPreEQ {
1225 /// Named "POST EQ" in the Rekordbox preferences.
1226 #[default]
1227 #[display("Post EQ")]
1228 PostEQ = 0x80,
1229 /// Named "PRE EQ" in the Rekordbox preferences.
1230 #[display("Pre EQ")]
1231 PreEQ,
1232}
1233
1234impl TryFrom<String> for HeadphonesPreEQ {
1235 type Error = SettingError;
1236
1237 fn try_from(value: String) -> core::result::Result<HeadphonesPreEQ, Self::Error> {
1238 match value.as_str() {
1239 "PostEQ" => Ok(Self::PostEQ),
1240 "PreEQ" => Ok(Self::PreEQ),
1241 _ => Err(SettingError::InvalidValue("HeadphonesPreEQ".into(), value)),
1242 }
1243 }
1244}
1245
1246/// Found at "MIXER > DJ SETTING > HEADPHONES MONO SPLIT" of the "My Settings" page in the
1247/// Rekordbox preferences.
1248#[binrw]
1249#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1250#[brw(repr = u8)]
1251pub enum HeadphonesMonoSplit {
1252 /// Named "MONO SPLIT" in the Rekordbox preferences.
1253 #[display("Mono Split")]
1254 MonoSplit = 0x81,
1255 /// Named "STEREO" in the Rekordbox preferences.
1256 #[default]
1257 Stereo = 0x80,
1258}
1259
1260impl TryFrom<String> for HeadphonesMonoSplit {
1261 type Error = SettingError;
1262
1263 fn try_from(value: String) -> core::result::Result<HeadphonesMonoSplit, Self::Error> {
1264 match value.as_str() {
1265 "MonoSplit" => Ok(Self::MonoSplit),
1266 "Stereo" => Ok(Self::Stereo),
1267 _ => Err(SettingError::InvalidValue(
1268 "HeadphonesMonoSplit".into(),
1269 value,
1270 )),
1271 }
1272 }
1273}
1274
1275/// Found at "MIXER > DJ SETTING > BEAT FX QUANTIZE" of the "My Settings" page in the
1276/// Rekordbox preferences.
1277#[binrw]
1278#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1279#[brw(repr = u8)]
1280pub enum BeatFXQuantize {
1281 /// Named "OFF" in the Rekordbox preferences.
1282 Off = 0x80,
1283 /// Named "ON" in the Rekordbox preferences.
1284 #[default]
1285 On,
1286}
1287
1288impl TryFrom<String> for BeatFXQuantize {
1289 type Error = SettingError;
1290
1291 fn try_from(value: String) -> core::result::Result<BeatFXQuantize, Self::Error> {
1292 match value.as_str() {
1293 "Off" => Ok(Self::Off),
1294 "On" => Ok(Self::On),
1295 _ => Err(SettingError::InvalidValue("BeatFXQuantize".into(), value)),
1296 }
1297 }
1298}
1299
1300/// Found at "MIXER > DJ SETTING > MIC LOW CUT" of the "My Settings" page in the
1301/// Rekordbox preferences.
1302#[binrw]
1303#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1304#[brw(repr = u8)]
1305pub enum MicLowCut {
1306 /// Named "OFF" in the Rekordbox preferences.
1307 Off = 0x80,
1308 /// Named "ON(for MC)" in the Rekordbox preferences.
1309 #[default]
1310 On,
1311}
1312
1313impl TryFrom<String> for MicLowCut {
1314 type Error = SettingError;
1315
1316 fn try_from(value: String) -> core::result::Result<MicLowCut, Self::Error> {
1317 match value.as_str() {
1318 "Off" => Ok(Self::Off),
1319 "On" => Ok(Self::On),
1320 _ => Err(SettingError::InvalidValue("MicLowCut".into(), value)),
1321 }
1322 }
1323}
1324
1325/// Found at "MIXER > DJ SETTING > TALK OVER MODE" of the "My Settings" page in the Rekordbox
1326/// preferences.
1327#[binrw]
1328#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1329#[brw(repr = u8)]
1330pub enum TalkOverMode {
1331 /// Named "ADVANCED" in the Rekordbox preferences.
1332 #[default]
1333 Advanced = 0x80,
1334 /// Named "NORMAL" in the Rekordbox preferences.
1335 Normal,
1336}
1337
1338impl TryFrom<String> for TalkOverMode {
1339 type Error = SettingError;
1340
1341 fn try_from(value: String) -> core::result::Result<TalkOverMode, Self::Error> {
1342 match value.as_str() {
1343 "Advanced" => Ok(Self::Advanced),
1344 "Normal" => Ok(Self::Normal),
1345 _ => Err(SettingError::InvalidValue("TalkOverMode".into(), value)),
1346 }
1347 }
1348}
1349
1350/// Found at "MIXER > DJ SETTING > TALK OVER LEVEL" of the "My Settings" page in the Rekordbox
1351/// preferences.
1352#[binrw]
1353#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1354#[brw(repr = u8)]
1355pub enum TalkOverLevel {
1356 /// Named "-24dB" in the Rekordbox preferences.
1357 #[display("-24dB")]
1358 Minus24dB = 0x80,
1359 /// Named "-18dB" in the Rekordbox preferences.
1360 #[default]
1361 #[display("-18dB")]
1362 Minus18dB,
1363 /// Named "-12dB" in the Rekordbox preferences.
1364 #[display("-12dB")]
1365 Minus12dB,
1366 /// Named "-6dB" in the Rekordbox preferences.
1367 #[display("-6dB")]
1368 Minus6dB,
1369}
1370
1371impl TryFrom<String> for TalkOverLevel {
1372 type Error = SettingError;
1373
1374 fn try_from(value: String) -> core::result::Result<TalkOverLevel, Self::Error> {
1375 match value.as_str() {
1376 "Minus24dB" => Ok(Self::Minus24dB),
1377 "Minus18dB" => Ok(Self::Minus18dB),
1378 "Minus12dB" => Ok(Self::Minus12dB),
1379 "Minus6dB" => Ok(Self::Minus6dB),
1380 _ => Err(SettingError::InvalidValue("TalkOverLevel".into(), value)),
1381 }
1382 }
1383}
1384
1385/// Found at "MIXER > DJ SETTING > MIDI CH" of the "My Settings" page in the Rekordbox
1386/// preferences.
1387#[binrw]
1388#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1389#[brw(repr = u8)]
1390pub enum MidiChannel {
1391 /// Named "1" in the Rekordbox preferences.
1392 #[default]
1393 #[display("1")]
1394 One = 0x80,
1395 /// Named "2" in the Rekordbox preferences.
1396 #[display("2")]
1397 Two,
1398 /// Named "3" in the Rekordbox preferences.
1399 #[display("3")]
1400 Three,
1401 /// Named "4" in the Rekordbox preferences.
1402 #[display("4")]
1403 Four,
1404 /// Named "5" in the Rekordbox preferences.
1405 #[display("5")]
1406 Five,
1407 /// Named "6" in the Rekordbox preferences.
1408 #[display("6")]
1409 Six,
1410 /// Named "7" in the Rekordbox preferences.
1411 #[display("7")]
1412 Seven,
1413 /// Named "8" in the Rekordbox preferences.
1414 #[display("8")]
1415 Eight,
1416 /// Named "9" in the Rekordbox preferences.
1417 #[display("9")]
1418 Nine,
1419 /// Named "10" in the Rekordbox preferences.
1420 #[display("10")]
1421 Ten,
1422 /// Named "11" in the Rekordbox preferences.
1423 #[display("11")]
1424 Eleven,
1425 /// Named "12" in the Rekordbox preferences.
1426 #[display("12")]
1427 Twelve,
1428 /// Named "13" in the Rekordbox preferences.
1429 #[display("13")]
1430 Thirteen,
1431 /// Named "14" in the Rekordbox preferences.
1432 #[display("14")]
1433 Fourteen,
1434 /// Named "15" in the Rekordbox preferences.
1435 #[display("15")]
1436 Fifteen,
1437 /// Named "16" in the Rekordbox preferences.
1438 #[display("16")]
1439 Sixteen,
1440}
1441
1442impl TryFrom<String> for MidiChannel {
1443 type Error = SettingError;
1444
1445 fn try_from(value: String) -> core::result::Result<MidiChannel, Self::Error> {
1446 match value.as_str() {
1447 "One" => Ok(Self::One),
1448 "Two" => Ok(Self::Two),
1449 "Three" => Ok(Self::Three),
1450 "Four" => Ok(Self::Four),
1451 "Five" => Ok(Self::Five),
1452 "Six" => Ok(Self::Six),
1453 "Seven" => Ok(Self::Seven),
1454 "Eight" => Ok(Self::Eight),
1455 "Nine" => Ok(Self::Nine),
1456 "Ten" => Ok(Self::Ten),
1457 "Eleven" => Ok(Self::Eleven),
1458 "Twelve" => Ok(Self::Twelve),
1459 "Thirteen" => Ok(Self::Thirteen),
1460 "Fourteen" => Ok(Self::Fourteen),
1461 "Fifteen" => Ok(Self::Fifteen),
1462 "Sixteen" => Ok(Self::Sixteen),
1463 _ => Err(SettingError::InvalidValue("MidiChannel".into(), value)),
1464 }
1465 }
1466}
1467
1468/// Found at "MIXER > DJ SETTING > MIDI BUTTON TYPE" of the "My Settings" page in the Rekordbox
1469/// preferences.
1470#[binrw]
1471#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1472#[brw(repr = u8)]
1473pub enum MidiButtonType {
1474 #[default]
1475 /// Named "TOGGLE" in the Rekordbox preferences.
1476 Toggle = 0x80,
1477 /// Named "TRIGGER" in the Rekordbox preferences.
1478 Trigger,
1479}
1480
1481impl TryFrom<String> for MidiButtonType {
1482 type Error = SettingError;
1483
1484 fn try_from(value: String) -> core::result::Result<MidiButtonType, Self::Error> {
1485 match value.as_str() {
1486 "Toggle" => Ok(Self::Toggle),
1487 "Trigger" => Ok(Self::Trigger),
1488 _ => Err(SettingError::InvalidValue("MidiButtonType".into(), value)),
1489 }
1490 }
1491}
1492
1493/// Found at "MIXER > BRIGHTNESS > DISPLAY" of the "My Settings" page in the Rekordbox
1494/// preferences.
1495#[binrw]
1496#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1497#[brw(repr = u8)]
1498pub enum MixerDisplayBrightness {
1499 /// Named "WHITE" in the Rekordbox preferences.
1500 White = 0x80,
1501 /// Named "1" in the Rekordbox preferences.
1502 #[display("1")]
1503 One,
1504 /// Named "2" in the Rekordbox preferences.
1505 #[display("2")]
1506 Two,
1507 /// Named "3" in the Rekordbox preferences.
1508 #[display("3")]
1509 Three,
1510 /// Named "4" in the Rekordbox preferences.
1511 #[display("4")]
1512 Four,
1513 /// Named "5" in the Rekordbox preferences.
1514 #[default]
1515 #[display("5")]
1516 Five,
1517}
1518
1519impl TryFrom<String> for MixerDisplayBrightness {
1520 type Error = SettingError;
1521
1522 fn try_from(value: String) -> core::result::Result<MixerDisplayBrightness, Self::Error> {
1523 match value.as_str() {
1524 "White" => Ok(Self::White),
1525 "One" => Ok(Self::One),
1526 "Two" => Ok(Self::Two),
1527 "Three" => Ok(Self::Three),
1528 "Four" => Ok(Self::Four),
1529 "Five" => Ok(Self::Five),
1530 _ => Err(SettingError::InvalidValue(
1531 "MixerDisplayBrightness".into(),
1532 value,
1533 )),
1534 }
1535 }
1536}
1537
1538/// Found at "MIXER > BRIGHTNESS > INDICATOR" of the "My Settings" page in the Rekordbox
1539/// preferences.
1540#[binrw]
1541#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1542#[brw(repr = u8)]
1543pub enum MixerIndicatorBrightness {
1544 /// Named "1" in the Rekordbox preferences.
1545 #[display("1")]
1546 One = 0x80,
1547 /// Named "2" in the Rekordbox preferences.
1548 #[display("2")]
1549 Two,
1550 /// Named "3" in the Rekordbox preferences.
1551 #[display("3")]
1552 #[default]
1553 Three,
1554}
1555
1556impl TryFrom<String> for MixerIndicatorBrightness {
1557 type Error = SettingError;
1558
1559 fn try_from(value: String) -> core::result::Result<MixerIndicatorBrightness, Self::Error> {
1560 match value.as_str() {
1561 "One" => Ok(Self::One),
1562 "Two" => Ok(Self::Two),
1563 "Three" => Ok(Self::Three),
1564 _ => Err(SettingError::InvalidValue(
1565 "MixerIndicatorBrightness".into(),
1566 value,
1567 )),
1568 }
1569 }
1570}
1571
1572/// Found at "MIXER > DJ SETTING > CH FADER CURVE (LONG FADER)" of the "My Settings" page in the
1573/// Rekordbox preferences.
1574#[binrw]
1575#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1576#[brw(repr = u8)]
1577pub enum ChannelFaderCurveLongFader {
1578 /// Very steep volume raise when the fader is moved the near the top (e.g. y = x⁵).
1579 #[default]
1580 Exponential = 0x80,
1581 /// Steep volume raise when the fader is moved the near the top (e.g. y = x²).
1582 Smooth,
1583 /// Linear volume raise when the fader is moved (e.g. y = k * x).
1584 Linear,
1585}
1586
1587impl TryFrom<String> for ChannelFaderCurveLongFader {
1588 type Error = SettingError;
1589
1590 fn try_from(value: String) -> core::result::Result<ChannelFaderCurveLongFader, Self::Error> {
1591 match value.as_str() {
1592 "Exponential" => Ok(Self::Exponential),
1593 "Smooth" => Ok(Self::Smooth),
1594 "Linear" => Ok(Self::Linear),
1595 _ => Err(SettingError::InvalidValue(
1596 "ChannelFaderCurveLongFader".into(),
1597 value,
1598 )),
1599 }
1600 }
1601}
1602
1603/// Payload of a `DJMMYSETTING.DAT` file (52 bytes).
1604#[binrw]
1605#[derive(Debug, PartialEq, Eq, Clone)]
1606#[brw(little)]
1607pub struct DJMMySetting {
1608 /// Unknown field.
1609 unknown1: [u8; 12],
1610 /// "CH FADER CURVE" setting.
1611 pub channel_fader_curve: ChannelFaderCurve,
1612 /// "CROSSFADER CURVE" setting.
1613 pub crossfader_curve: CrossfaderCurve,
1614 /// "HEADPHONES PRE EQ" setting.
1615 pub headphones_pre_eq: HeadphonesPreEQ,
1616 /// "HEADPHONES MONO SPLIT" setting.
1617 pub headphones_mono_split: HeadphonesMonoSplit,
1618 /// "BEAT FX QUANTIZE" setting.
1619 pub beat_fx_quantize: BeatFXQuantize,
1620 /// "MIC LOW CUT" setting.
1621 pub mic_low_cut: MicLowCut,
1622 /// "TALK OVER MODE" setting.
1623 pub talk_over_mode: TalkOverMode,
1624 /// "TALK OVER LEVEL" setting.
1625 pub talk_over_level: TalkOverLevel,
1626 /// "MIDI CH" setting.
1627 pub midi_channel: MidiChannel,
1628 /// "MIDI BUTTON TYPE" setting.
1629 pub midi_button_type: MidiButtonType,
1630 /// "BRIGHTNESS > DISPLAY" setting.
1631 pub display_brightness: MixerDisplayBrightness,
1632 /// "BRIGHTNESS > INDICATOR" setting.
1633 pub indicator_brightness: MixerIndicatorBrightness,
1634 /// "CH FADER CURVE (LONG FADER)" setting.
1635 pub channel_fader_curve_long_fader: ChannelFaderCurveLongFader,
1636 /// Unknown field (apparently always 0).
1637 #[br(assert(unknown2 == [0; 27]))]
1638 unknown2: [u8; 27],
1639}
1640
1641impl Default for DJMMySetting {
1642 fn default() -> Self {
1643 Self {
1644 unknown1: [
1645 0x78, 0x56, 0x34, 0x12, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1646 ],
1647 channel_fader_curve: ChannelFaderCurve::default(),
1648 crossfader_curve: CrossfaderCurve::default(),
1649 headphones_pre_eq: HeadphonesPreEQ::default(),
1650 headphones_mono_split: HeadphonesMonoSplit::default(),
1651 beat_fx_quantize: BeatFXQuantize::default(),
1652 mic_low_cut: MicLowCut::default(),
1653 talk_over_mode: TalkOverMode::default(),
1654 talk_over_level: TalkOverLevel::default(),
1655 midi_channel: MidiChannel::default(),
1656 midi_button_type: MidiButtonType::default(),
1657 display_brightness: MixerDisplayBrightness::default(),
1658 indicator_brightness: MixerIndicatorBrightness::default(),
1659 channel_fader_curve_long_fader: ChannelFaderCurveLongFader::default(),
1660 unknown2: [0; 27],
1661 }
1662 }
1663}
1664
1665impl DJMMySetting {
1666 fn file_name() -> String {
1667 "DJMMYSETTING.DAT".into()
1668 }
1669}
1670
1671// -- DevSetting -----------------------------------------------------------------------------------
1672
1673/// Type of the Overview Waveform displayed on the CDJ.
1674///
1675/// Found on the "General" page in the Rekordbox preferences.
1676#[binrw]
1677#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1678#[brw(repr = u8)]
1679pub enum OverviewWaveformType {
1680 /// Named "Half Waveform" in the Rekordbox preferences.
1681 #[default]
1682 #[display("Half Waveform")]
1683 HalfWaveform = 0x01,
1684 /// Named "Full Waveform" in the Rekordbox preferences.
1685 #[display("Full Waveform")]
1686 FullWaveform,
1687}
1688
1689impl TryFrom<String> for OverviewWaveformType {
1690 type Error = SettingError;
1691
1692 fn try_from(value: String) -> core::result::Result<OverviewWaveformType, Self::Error> {
1693 match value.as_str() {
1694 "HalfWaveform" => Ok(Self::HalfWaveform),
1695 "FullWaveform" => Ok(Self::FullWaveform),
1696 _ => Err(SettingError::InvalidValue(
1697 "OverviewWaveformType".into(),
1698 value,
1699 )),
1700 }
1701 }
1702}
1703
1704/// Waveform color displayed on the CDJ.
1705///
1706/// Found on the "General" page in the Rekordbox preferences.
1707#[binrw]
1708#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1709#[brw(repr = u8)]
1710pub enum WaveformColor {
1711 /// Named "BLUE" in the Rekordbox preferences.
1712 #[default]
1713 Blue = 0x01,
1714 /// Named "RGB" in the Rekordbox preferences.
1715 #[display("RGB")]
1716 Rgb = 0x03,
1717 /// Named "3Band" in the Rekordbox preferences.
1718 #[display("3Band")]
1719 TriBand = 0x04,
1720}
1721
1722impl TryFrom<String> for WaveformColor {
1723 type Error = SettingError;
1724
1725 fn try_from(value: String) -> core::result::Result<WaveformColor, Self::Error> {
1726 match value.as_str() {
1727 "Blue" => Ok(Self::Blue),
1728 "Rgb" => Ok(Self::Rgb),
1729 "TriBand" => Ok(Self::TriBand),
1730 _ => Err(SettingError::InvalidValue("WaveformColor".into(), value)),
1731 }
1732 }
1733}
1734
1735/// The key display format displayed on the CDJ.
1736///
1737/// Found on the "General" page in the Rekordbox preferences.
1738#[binrw]
1739#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1740#[brw(repr = u8)]
1741pub enum KeyDisplayFormat {
1742 /// Named "Classic" in the Rekordbox preferences.
1743 #[default]
1744 Classic = 0x01,
1745 /// Named "Alphanumeric" in the Rekordbox preferences.
1746 Alphanumeric,
1747}
1748
1749impl TryFrom<String> for KeyDisplayFormat {
1750 type Error = SettingError;
1751
1752 fn try_from(value: String) -> core::result::Result<KeyDisplayFormat, Self::Error> {
1753 match value.as_str() {
1754 "Classic" => Ok(Self::Classic),
1755 "Alphanumeric" => Ok(Self::Alphanumeric),
1756 _ => Err(SettingError::InvalidValue("KeyDisplayFormat".into(), value)),
1757 }
1758 }
1759}
1760
1761/// Waveform Current Position displayed on the CDJ.
1762///
1763/// Found on the "General" page in the Rekordbox preferences.
1764#[binrw]
1765#[derive(Display, Debug, PartialEq, Eq, Default, Clone, Copy)]
1766#[brw(repr = u8)]
1767pub enum WaveformCurrentPosition {
1768 /// Named "LEFT" in the Rekordbox preferences.
1769 Left = 0x02,
1770 /// Named "CENTER" in the Rekordbox preferences.
1771 #[default]
1772 Center = 0x01,
1773}
1774
1775impl TryFrom<String> for WaveformCurrentPosition {
1776 type Error = SettingError;
1777
1778 fn try_from(value: String) -> core::result::Result<WaveformCurrentPosition, Self::Error> {
1779 match value.as_str() {
1780 "Left" => Ok(Self::Left),
1781 "Center" => Ok(Self::Center),
1782 _ => Err(SettingError::InvalidValue(
1783 "WaveformCurrentPosition".into(),
1784 value,
1785 )),
1786 }
1787 }
1788}
1789
1790/// Payload of a `DEVSETTING.DAT` file (32 bytes).
1791#[binrw]
1792#[derive(Debug, PartialEq, Eq, Clone)]
1793#[brw(little)]
1794pub struct DevSetting {
1795 /// Unknown field.
1796 #[br(assert(unknown1 == [0x78, 0x56, 0x34, 0x12, 0x01, 0x00, 0x00, 0x00, 0x01]))]
1797 unknown1: [u8; 9],
1798 /// "Type of the overview Waveform" setting.
1799 pub overview_waveform_type: OverviewWaveformType,
1800 /// "Waveform color" setting.
1801 pub waveform_color: WaveformColor,
1802 /// Unknown field.
1803 #[br(assert(unknown2 == 0x01))]
1804 unknown2: u8,
1805 /// "Key display format" setting.
1806 pub key_display_format: KeyDisplayFormat,
1807 /// "Waveform Current Position" setting.
1808 pub waveform_current_position: WaveformCurrentPosition,
1809 /// Unknown field.
1810 #[br(assert(unknown3 == [0x00; 18]))]
1811 unknown3: [u8; 18],
1812}
1813
1814impl Default for DevSetting {
1815 fn default() -> Self {
1816 Self {
1817 unknown1: [0x78, 0x56, 0x34, 0x12, 0x01, 0x00, 0x00, 0x00, 0x01],
1818 overview_waveform_type: OverviewWaveformType::default(),
1819 waveform_color: WaveformColor::default(),
1820 key_display_format: KeyDisplayFormat::default(),
1821 unknown2: 0x01,
1822 waveform_current_position: WaveformCurrentPosition::default(),
1823 unknown3: [0x00; 18],
1824 }
1825 }
1826}
1827
1828impl DevSetting {
1829 fn file_name() -> String {
1830 "DEVSETTING.DAT".into()
1831 }
1832}
1833
1834// -- Setting file data ----------------------------------------------------------------------------
1835
1836/// Data section of a `*SETTING.DAT` file.
1837#[binrw]
1838#[derive(Debug, PartialEq, Eq, Clone)]
1839#[brw(little)]
1840#[br(import(len: u32))]
1841pub enum SettingContent {
1842 /// Payload of a `MYSETTING.DAT` file (40 bytes).
1843 #[br(pre_assert(len == 40))]
1844 MySetting(MySetting),
1845 // /// Payload of a `MYSETTING2.DAT` file (40 bytes).
1846 #[br(pre_assert(len == 40))]
1847 MySetting2(MySetting2),
1848 /// Payload of a `DJMMYSETTING.DAT` file (52 bytes).
1849 #[br(pre_assert(len == 52))]
1850 DJMMySetting(DJMMySetting),
1851 /// Payload of a `DEVSETTING.DAT` file (32 bytes).
1852 #[br(pre_assert(len == 32))]
1853 DevSetting(DevSetting),
1854}
1855
1856impl SettingContent {
1857 fn size(&self) -> u32 {
1858 match &self {
1859 Self::MySetting(_) => 40,
1860 Self::MySetting2(_) => 40,
1861 Self::DJMMySetting(_) => 52,
1862 Self::DevSetting(_) => 32,
1863 }
1864 }
1865}
1866
1867#[binrw]
1868#[derive(Debug, PartialEq, Eq, Clone)]
1869#[brw(little)]
1870#[bw(import(no_checksum: bool))]
1871/// Represents the data of a Setting file.
1872pub struct SettingData {
1873 /// Size of the string data field (should be always 96).
1874 #[br(temp, assert(len_stringdata == 0x60))]
1875 #[bw(calc = 0x60)]
1876 len_stringdata: u32,
1877 /// Name of the brand (depends on the kind of file).
1878 #[brw(pad_size_to = 0x20, assert(brand.len() <= (0x20 - 1)))]
1879 pub brand: NullString,
1880 /// Name of the software ("rekordbox").
1881 #[brw(pad_size_to = 0x20, assert(software.len() <= (0x20 - 1)))]
1882 pub software: NullString,
1883 /// Some kind of version number.
1884 #[brw(pad_size_to = 0x20, assert(version.len() <= (0x20 - 1)))]
1885 pub version: NullString,
1886 /// Size of the `data` data in bytes.
1887 #[br(temp)]
1888 #[bw(calc = content.size())]
1889 len_data: u32,
1890 /// The actual settings data.
1891 #[br(args(len_data))]
1892 pub content: SettingContent,
1893 /// CRC16 XMODEM checksum. The checksum is calculated over the contents of the `data`
1894 /// field, except for `DJMSETTING.DAT` files where the checksum is calculated over all
1895 /// preceding bytes including the length fields.
1896 ///
1897 /// See <https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-xmodem> for details.
1898 #[br(temp)]
1899 #[bw(calc = no_checksum.then_some(0).unwrap_or_else(|| self.calculate_checksum()))]
1900 _checksum: u16,
1901 /// Unknown field (apparently always `0000`).
1902 #[br(temp)]
1903 #[br(assert(unknown == 0))]
1904 #[bw(calc = 0u16)]
1905 unknown: u16,
1906}
1907
1908impl SettingData
1909where
1910 SettingData: BinWrite,
1911{
1912 /// Calculate the CRC16 checksum.
1913 ///
1914 /// This is horribly inefficient and basically serializes the whole data structure twice, but
1915 /// there seems to be no other way to achieve this.
1916 ///
1917 /// See https://github.com/jam1garner/binrw/issues/102
1918 fn calculate_checksum(&self) -> u16 {
1919 let mut data = Vec::<u8>::with_capacity(156);
1920 let mut writer = Cursor::new(&mut data);
1921 self.write_options(&mut writer, Endian::Little, (true,))
1922 .unwrap();
1923 let start = match self.content {
1924 // In `DJMMYSETTING.DAT`, the checksum is calculated over all previous bytes, including
1925 // the section lengths and string data.
1926 SettingContent::DJMMySetting(_) => 0,
1927 // In all other files`, the checksum is calculated just over the data section which
1928 // starts at offset 104,
1929 _ => 104,
1930 };
1931
1932 let end = data.len() - 4;
1933 crc16::State::<crc16::XMODEM>::calculate(&data[start..end])
1934 }
1935}
1936
1937impl SettingData {
1938 /// Create a new object containing with the given brand string and data.
1939 #[must_use]
1940 fn default_with_brand_and_data(brand: NullString, content: SettingContent) -> Self {
1941 Self {
1942 brand,
1943 software: "rekordbox".into(),
1944 version: "6.6.1".into(),
1945 content,
1946 }
1947 }
1948
1949 /// Create a new object containing the default values of a `MYSETTING.DAT` file.
1950 #[must_use]
1951 pub fn default_mysetting() -> Self {
1952 Self::default_with_brand_and_data(
1953 "PIONEER".into(),
1954 SettingContent::MySetting(MySetting::default()),
1955 )
1956 }
1957
1958 /// Create a new object containing the default values of a `MYSETTING2.DAT` file.
1959 #[must_use]
1960 pub fn default_mysetting2() -> Self {
1961 Self::default_with_brand_and_data(
1962 "PIONEER".into(),
1963 SettingContent::MySetting2(MySetting2::default()),
1964 )
1965 }
1966
1967 /// Create a new object containing the default values of a `DJMMYSETTING.DAT` file.
1968 #[must_use]
1969 pub fn default_djmmysetting() -> Self {
1970 Self::default_with_brand_and_data(
1971 "PioneerDJ".into(),
1972 SettingContent::DJMMySetting(DJMMySetting::default()),
1973 )
1974 }
1975
1976 /// Create a new object containing the default values of a `DEVSETTING.DAT` file.
1977 #[must_use]
1978 pub fn default_devsetting() -> Self {
1979 Self::default_with_brand_and_data(
1980 "PIONEER DJ".into(),
1981 SettingContent::DevSetting(DevSetting::default()),
1982 )
1983 }
1984
1985 fn file_name(&self) -> &str {
1986 match &self.content {
1987 SettingContent::MySetting(_) => "MYSETTING.DAT",
1988 SettingContent::MySetting2(_) => "MYSETTING2.DAT",
1989 SettingContent::DJMMySetting(_) => "DJMMYSETTING.DAT",
1990 SettingContent::DevSetting(_) => "DEVSETTING.DAT",
1991 }
1992 }
1993}
1994
1995// -- Setting file handler -------------------------------------------------------------------------
1996
1997/// Rekordbox `*SETTING.DAT` file handler.
1998pub struct Setting {
1999 /// Setting file path.
2000 path: std::path::PathBuf,
2001 /// Setting file data.
2002 pub data: SettingData,
2003}
2004
2005impl Setting {
2006 /// Create a new generic `Setting` object with the given path and data.
2007 pub fn new<P: AsRef<std::path::Path>>(path: P, data: SettingData) -> Self {
2008 Self {
2009 path: path.as_ref().to_path_buf(),
2010 data,
2011 }
2012 }
2013
2014 /// Create a new `MYSETTING.DAT` file filled with the default values.
2015 pub fn new_mysetting<P: AsRef<std::path::Path>>(path: P) -> Result<Self> {
2016 let file_name = path.as_ref().file_name().unwrap().to_str().unwrap();
2017 if file_name != &MySetting::file_name() {
2018 return Err(SettingError::InvalidFile(MySetting::file_name()));
2019 }
2020 let data = SettingData::default_mysetting();
2021 Ok(Self::new(path, data))
2022 }
2023
2024 /// Create a new `MYSETTING2.DAT` file filled with the default values.
2025 pub fn new_mysetting2<P: AsRef<std::path::Path>>(path: P) -> Result<Self> {
2026 let file_name = path.as_ref().file_name().unwrap().to_str().unwrap();
2027 if file_name != &MySetting2::file_name() {
2028 return Err(SettingError::InvalidFile(MySetting2::file_name()));
2029 }
2030 let data = SettingData::default_mysetting2();
2031 Ok(Self::new(path, data))
2032 }
2033
2034 /// Create a new `DJMMYSETTING.DAT` file filled with the default values.
2035 pub fn new_djmmysetting<P: AsRef<std::path::Path>>(path: P) -> Result<Self> {
2036 let file_name = path.as_ref().file_name().unwrap().to_str().unwrap();
2037 if file_name != &DJMMySetting::file_name() {
2038 return Err(SettingError::InvalidFile(DJMMySetting::file_name()));
2039 }
2040 let data = SettingData::default_djmmysetting();
2041 Ok(Self::new(path, data))
2042 }
2043
2044 /// Create a new `DEVSETTING.DAT` file filled with the default values.
2045 pub fn new_devsetting<P: AsRef<std::path::Path>>(path: P) -> Result<Self> {
2046 let file_name = path.as_ref().file_name().unwrap().to_str().unwrap();
2047 if file_name != &DevSetting::file_name() {
2048 return Err(SettingError::InvalidFile(DevSetting::file_name()));
2049 }
2050 let data = SettingData::default_devsetting();
2051 Ok(Self::new(path, data))
2052 }
2053
2054 /// Read a Rekordbox Setting file.
2055 pub fn load<P: AsRef<std::path::Path>>(path: P) -> Result<Self> {
2056 let mut file = std::fs::File::open(&path)?;
2057 let data = SettingData::read(&mut file)?;
2058 Ok(Self::new(path, data))
2059 }
2060
2061 /// Write the Setting file.
2062 pub fn dump_copy<P: AsRef<std::path::Path>>(&mut self, path: P) -> Result<()> {
2063 let file_name = path.as_ref().file_name().unwrap().to_str().unwrap();
2064 if file_name != self.data.file_name() {
2065 return Err(SettingError::InvalidFile(self.data.file_name().into()));
2066 }
2067 let mut file = std::fs::File::create(path)?;
2068 self.data.write(&mut file)?;
2069 Ok(())
2070 }
2071
2072 /// Write the Setting file to the original file.
2073 pub fn dump(&mut self) -> Result<()> {
2074 let path = &self.path.clone();
2075 self.dump_copy(path)?;
2076 Ok(())
2077 }
2078
2079 // -- MySetting getters and setters ------------------------------------------------------------
2080
2081 /// Gets the value of the "ON AIR DISPLAY" setting.
2082 ///
2083 /// # Returns
2084 /// - `Ok(OnAirDisplay)` if the `SettingContent` is of type `MySetting`.
2085 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2086 ///
2087 /// # Errors
2088 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2089 pub fn get_on_air_display(&self) -> Result<OnAirDisplay> {
2090 if let SettingContent::MySetting(content) = &self.data.content {
2091 Ok(content.on_air_display)
2092 } else {
2093 Err(SettingError::InvalidFile(MySetting::file_name()))
2094 }
2095 }
2096
2097 /// Sets the value of the "ON AIR DISPLAY" setting.
2098 ///
2099 /// # Parameters
2100 /// - `on_air_display`: The new value of the `OnAirDisplay` setting to be set.
2101 ///
2102 /// # Returns
2103 /// - `Ok(())` if the value is successfully set.
2104 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2105 ///
2106 /// # Errors
2107 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2108 pub fn set_on_air_display(&mut self, on_air_display: OnAirDisplay) -> Result<()> {
2109 if let SettingContent::MySetting(content) = &mut self.data.content {
2110 content.on_air_display = on_air_display;
2111 Ok(())
2112 } else {
2113 Err(SettingError::InvalidFile(MySetting::file_name()))
2114 }
2115 }
2116
2117 /// Gets the value of the "LCD BRIGHTNESS" setting.
2118 ///
2119 /// # Returns
2120 /// - `Ok(LCDBrightness)` if the `SettingContent` is of type `MySetting`.
2121 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2122 ///
2123 /// # Errors
2124 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2125 pub fn get_lcd_brightness(&self) -> Result<LCDBrightness> {
2126 if let SettingContent::MySetting(content) = &self.data.content {
2127 Ok(content.lcd_brightness)
2128 } else {
2129 Err(SettingError::InvalidFile(MySetting::file_name()))
2130 }
2131 }
2132
2133 /// Sets the value of the "LCD BRIGHTNESS" setting.
2134 ///
2135 /// # Parameters
2136 /// - `lcd_brightness`: The new value of the `LCDBrightness` setting to be set.
2137 ///
2138 /// # Returns
2139 /// - `Ok(())` if the value is successfully set.
2140 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2141 ///
2142 /// # Errors
2143 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2144 pub fn set_lcd_brightness(&mut self, lcd_brightness: LCDBrightness) -> Result<()> {
2145 if let SettingContent::MySetting(content) = &mut self.data.content {
2146 content.lcd_brightness = lcd_brightness;
2147 Ok(())
2148 } else {
2149 Err(SettingError::InvalidFile(MySetting::file_name()))
2150 }
2151 }
2152
2153 /// Gets the value of the "QUANTIZE" setting.
2154 ///
2155 /// # Returns
2156 /// - `Ok(Quantize)` if the `SettingContent` is of type `MySetting`.
2157 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2158 ///
2159 /// # Errors
2160 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2161 pub fn get_quantize(&self) -> Result<Quantize> {
2162 if let SettingContent::MySetting(content) = &self.data.content {
2163 Ok(content.quantize)
2164 } else {
2165 Err(SettingError::InvalidFile(MySetting::file_name()))
2166 }
2167 }
2168
2169 /// Sets the value of the "QUANTIZE" setting.
2170 ///
2171 /// # Parameters
2172 /// - `quantize`: The new value of the `Quantize` setting to be set.
2173 ///
2174 /// # Returns
2175 /// - `Ok(())` if the value is successfully set.
2176 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2177 ///
2178 /// # Errors
2179 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2180 pub fn set_quantize(&mut self, quantize: Quantize) -> Result<()> {
2181 if let SettingContent::MySetting(content) = &mut self.data.content {
2182 content.quantize = quantize;
2183 Ok(())
2184 } else {
2185 Err(SettingError::InvalidFile(MySetting::file_name()))
2186 }
2187 }
2188
2189 /// Gets the value of the "AUTO CUE LEVEL" setting.
2190 ///
2191 /// # Returns
2192 /// - `Ok(AutoCueLevel)` if the `SettingContent` is of type `MySetting`.
2193 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2194 ///
2195 /// # Errors
2196 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2197 pub fn get_auto_cue_level(&self) -> Result<AutoCueLevel> {
2198 if let SettingContent::MySetting(content) = &self.data.content {
2199 Ok(content.auto_cue_level)
2200 } else {
2201 Err(SettingError::InvalidFile(MySetting::file_name()))
2202 }
2203 }
2204
2205 /// Sets the value of the "AUTO CUE LEVEL" setting.
2206 ///
2207 /// # Parameters
2208 /// - `auto_cue_level`: The new value of the `AutoCueLevel` setting to be set.
2209 ///
2210 /// # Returns
2211 /// - `Ok(())` if the value is successfully set.
2212 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2213 ///
2214 /// # Errors
2215 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2216 pub fn set_auto_cue_level(&mut self, auto_cue_level: AutoCueLevel) -> Result<()> {
2217 if let SettingContent::MySetting(content) = &mut self.data.content {
2218 content.auto_cue_level = auto_cue_level;
2219 Ok(())
2220 } else {
2221 Err(SettingError::InvalidFile(MySetting::file_name()))
2222 }
2223 }
2224
2225 /// Gets the value of the "LANGUAGE" setting.
2226 ///
2227 /// # Returns
2228 /// - `Ok(Language)` if the `SettingContent` is of type `MySetting`.
2229 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2230 ///
2231 /// # Errors
2232 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2233 pub fn get_language(&self) -> Result<Language> {
2234 if let SettingContent::MySetting(content) = &self.data.content {
2235 Ok(content.language)
2236 } else {
2237 Err(SettingError::InvalidFile(MySetting::file_name()))
2238 }
2239 }
2240
2241 /// Sets the value of the "LANGUAGE" setting.
2242 ///
2243 /// # Parameters
2244 /// - `language`: The new value of the `Language` setting to be set.
2245 ///
2246 /// # Returns
2247 /// - `Ok(())` if the value is successfully set.
2248 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2249 ///
2250 /// # Errors
2251 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2252 pub fn set_language(&mut self, language: Language) -> Result<()> {
2253 if let SettingContent::MySetting(content) = &mut self.data.content {
2254 content.language = language;
2255 Ok(())
2256 } else {
2257 Err(SettingError::InvalidFile(MySetting::file_name()))
2258 }
2259 }
2260
2261 /// Gets the value of the "JOG RING BRIGHTNESS" setting.
2262 ///
2263 /// # Returns
2264 /// - `Ok(JogRingBrightness)` if the `SettingContent` is of type `MySetting`.
2265 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2266 ///
2267 /// # Errors
2268 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2269 pub fn get_jog_ring_brightness(&self) -> Result<JogRingBrightness> {
2270 if let SettingContent::MySetting(content) = &self.data.content {
2271 Ok(content.jog_ring_brightness)
2272 } else {
2273 Err(SettingError::InvalidFile(MySetting::file_name()))
2274 }
2275 }
2276
2277 /// Sets the value of the "JOG RING BRIGHTNESS" setting.
2278 ///
2279 /// # Parameters
2280 /// - `jog_ring_brightness`: The new value of the `JogRingBrightness` setting to be set.
2281 ///
2282 /// # Returns
2283 /// - `Ok(())` if the value is successfully set.
2284 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2285 ///
2286 /// # Errors
2287 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2288 pub fn set_jog_ring_brightness(
2289 &mut self,
2290 jog_ring_brightness: JogRingBrightness,
2291 ) -> Result<()> {
2292 if let SettingContent::MySetting(content) = &mut self.data.content {
2293 content.jog_ring_brightness = jog_ring_brightness;
2294 Ok(())
2295 } else {
2296 Err(SettingError::InvalidFile(MySetting::file_name()))
2297 }
2298 }
2299
2300 /// Gets the value of the "JOG RING INDICATOR" setting.
2301 ///
2302 /// # Returns
2303 /// - `Ok(JogRingIndicator)` if the `SettingContent` is of type `MySetting`.
2304 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2305 ///
2306 /// # Errors
2307 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2308 pub fn get_jog_ring_indicator(&self) -> Result<JogRingIndicator> {
2309 if let SettingContent::MySetting(content) = &self.data.content {
2310 Ok(content.jog_ring_indicator)
2311 } else {
2312 Err(SettingError::InvalidFile(MySetting::file_name()))
2313 }
2314 }
2315
2316 /// Sets the value of the "JOG RING INDICATOR" setting.
2317 ///
2318 /// # Parameters
2319 /// - `jog_ring_indicator`: The new value of the `JogRingIndicator` setting to be set.
2320 ///
2321 /// # Returns
2322 /// - `Ok(())` if the value is successfully set.
2323 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2324 ///
2325 /// # Errors
2326 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2327 pub fn set_jog_ring_indicator(&mut self, jog_ring_indicator: JogRingIndicator) -> Result<()> {
2328 if let SettingContent::MySetting(content) = &mut self.data.content {
2329 content.jog_ring_indicator = jog_ring_indicator;
2330 Ok(())
2331 } else {
2332 Err(SettingError::InvalidFile(MySetting::file_name()))
2333 }
2334 }
2335 /// Gets the value of the "SLIP FLASHING" setting.
2336 ///
2337 /// # Returns
2338 /// - `Ok(SlipFlashing)` if the `SettingContent` is of type `MySetting`.
2339 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2340 ///
2341 /// # Errors
2342 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2343 pub fn get_slip_flashing(&self) -> Result<SlipFlashing> {
2344 if let SettingContent::MySetting(content) = &self.data.content {
2345 Ok(content.slip_flashing)
2346 } else {
2347 Err(SettingError::InvalidFile(MySetting::file_name()))
2348 }
2349 }
2350
2351 /// Sets the value of the "SLIP FLASHING" setting.
2352 ///
2353 /// # Parameters
2354 /// - `slip_flashing`: The new value of the `SlipFlashing` setting to be set.
2355 ///
2356 /// # Returns
2357 /// - `Ok(())` if the value is successfully set.
2358 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2359 ///
2360 /// # Errors
2361 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2362 pub fn set_slip_flashing(&mut self, slip_flashing: SlipFlashing) -> Result<()> {
2363 if let SettingContent::MySetting(content) = &mut self.data.content {
2364 content.slip_flashing = slip_flashing;
2365 Ok(())
2366 } else {
2367 Err(SettingError::InvalidFile(MySetting::file_name()))
2368 }
2369 }
2370
2371 /// Gets the value of the "DISC SLOT ILLUMINATION" setting.
2372 ///
2373 /// # Returns
2374 /// - `Ok(DiscSlotIllumination)` if the `SettingContent` is of type `MySetting`.
2375 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2376 ///
2377 /// # Errors
2378 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2379 pub fn get_disc_slot_illumination(&self) -> Result<DiscSlotIllumination> {
2380 if let SettingContent::MySetting(content) = &self.data.content {
2381 Ok(content.disc_slot_illumination)
2382 } else {
2383 Err(SettingError::InvalidFile(MySetting::file_name()))
2384 }
2385 }
2386
2387 /// Sets the value of the "DISC SLOT ILLUMINATION" setting.
2388 ///
2389 /// # Parameters
2390 /// - `disc_slot_illumination`: The new value of the `DiscSlotIllumination` setting to be set.
2391 ///
2392 /// # Returns
2393 /// - `Ok(())` if the value is successfully set.
2394 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2395 ///
2396 /// # Errors
2397 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2398 pub fn set_disc_slot_illumination(
2399 &mut self,
2400 disc_slot_illumination: DiscSlotIllumination,
2401 ) -> Result<()> {
2402 if let SettingContent::MySetting(content) = &mut self.data.content {
2403 content.disc_slot_illumination = disc_slot_illumination;
2404 Ok(())
2405 } else {
2406 Err(SettingError::InvalidFile(MySetting::file_name()))
2407 }
2408 }
2409
2410 /// Gets the value of the "EJECT/LOAD LOCK" setting.
2411 ///
2412 /// # Returns
2413 /// - `Ok(EjectLock)` if the `SettingContent` is of type `MySetting`.
2414 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2415 ///
2416 /// # Errors
2417 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2418 pub fn get_eject_lock(&self) -> Result<EjectLock> {
2419 if let SettingContent::MySetting(content) = &self.data.content {
2420 Ok(content.eject_lock)
2421 } else {
2422 Err(SettingError::InvalidFile(MySetting::file_name()))
2423 }
2424 }
2425
2426 /// Sets the value of the "EJECT/LOAD LOCK" setting.
2427 ///
2428 /// # Parameters
2429 /// - `eject_lock`: The new value of the `EjectLock` setting to be set.
2430 ///
2431 /// # Returns
2432 /// - `Ok(())` if the value is successfully set.
2433 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2434 ///
2435 /// # Errors
2436 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2437 pub fn set_eject_lock(&mut self, eject_lock: EjectLock) -> Result<()> {
2438 if let SettingContent::MySetting(content) = &mut self.data.content {
2439 content.eject_lock = eject_lock;
2440 Ok(())
2441 } else {
2442 Err(SettingError::InvalidFile(MySetting::file_name()))
2443 }
2444 }
2445
2446 /// Gets the value of the "SYNC" setting.
2447 ///
2448 /// # Returns
2449 /// - `Ok(Sync)` if the `SettingContent` is of type `MySetting`.
2450 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2451 ///
2452 /// # Errors
2453 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2454 pub fn get_sync(&self) -> Result<Sync> {
2455 if let SettingContent::MySetting(content) = &self.data.content {
2456 Ok(content.sync)
2457 } else {
2458 Err(SettingError::InvalidFile(MySetting::file_name()))
2459 }
2460 }
2461
2462 /// Sets the value of the "SYNC" setting.
2463 ///
2464 /// # Parameters
2465 /// - `sync`: The new value of the `Sync` setting to be set.
2466 ///
2467 /// # Returns
2468 /// - `Ok(())` if the value is successfully set.
2469 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2470 ///
2471 /// # Errors
2472 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2473 pub fn set_sync(&mut self, sync: Sync) -> Result<()> {
2474 if let SettingContent::MySetting(content) = &mut self.data.content {
2475 content.sync = sync;
2476 Ok(())
2477 } else {
2478 Err(SettingError::InvalidFile(MySetting::file_name()))
2479 }
2480 }
2481 /// Gets the value of the "PLAY MODE" setting.
2482 ///
2483 /// # Returns
2484 /// - `Ok(PlayMode)` if the `SettingContent` is of type `MySetting`.
2485 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2486 ///
2487 /// # Errors
2488 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2489 pub fn get_play_mode(&self) -> Result<PlayMode> {
2490 if let SettingContent::MySetting(content) = &self.data.content {
2491 Ok(content.play_mode)
2492 } else {
2493 Err(SettingError::InvalidFile(MySetting::file_name()))
2494 }
2495 }
2496
2497 /// Sets the value of the "PLAY MODE" setting.
2498 ///
2499 /// # Parameters
2500 /// - `play_mode`: The new value of the `PlayMode` setting to be set.
2501 ///
2502 /// # Returns
2503 /// - `Ok(())` if the value is successfully set.
2504 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2505 ///
2506 /// # Errors
2507 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2508 pub fn set_play_mode(&mut self, play_mode: PlayMode) -> Result<()> {
2509 if let SettingContent::MySetting(content) = &mut self.data.content {
2510 content.play_mode = play_mode;
2511 Ok(())
2512 } else {
2513 Err(SettingError::InvalidFile(MySetting::file_name()))
2514 }
2515 }
2516
2517 /// Gets the value of the "QUANTIZE BEAT VALUE" setting.
2518 ///
2519 /// # Returns
2520 /// - `Ok(QuantizeBeatValue)` if the `SettingContent` is of type `MySetting`.
2521 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2522 ///
2523 /// # Errors
2524 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2525 pub fn get_quantize_beat_value(&self) -> Result<QuantizeBeatValue> {
2526 if let SettingContent::MySetting(content) = &self.data.content {
2527 Ok(content.quantize_beat_value)
2528 } else {
2529 Err(SettingError::InvalidFile(MySetting::file_name()))
2530 }
2531 }
2532
2533 /// Sets the value of the "QUANTIZE BEAT VALUE" setting.
2534 ///
2535 /// # Parameters
2536 /// - `quantize_beat_value`: The new value of the `QuantizeBeatValue` setting to be set.
2537 ///
2538 /// # Returns
2539 /// - `Ok(())` if the value is successfully set.
2540 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2541 ///
2542 /// # Errors
2543 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2544 pub fn set_quantize_beat_value(
2545 &mut self,
2546 quantize_beat_value: QuantizeBeatValue,
2547 ) -> Result<()> {
2548 if let SettingContent::MySetting(content) = &mut self.data.content {
2549 content.quantize_beat_value = quantize_beat_value;
2550 Ok(())
2551 } else {
2552 Err(SettingError::InvalidFile(MySetting::file_name()))
2553 }
2554 }
2555
2556 /// Gets the value of the "HOT CUE AUTO LOAD" setting.
2557 ///
2558 /// # Returns
2559 /// - `Ok(HotCueAutoLoad)` if the `SettingContent` is of type `MySetting`.
2560 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2561 ///
2562 /// # Errors
2563 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2564 pub fn get_hotcue_autoload(&self) -> Result<HotCueAutoLoad> {
2565 if let SettingContent::MySetting(content) = &self.data.content {
2566 Ok(content.hotcue_autoload)
2567 } else {
2568 Err(SettingError::InvalidFile(MySetting::file_name()))
2569 }
2570 }
2571
2572 /// Sets the value of the "HOT CUE AUTO LOAD" setting.
2573 ///
2574 /// # Parameters
2575 /// - `hot_cue_autoload`: The new value of the `HotCueAutoLoad` setting to be set.
2576 ///
2577 /// # Returns
2578 /// - `Ok(())` if the value is successfully set.
2579 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2580 ///
2581 /// # Errors
2582 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2583 pub fn set_hotcue_autoload(&mut self, hotcue_autoload: HotCueAutoLoad) -> Result<()> {
2584 if let SettingContent::MySetting(content) = &mut self.data.content {
2585 content.hotcue_autoload = hotcue_autoload;
2586 Ok(())
2587 } else {
2588 Err(SettingError::InvalidFile(MySetting::file_name()))
2589 }
2590 }
2591
2592 /// Gets the value of the "HOT CUE COLOR" setting.
2593 ///
2594 /// # Returns
2595 /// - `Ok(HotCueColor)` if the `SettingContent` is of type `MySetting`.
2596 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2597 ///
2598 /// # Errors
2599 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2600 pub fn get_hotcue_color(&self) -> Result<HotCueColor> {
2601 if let SettingContent::MySetting(content) = &self.data.content {
2602 Ok(content.hotcue_color)
2603 } else {
2604 Err(SettingError::InvalidFile(MySetting::file_name()))
2605 }
2606 }
2607
2608 /// Sets the value of the "HOT CUE COLOR" setting.
2609 ///
2610 /// # Parameters
2611 /// - `hot_cue_color`: The new value of the `HotCueColor` setting to be set.
2612 ///
2613 /// # Returns
2614 /// - `Ok(())` if the value is successfully set.
2615 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2616 ///
2617 /// # Errors
2618 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2619 pub fn set_hotcue_color(&mut self, hotcue_color: HotCueColor) -> Result<()> {
2620 if let SettingContent::MySetting(content) = &mut self.data.content {
2621 content.hotcue_color = hotcue_color;
2622 Ok(())
2623 } else {
2624 Err(SettingError::InvalidFile(MySetting::file_name()))
2625 }
2626 }
2627
2628 /// Gets the value of the "NEEDLE LOCK" setting.
2629 ///
2630 /// # Returns
2631 /// - `Ok(NeedleLock)` if the `SettingContent` is of type `MySetting`.
2632 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2633 ///
2634 /// # Errors
2635 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2636 pub fn get_needle_lock(&self) -> Result<NeedleLock> {
2637 if let SettingContent::MySetting(content) = &self.data.content {
2638 Ok(content.needle_lock)
2639 } else {
2640 Err(SettingError::InvalidFile(MySetting::file_name()))
2641 }
2642 }
2643
2644 /// Sets the value of the "NEEDLE LOCK" setting.
2645 ///
2646 /// # Parameters
2647 /// - `needle_lock`: The new value of the `NeedleLock` setting to be set.
2648 ///
2649 /// # Returns
2650 /// - `Ok(())` if the value is successfully set.
2651 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2652 ///
2653 /// # Errors
2654 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2655 pub fn set_needle_lock(&mut self, needle_lock: NeedleLock) -> Result<()> {
2656 if let SettingContent::MySetting(content) = &mut self.data.content {
2657 content.needle_lock = needle_lock;
2658 Ok(())
2659 } else {
2660 Err(SettingError::InvalidFile(MySetting::file_name()))
2661 }
2662 }
2663
2664 /// Gets the value of the "TIME MODE" setting.
2665 ///
2666 /// # Returns
2667 /// - `Ok(TimeMode)` if the `SettingContent` is of type `MySetting`.
2668 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2669 ///
2670 /// # Errors
2671 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2672 pub fn get_time_mode(&self) -> Result<TimeMode> {
2673 if let SettingContent::MySetting(content) = &self.data.content {
2674 Ok(content.time_mode)
2675 } else {
2676 Err(SettingError::InvalidFile(MySetting::file_name()))
2677 }
2678 }
2679
2680 /// Sets the value of the "TIME MODE" setting.
2681 ///
2682 /// # Parameters
2683 /// - `time_mode`: The new value of the `TimeMode` setting to be set.
2684 ///
2685 /// # Returns
2686 /// - `Ok(())` if the value is successfully set.
2687 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2688 ///
2689 /// # Errors
2690 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2691 pub fn set_time_mode(&mut self, time_mode: TimeMode) -> Result<()> {
2692 if let SettingContent::MySetting(content) = &mut self.data.content {
2693 content.time_mode = time_mode;
2694 Ok(())
2695 } else {
2696 Err(SettingError::InvalidFile(MySetting::file_name()))
2697 }
2698 }
2699
2700 /// Gets the value of the "JOG MODE" setting.
2701 ///
2702 /// # Returns
2703 /// - `Ok(JogMode)` if the `SettingContent` is of type `MySetting`.
2704 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2705 ///
2706 /// # Errors
2707 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2708 pub fn get_jog_mode(&self) -> Result<JogMode> {
2709 if let SettingContent::MySetting(content) = &self.data.content {
2710 Ok(content.jog_mode)
2711 } else {
2712 Err(SettingError::InvalidFile(MySetting::file_name()))
2713 }
2714 }
2715
2716 /// Sets the value of the "JOG MODE" setting.
2717 ///
2718 /// # Parameters
2719 /// - `jog_mode`: The new value of the `JogMode` setting to be set.
2720 ///
2721 /// # Returns
2722 /// - `Ok(())` if the value is successfully set.
2723 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2724 ///
2725 /// # Errors
2726 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2727 pub fn set_jog_mode(&mut self, jog_mode: JogMode) -> Result<()> {
2728 if let SettingContent::MySetting(content) = &mut self.data.content {
2729 content.jog_mode = jog_mode;
2730 Ok(())
2731 } else {
2732 Err(SettingError::InvalidFile(MySetting::file_name()))
2733 }
2734 }
2735
2736 /// Gets the value of the "AUTO CUE" setting.
2737 ///
2738 /// # Returns
2739 /// - `Ok(AutoCue)` if the `SettingContent` is of type `MySetting`.
2740 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2741 ///
2742 /// # Errors
2743 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2744 pub fn get_auto_cue(&self) -> Result<AutoCue> {
2745 if let SettingContent::MySetting(content) = &self.data.content {
2746 Ok(content.auto_cue)
2747 } else {
2748 Err(SettingError::InvalidFile(MySetting::file_name()))
2749 }
2750 }
2751
2752 /// Sets the value of the "AUTO CUE" setting.
2753 ///
2754 /// # Parameters
2755 /// - `auto_cue`: The new value of the `AutoCue` setting to be set.
2756 ///
2757 /// # Returns
2758 /// - `Ok(())` if the value is successfully set.
2759 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2760 ///
2761 /// # Errors
2762 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2763 pub fn set_auto_cue(&mut self, auto_cue: AutoCue) -> Result<()> {
2764 if let SettingContent::MySetting(content) = &mut self.data.content {
2765 content.auto_cue = auto_cue;
2766 Ok(())
2767 } else {
2768 Err(SettingError::InvalidFile(MySetting::file_name()))
2769 }
2770 }
2771
2772 /// Gets the value of the "MASTER TEMPO" setting.
2773 ///
2774 /// # Returns
2775 /// - `Ok(MasterTempo)` if the `SettingContent` is of type `MySetting`.
2776 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2777 ///
2778 /// # Errors
2779 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2780 pub fn get_master_tempo(&self) -> Result<MasterTempo> {
2781 if let SettingContent::MySetting(content) = &self.data.content {
2782 Ok(content.master_tempo)
2783 } else {
2784 Err(SettingError::InvalidFile(MySetting::file_name()))
2785 }
2786 }
2787
2788 /// Sets the value of the "MASTER TEMPO" setting.
2789 ///
2790 /// # Parameters
2791 /// - `master_tempo`: The new value of the `MasterTempo` setting to be set.
2792 ///
2793 /// # Returns
2794 /// - `Ok(())` if the value is successfully set.
2795 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2796 ///
2797 /// # Errors
2798 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2799 pub fn set_master_tempo(&mut self, master_tempo: MasterTempo) -> Result<()> {
2800 if let SettingContent::MySetting(content) = &mut self.data.content {
2801 content.master_tempo = master_tempo;
2802 Ok(())
2803 } else {
2804 Err(SettingError::InvalidFile(MySetting::file_name()))
2805 }
2806 }
2807
2808 /// Gets the value of the "TEMPO RANGE" setting.
2809 ///
2810 /// # Returns
2811 /// - `Ok(TempoRange)` if the `SettingContent` is of type `MySetting`.
2812 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2813 ///
2814 /// # Errors
2815 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2816 pub fn get_tempo_range(&self) -> Result<TempoRange> {
2817 if let SettingContent::MySetting(content) = &self.data.content {
2818 Ok(content.tempo_range)
2819 } else {
2820 Err(SettingError::InvalidFile(MySetting::file_name()))
2821 }
2822 }
2823
2824 /// Sets the value of the "TEMPO RANGE" setting.
2825 ///
2826 /// # Parameters
2827 /// - `tempo_range`: The new value of the `TempoRange` setting to be set.
2828 ///
2829 /// # Returns
2830 /// - `Ok(())` if the value is successfully set.
2831 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2832 ///
2833 /// # Errors
2834 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2835 pub fn set_tempo_range(&mut self, tempo_range: TempoRange) -> Result<()> {
2836 if let SettingContent::MySetting(content) = &mut self.data.content {
2837 content.tempo_range = tempo_range;
2838 Ok(())
2839 } else {
2840 Err(SettingError::InvalidFile(MySetting::file_name()))
2841 }
2842 }
2843
2844 /// Gets the value of the "PHASE METER" setting.
2845 ///
2846 /// # Returns
2847 /// - `Ok(PhaseMeter)` if the `SettingContent` is of type `MySetting`.
2848 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2849 ///
2850 /// # Errors
2851 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2852 pub fn get_phase_meter(&self) -> Result<PhaseMeter> {
2853 if let SettingContent::MySetting(content) = &self.data.content {
2854 Ok(content.phase_meter)
2855 } else {
2856 Err(SettingError::InvalidFile(MySetting::file_name()))
2857 }
2858 }
2859
2860 /// Sets the value of the "PHASE METER" setting.
2861 ///
2862 /// # Parameters
2863 /// - `phase_meter`: The new value of the `PhaseMeter` setting to be set.
2864 ///
2865 /// # Returns
2866 /// - `Ok(())` if the value is successfully set.
2867 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting`.
2868 ///
2869 /// # Errors
2870 /// Returns an error if the `SettingContent` is not a `MySetting` file.
2871 pub fn set_phase_meter(&mut self, phase_meter: PhaseMeter) -> Result<()> {
2872 if let SettingContent::MySetting(content) = &mut self.data.content {
2873 content.phase_meter = phase_meter;
2874 Ok(())
2875 } else {
2876 Err(SettingError::InvalidFile(MySetting::file_name()))
2877 }
2878 }
2879
2880 // -- MySetting2 getters and setters --------------------------------------------------------------
2881
2882 /// Gets the value of the "VINYL SPEED ADJUST" setting.
2883 ///
2884 /// # Returns
2885 /// - `Ok(VinylSpeedAdjust)` if the `SettingContent` is of type `MySetting2`.
2886 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2887 ///
2888 /// # Errors
2889 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2890 pub fn get_vinyl_speed_adjust(&self) -> Result<VinylSpeedAdjust> {
2891 if let SettingContent::MySetting2(content) = &self.data.content {
2892 Ok(content.vinyl_speed_adjust)
2893 } else {
2894 Err(SettingError::InvalidFile(MySetting2::file_name()))
2895 }
2896 }
2897
2898 /// Sets the value of the "VINYL SPEED ADJUST" setting.
2899 ///
2900 /// # Parameters
2901 /// - `vinyl_speed_adjust`: The new value of the `VinylSpeedAdjust` setting to be set.
2902 ///
2903 /// # Returns
2904 /// - `Ok(())` if the value is successfully set.
2905 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2906 ///
2907 /// # Errors
2908 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2909 pub fn set_vinyl_speed_adjust(&mut self, vinyl_speed_adjust: VinylSpeedAdjust) -> Result<()> {
2910 if let SettingContent::MySetting2(content) = &mut self.data.content {
2911 content.vinyl_speed_adjust = vinyl_speed_adjust;
2912 Ok(())
2913 } else {
2914 Err(SettingError::InvalidFile(MySetting2::file_name()))
2915 }
2916 }
2917
2918 /// Gets the value of the "JOG DISPLAY MODE" setting.
2919 ///
2920 /// # Returns
2921 /// - `Ok(JogDisplayMode)` if the `SettingContent` is of type `MySetting2`.
2922 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2923 ///
2924 /// # Errors
2925 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2926 pub fn get_jog_display_mode(&self) -> Result<JogDisplayMode> {
2927 if let SettingContent::MySetting2(content) = &self.data.content {
2928 Ok(content.jog_display_mode)
2929 } else {
2930 Err(SettingError::InvalidFile(MySetting2::file_name()))
2931 }
2932 }
2933
2934 /// Sets the value of the "JOG DISPLAY MODE" setting.
2935 ///
2936 /// # Parameters
2937 /// - `jog_display_mode`: The new value of the `JogDisplayMode` setting to be set.
2938 ///
2939 /// # Returns
2940 /// - `Ok(())` if the value is successfully set.
2941 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2942 ///
2943 /// # Errors
2944 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2945 pub fn set_jog_display_mode(&mut self, jog_display_mode: JogDisplayMode) -> Result<()> {
2946 if let SettingContent::MySetting2(content) = &mut self.data.content {
2947 content.jog_display_mode = jog_display_mode;
2948 Ok(())
2949 } else {
2950 Err(SettingError::InvalidFile(MySetting2::file_name()))
2951 }
2952 }
2953
2954 /// Gets the value of the "PAD/BUTTON BRIGHTNESS" setting.
2955 ///
2956 /// # Returns
2957 /// - `Ok(PadButtonBrightness)` if the `SettingContent` is of type `MySetting2`.
2958 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2959 ///
2960 /// # Errors
2961 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2962 pub fn get_pad_button_brightness(&self) -> Result<PadButtonBrightness> {
2963 if let SettingContent::MySetting2(content) = &self.data.content {
2964 Ok(content.pad_button_brightness)
2965 } else {
2966 Err(SettingError::InvalidFile(MySetting2::file_name()))
2967 }
2968 }
2969
2970 /// Sets the value of the "PAD/BUTTON BRIGHTNESS" setting.
2971 ///
2972 /// # Parameters
2973 /// - `pad_button_brightness`: The new value of the `PadButtonBrightness` setting to be set.
2974 ///
2975 /// # Returns
2976 /// - `Ok(())` if the value is successfully set.
2977 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2978 ///
2979 /// # Errors
2980 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
2981 pub fn set_pad_button_brightness(
2982 &mut self,
2983 pad_button_brightness: PadButtonBrightness,
2984 ) -> Result<()> {
2985 if let SettingContent::MySetting2(content) = &mut self.data.content {
2986 content.pad_button_brightness = pad_button_brightness;
2987 Ok(())
2988 } else {
2989 Err(SettingError::InvalidFile(MySetting2::file_name()))
2990 }
2991 }
2992
2993 /// Gets the value of the "JOG LCD BRIGHTNESS" setting.
2994 ///
2995 /// # Returns
2996 /// - `Ok(JogLCDBrightness)` if the `SettingContent` is of type `MySetting2`.
2997 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
2998 ///
2999 /// # Errors
3000 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3001 pub fn get_jog_lcd_brightness(&self) -> Result<JogLCDBrightness> {
3002 if let SettingContent::MySetting2(content) = &self.data.content {
3003 Ok(content.jog_lcd_brightness)
3004 } else {
3005 Err(SettingError::InvalidFile(MySetting2::file_name()))
3006 }
3007 }
3008
3009 /// Sets the value of the "JOG LCD BRIGHTNESS" setting.
3010 ///
3011 /// # Parameters
3012 /// - `jog_lcd_brightness`: The new value of the `JogLCDBrightness` setting to be set.
3013 ///
3014 /// # Returns
3015 /// - `Ok(())` if the value is successfully set.
3016 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3017 ///
3018 /// # Errors
3019 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3020 pub fn set_jog_lcd_brightness(&mut self, jog_lcd_brightness: JogLCDBrightness) -> Result<()> {
3021 if let SettingContent::MySetting2(content) = &mut self.data.content {
3022 content.jog_lcd_brightness = jog_lcd_brightness;
3023 Ok(())
3024 } else {
3025 Err(SettingError::InvalidFile(MySetting2::file_name()))
3026 }
3027 }
3028
3029 /// Gets the value of the "WAVEFORM DIVISIONS" setting.
3030 ///
3031 /// # Returns
3032 /// - `Ok(WaveformDivisions)` if the `SettingContent` is of type `MySetting2`.
3033 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3034 ///
3035 /// # Errors
3036 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3037 pub fn get_waveform_divisions(&self) -> Result<WaveformDivisions> {
3038 if let SettingContent::MySetting2(content) = &self.data.content {
3039 Ok(content.waveform_divisions)
3040 } else {
3041 Err(SettingError::InvalidFile(MySetting2::file_name()))
3042 }
3043 }
3044
3045 /// Sets the value of the "WAVEFORM DIVISIONS" setting.
3046 ///
3047 /// # Parameters
3048 /// - `waveform_divisions`: The new value of the `WaveformDivisions` setting to be set.
3049 ///
3050 /// # Returns
3051 /// - `Ok(())` if the value is successfully set.
3052 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3053 ///
3054 /// # Errors
3055 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3056 pub fn set_waveform_divisions(&mut self, waveform_divisions: WaveformDivisions) -> Result<()> {
3057 if let SettingContent::MySetting2(content) = &mut self.data.content {
3058 content.waveform_divisions = waveform_divisions;
3059 Ok(())
3060 } else {
3061 Err(SettingError::InvalidFile(MySetting2::file_name()))
3062 }
3063 }
3064
3065 /// Gets the value of the "WAVEFORM / PHASE METER" setting.
3066 ///
3067 /// # Returns
3068 /// - `Ok(Waveform)` if the `SettingContent` is of type `MySetting2`.
3069 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3070 ///
3071 /// # Errors
3072 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3073 pub fn get_waveform(&self) -> Result<Waveform> {
3074 if let SettingContent::MySetting2(content) = &self.data.content {
3075 Ok(content.waveform)
3076 } else {
3077 Err(SettingError::InvalidFile(MySetting2::file_name()))
3078 }
3079 }
3080
3081 /// Sets the value of the "WAVEFORM / PHASE METER" setting.
3082 ///
3083 /// # Parameters
3084 /// - `waveform`: The new value of the `Waveform` setting to be set.
3085 ///
3086 /// # Returns
3087 /// - `Ok(())` if the value is successfully set.
3088 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3089 ///
3090 /// # Errors
3091 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3092 pub fn set_waveform(&mut self, waveform: Waveform) -> Result<()> {
3093 if let SettingContent::MySetting2(content) = &mut self.data.content {
3094 content.waveform = waveform;
3095 Ok(())
3096 } else {
3097 Err(SettingError::InvalidFile(MySetting2::file_name()))
3098 }
3099 }
3100
3101 /// Gets the value of the "BEAT JUMP BEAT VALUE" setting.
3102 ///
3103 /// # Returns
3104 /// - `Ok(BeatJumpBeatValue)` if the `SettingContent` is of type `MySetting2`.
3105 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3106 ///
3107 /// # Errors
3108 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3109 pub fn get_beat_jump_beat_value(&self) -> Result<BeatJumpBeatValue> {
3110 if let SettingContent::MySetting2(content) = &self.data.content {
3111 Ok(content.beat_jump_beat_value)
3112 } else {
3113 Err(SettingError::InvalidFile(MySetting2::file_name()))
3114 }
3115 }
3116
3117 /// Sets the value of the "BEAT JUMP BEAT VALUE" setting.
3118 ///
3119 /// # Parameters
3120 /// - `beat_jump_beat_value`: The new value of the `BeatJumpBeatValue` setting to be set.
3121 ///
3122 /// # Returns
3123 /// - `Ok(())` if the value is successfully set.
3124 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `MySetting2`.
3125 ///
3126 /// # Errors
3127 /// Returns an error if the `SettingContent` is not a `MySetting2` file.
3128 pub fn set_beat_jump_beat_value(
3129 &mut self,
3130 beat_jump_beat_value: BeatJumpBeatValue,
3131 ) -> Result<()> {
3132 if let SettingContent::MySetting2(content) = &mut self.data.content {
3133 content.beat_jump_beat_value = beat_jump_beat_value;
3134 Ok(())
3135 } else {
3136 Err(SettingError::InvalidFile(MySetting2::file_name()))
3137 }
3138 }
3139
3140 // -- DJMMySetting getters and setters -----------------------------------------------------------
3141
3142 /// Gets the value of the "CH FADER CURVE" setting.
3143 ///
3144 /// # Returns
3145 /// - `Ok(ChannelFaderCurve)` if the `SettingContent` is of type `DJMMySetting`.
3146 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3147 ///
3148 /// # Errors
3149 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3150 pub fn get_channel_fader_curve(&self) -> Result<ChannelFaderCurve> {
3151 if let SettingContent::DJMMySetting(content) = &self.data.content {
3152 Ok(content.channel_fader_curve)
3153 } else {
3154 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3155 }
3156 }
3157
3158 /// Sets the value of the "CH FADER CURVE" setting.
3159 ///
3160 /// # Parameters
3161 /// - `channel_fader_curve`: The new value of the `ChannelFaderCurve` setting to be set.
3162 ///
3163 /// # Returns
3164 /// - `Ok(())` if the value is successfully set.
3165 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3166 ///
3167 /// # Errors
3168 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3169 pub fn set_channel_fader_curve(
3170 &mut self,
3171 channel_fader_curve: ChannelFaderCurve,
3172 ) -> Result<()> {
3173 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3174 content.channel_fader_curve = channel_fader_curve;
3175 Ok(())
3176 } else {
3177 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3178 }
3179 }
3180
3181 /// Gets the value of the "CROSSFADER CURVE" setting.
3182 ///
3183 /// # Returns
3184 /// - `Ok(CrossfaderCurve)` if the `SettingContent` is of type `DJMMySetting`.
3185 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3186 ///
3187 /// # Errors
3188 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3189 pub fn get_crossfader_curve(&self) -> Result<CrossfaderCurve> {
3190 if let SettingContent::DJMMySetting(content) = &self.data.content {
3191 Ok(content.crossfader_curve)
3192 } else {
3193 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3194 }
3195 }
3196
3197 /// Sets the value of the "CROSSFADER CURVE" setting.
3198 ///
3199 /// # Parameters
3200 /// - `crossfader_curve`: The new value of the `CrossfaderCurve` setting to be set.
3201 ///
3202 /// # Returns
3203 /// - `Ok(())` if the value is successfully set.
3204 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3205 ///
3206 /// # Errors
3207 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3208 pub fn set_crossfader_curve(&mut self, crossfader_curve: CrossfaderCurve) -> Result<()> {
3209 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3210 content.crossfader_curve = crossfader_curve;
3211 Ok(())
3212 } else {
3213 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3214 }
3215 }
3216
3217 /// Gets the value of the "HEADPHONES PRE EQ" setting.
3218 ///
3219 /// # Returns
3220 /// - `Ok(HeadphonesPreEQ)` if the `SettingContent` is of type `DJMMySetting`.
3221 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3222 ///
3223 /// # Errors
3224 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3225 pub fn get_headphones_pre_eq(&self) -> Result<HeadphonesPreEQ> {
3226 if let SettingContent::DJMMySetting(content) = &self.data.content {
3227 Ok(content.headphones_pre_eq)
3228 } else {
3229 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3230 }
3231 }
3232
3233 /// Sets the value of the "HEADPHONES PRE EQ" setting.
3234 ///
3235 /// # Parameters
3236 /// - `headphones_pre_eq`: The new value of the `HeadphonesPreEQ` setting to be set.
3237 ///
3238 /// # Returns
3239 /// - `Ok(())` if the value is successfully set.
3240 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3241 ///
3242 /// # Errors
3243 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3244 pub fn set_headphones_pre_eq(&mut self, headphones_pre_eq: HeadphonesPreEQ) -> Result<()> {
3245 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3246 content.headphones_pre_eq = headphones_pre_eq;
3247 Ok(())
3248 } else {
3249 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3250 }
3251 }
3252
3253 /// Gets the value of the "HEADPHONES MONO SPLIT" setting.
3254 ///
3255 /// # Returns
3256 /// - `Ok(HeadphonesMonoSplit)` if the `SettingContent` is of type `DJMMySetting`.
3257 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3258 ///
3259 /// # Errors
3260 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3261 pub fn get_headphones_mono_split(&self) -> Result<HeadphonesMonoSplit> {
3262 if let SettingContent::DJMMySetting(content) = &self.data.content {
3263 Ok(content.headphones_mono_split)
3264 } else {
3265 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3266 }
3267 }
3268
3269 /// Sets the value of the "HEADPHONES MONO SPLIT" setting.
3270 ///
3271 /// # Parameters
3272 /// - `headphones_mono_split`: The new value of the `HeadphonesMonoSplit` setting to be set.
3273 ///
3274 /// # Returns
3275 /// - `Ok(())` if the value is successfully set.
3276 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3277 ///
3278 /// # Errors
3279 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3280 pub fn set_headphones_mono_split(
3281 &mut self,
3282 headphones_mono_split: HeadphonesMonoSplit,
3283 ) -> Result<()> {
3284 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3285 content.headphones_mono_split = headphones_mono_split;
3286 Ok(())
3287 } else {
3288 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3289 }
3290 }
3291
3292 /// Gets the value of the "BEAT FX QUANTIZE" setting.
3293 ///
3294 /// # Returns
3295 /// - `Ok(BeatFXQuantize)` if the `SettingContent` is of type `DJMMySetting`.
3296 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3297 ///
3298 /// # Errors
3299 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3300 pub fn get_beat_fx_quantize(&self) -> Result<BeatFXQuantize> {
3301 if let SettingContent::DJMMySetting(content) = &self.data.content {
3302 Ok(content.beat_fx_quantize)
3303 } else {
3304 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3305 }
3306 }
3307
3308 /// Sets the value of the "BEAT FX QUANTIZE" setting.
3309 ///
3310 /// # Parameters
3311 /// - `beat_fx_quantize`: The new value of the `BeatFXQuantize` setting to be set.
3312 ///
3313 /// # Returns
3314 /// - `Ok(())` if the value is successfully set.
3315 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3316 ///
3317 /// # Errors
3318 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3319 pub fn set_beat_fx_quantize(&mut self, beat_fx_quantize: BeatFXQuantize) -> Result<()> {
3320 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3321 content.beat_fx_quantize = beat_fx_quantize;
3322 Ok(())
3323 } else {
3324 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3325 }
3326 }
3327
3328 /// Gets the value of the "MIC LOW CUT" setting.
3329 ///
3330 /// # Returns
3331 /// - `Ok(MicLowCut)` if the `SettingContent` is of type `DJMMySetting`.
3332 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3333 ///
3334 /// # Errors
3335 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3336 pub fn get_mic_low_cut(&self) -> Result<MicLowCut> {
3337 if let SettingContent::DJMMySetting(content) = &self.data.content {
3338 Ok(content.mic_low_cut)
3339 } else {
3340 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3341 }
3342 }
3343
3344 /// Sets the value of the "MIC LOW CUT" setting.
3345 ///
3346 /// # Parameters
3347 /// - `mic_low_cut`: The new value of the `MicLowCut` setting to be set.
3348 ///
3349 /// # Returns
3350 /// - `Ok(())` if the value is successfully set.
3351 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3352 ///
3353 /// # Errors
3354 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3355 pub fn set_mic_low_cut(&mut self, mic_low_cut: MicLowCut) -> Result<()> {
3356 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3357 content.mic_low_cut = mic_low_cut;
3358 Ok(())
3359 } else {
3360 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3361 }
3362 }
3363
3364 /// Gets the value of the "TALK OVER MODE" setting.
3365 ///
3366 /// # Returns
3367 /// - `Ok(TalkOverMode)` if the `SettingContent` is of type `DJMMySetting`.
3368 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3369 ///
3370 /// # Errors
3371 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3372 pub fn get_talk_over_mode(&self) -> Result<TalkOverMode> {
3373 if let SettingContent::DJMMySetting(content) = &self.data.content {
3374 Ok(content.talk_over_mode)
3375 } else {
3376 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3377 }
3378 }
3379
3380 /// Sets the value of the "TALK OVER MODE" setting.
3381 ///
3382 /// # Parameters
3383 /// - `talk_over_mode`: The new value of the `TalkOverMode` setting to be set.
3384 ///
3385 /// # Returns
3386 /// - `Ok(())` if the value is successfully set.
3387 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3388 ///
3389 /// # Errors
3390 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3391 pub fn set_talk_over_mode(&mut self, talk_over_mode: TalkOverMode) -> Result<()> {
3392 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3393 content.talk_over_mode = talk_over_mode;
3394 Ok(())
3395 } else {
3396 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3397 }
3398 }
3399
3400 /// Gets the value of the "TALK OVER LEVEL" setting.
3401 ///
3402 /// # Returns
3403 /// - `Ok(TalkOverLevel)` if the `SettingContent` is of type `DJMMySetting`.
3404 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3405 ///
3406 /// # Errors
3407 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3408 pub fn get_talk_over_level(&self) -> Result<TalkOverLevel> {
3409 if let SettingContent::DJMMySetting(content) = &self.data.content {
3410 Ok(content.talk_over_level)
3411 } else {
3412 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3413 }
3414 }
3415
3416 /// Sets the value of the "TALK OVER LEVEL" setting.
3417 ///
3418 /// # Parameters
3419 /// - `talk_over_level`: The new value of the `TalkOverLevel` setting to be set.
3420 ///
3421 /// # Returns
3422 /// - `Ok(())` if the value is successfully set.
3423 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3424 ///
3425 /// # Errors
3426 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3427 pub fn set_talk_over_level(&mut self, talk_over_level: TalkOverLevel) -> Result<()> {
3428 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3429 content.talk_over_level = talk_over_level;
3430 Ok(())
3431 } else {
3432 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3433 }
3434 }
3435
3436 /// Gets the value of the "MIDI CH" setting.
3437 ///
3438 /// # Returns
3439 /// - `Ok(MidiChannel)` if the `SettingContent` is of type `DJMMySetting`.
3440 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3441 ///
3442 /// # Errors
3443 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3444 pub fn get_midi_channel(&self) -> Result<MidiChannel> {
3445 if let SettingContent::DJMMySetting(content) = &self.data.content {
3446 Ok(content.midi_channel)
3447 } else {
3448 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3449 }
3450 }
3451
3452 /// Sets the value of the "MIDI CH" setting.
3453 ///
3454 /// # Parameters
3455 /// - `midi_channel`: The new value of the `MidiChannel` setting to be set.
3456 ///
3457 /// # Returns
3458 /// - `Ok(())` if the value is successfully set.
3459 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3460 ///
3461 /// # Errors
3462 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3463 pub fn set_midi_channel(&mut self, midi_channel: MidiChannel) -> Result<()> {
3464 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3465 content.midi_channel = midi_channel;
3466 Ok(())
3467 } else {
3468 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3469 }
3470 }
3471
3472 /// Gets the value of the "MIDI BUTTON TYPE" setting.
3473 ///
3474 /// # Returns
3475 /// - `Ok(MidiButtonType)` if the `SettingContent` is of type `DJMMySetting`.
3476 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3477 ///
3478 /// # Errors
3479 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3480 pub fn get_midi_button_type(&self) -> Result<MidiButtonType> {
3481 if let SettingContent::DJMMySetting(content) = &self.data.content {
3482 Ok(content.midi_button_type)
3483 } else {
3484 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3485 }
3486 }
3487
3488 /// Sets the value of the "MIDI BUTTON TYPE" setting.
3489 ///
3490 /// # Parameters
3491 /// - `midi_button_type`: The new value of the `MidiButtonType` setting to be set.
3492 ///
3493 /// # Returns
3494 /// - `Ok(())` if the value is successfully set.
3495 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3496 ///
3497 /// # Errors
3498 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3499 pub fn set_midi_button_type(&mut self, midi_button_type: MidiButtonType) -> Result<()> {
3500 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3501 content.midi_button_type = midi_button_type;
3502 Ok(())
3503 } else {
3504 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3505 }
3506 }
3507
3508 /// Gets the value of the "MIXER DISPLAY BRIGHTNESS" setting.
3509 ///
3510 /// # Returns
3511 /// - `Ok(MixerDisplayBrightness)` if the `SettingContent` is of type `DJMMySetting`.
3512 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3513 ///
3514 /// # Errors
3515 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3516 pub fn get_mixer_display_brightness(&self) -> Result<MixerDisplayBrightness> {
3517 if let SettingContent::DJMMySetting(content) = &self.data.content {
3518 Ok(content.display_brightness)
3519 } else {
3520 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3521 }
3522 }
3523
3524 /// Sets the value of the "MIXER DISPLAY BRIGHTNESS" setting.
3525 ///
3526 /// # Parameters
3527 /// - `mixer_display_brightness`: The new value of the `MixerDisplayBrightness` setting to be set.
3528 ///
3529 /// # Returns
3530 /// - `Ok(())` if the value is successfully set.
3531 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3532 ///
3533 /// # Errors
3534 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3535 pub fn set_mixer_display_brightness(
3536 &mut self,
3537 mixer_display_brightness: MixerDisplayBrightness,
3538 ) -> Result<()> {
3539 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3540 content.display_brightness = mixer_display_brightness;
3541 Ok(())
3542 } else {
3543 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3544 }
3545 }
3546
3547 /// Gets the value of the "MIXER INDICATOR BRIGHTNESS" setting.
3548 ///
3549 /// # Returns
3550 /// - `Ok(MixerIndicatorBrightness)` if the `SettingContent` is of type `DJMMySetting`.
3551 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3552 ///
3553 /// # Errors
3554 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3555 pub fn get_mixer_indicator_brightness(&self) -> Result<MixerIndicatorBrightness> {
3556 if let SettingContent::DJMMySetting(content) = &self.data.content {
3557 Ok(content.indicator_brightness)
3558 } else {
3559 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3560 }
3561 }
3562
3563 /// Sets the value of the "MIXER INDICATOR BRIGHTNESS" setting.
3564 ///
3565 /// # Parameters
3566 /// - `mixer_indicator_brightness`: The new value of the `MixerIndicatorBrightness` setting to be set.
3567 ///
3568 /// # Returns
3569 /// - `Ok(())` if the value is successfully set.
3570 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3571 ///
3572 /// # Errors
3573 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3574 pub fn set_mixer_indicator_brightness(
3575 &mut self,
3576 mixer_indicator_brightness: MixerIndicatorBrightness,
3577 ) -> Result<()> {
3578 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3579 content.indicator_brightness = mixer_indicator_brightness;
3580 Ok(())
3581 } else {
3582 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3583 }
3584 }
3585
3586 /// Gets the value of the "CH FADER CURVE (LONG FADER)" setting.
3587 ///
3588 /// # Returns
3589 /// - `Ok(ChannelFaderCurveLongFader)` if the `SettingContent` is of type `DJMMySetting`.
3590 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3591 ///
3592 /// # Errors
3593 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3594 pub fn get_channel_fader_curve_long_fader(&self) -> Result<ChannelFaderCurveLongFader> {
3595 if let SettingContent::DJMMySetting(content) = &self.data.content {
3596 Ok(content.channel_fader_curve_long_fader)
3597 } else {
3598 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3599 }
3600 }
3601
3602 /// Sets the value of the "CH FADER CURVE (LONG FADER)" setting.
3603 ///
3604 /// # Parameters
3605 /// - `channel_fader_curve_long_fader`: The new value of the `ChannelFaderCurveLongFader` setting to be set.
3606 ///
3607 /// # Returns
3608 /// - `Ok(())` if the value is successfully set.
3609 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DJMMySetting`.
3610 ///
3611 /// # Errors
3612 /// Returns an error if the `SettingContent` is not a `DJMMySetting` file.
3613 pub fn set_channel_fader_curve_long_fader(
3614 &mut self,
3615 channel_fader_curve_long_fader: ChannelFaderCurveLongFader,
3616 ) -> Result<()> {
3617 if let SettingContent::DJMMySetting(content) = &mut self.data.content {
3618 content.channel_fader_curve_long_fader = channel_fader_curve_long_fader;
3619 Ok(())
3620 } else {
3621 Err(SettingError::InvalidFile(DJMMySetting::file_name()))
3622 }
3623 }
3624
3625 // -- DevSetting getters and setters --------------------------------------------------------------
3626
3627 /// Gets the value of the "Type of the overview Waveform" setting.
3628 ///
3629 /// # Returns
3630 /// - `Ok(OverviewWaveformType)` if the `SettingContent` is of type `DevSetting`.
3631 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3632 ///
3633 /// # Errors
3634 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3635 pub fn get_overview_waveform_type(&self) -> Result<OverviewWaveformType> {
3636 if let SettingContent::DevSetting(content) = &self.data.content {
3637 Ok(content.overview_waveform_type)
3638 } else {
3639 Err(SettingError::InvalidFile(DevSetting::file_name()))
3640 }
3641 }
3642
3643 /// Sets the value of the "Type of the overview Waveform" setting.
3644 ///
3645 /// # Parameters
3646 /// - `overview_waveform_type`: The new value of the `OverviewWaveformType` setting to be set.
3647 ///
3648 /// # Returns
3649 /// - `Ok(())` if the value is successfully set.
3650 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3651 ///
3652 /// # Errors
3653 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3654 pub fn set_overview_waveform_type(
3655 &mut self,
3656 overview_waveform_type: OverviewWaveformType,
3657 ) -> Result<()> {
3658 if let SettingContent::DevSetting(content) = &mut self.data.content {
3659 content.overview_waveform_type = overview_waveform_type;
3660 Ok(())
3661 } else {
3662 Err(SettingError::InvalidFile(DevSetting::file_name()))
3663 }
3664 }
3665
3666 /// Gets the value of the "Waveform color" setting.
3667 ///
3668 /// # Returns
3669 /// - `Ok(WaveformColor)` if the `SettingContent` is of type `DevSetting`.
3670 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3671 ///
3672 /// # Errors
3673 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3674 pub fn get_waveform_color(&self) -> Result<WaveformColor> {
3675 if let SettingContent::DevSetting(content) = &self.data.content {
3676 Ok(content.waveform_color)
3677 } else {
3678 Err(SettingError::InvalidFile(DevSetting::file_name()))
3679 }
3680 }
3681
3682 /// Sets the value of the "Waveform color" setting.
3683 ///
3684 /// # Parameters
3685 /// - `waveform_color`: The new value of the `WaveformColor` setting to be set.
3686 ///
3687 /// # Returns
3688 /// - `Ok(())` if the value is successfully set.
3689 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3690 ///
3691 /// # Errors
3692 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3693 pub fn set_waveform_color(&mut self, waveform_color: WaveformColor) -> Result<()> {
3694 if let SettingContent::DevSetting(content) = &mut self.data.content {
3695 content.waveform_color = waveform_color;
3696 Ok(())
3697 } else {
3698 Err(SettingError::InvalidFile(DevSetting::file_name()))
3699 }
3700 }
3701
3702 /// Gets the value of the "Key display format" setting.
3703 ///
3704 /// # Returns
3705 /// - `Ok(KeyDisplayFormat)` if the `SettingContent` is of type `DevSetting`.
3706 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3707 ///
3708 /// # Errors
3709 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3710 pub fn get_key_display_format(&self) -> Result<KeyDisplayFormat> {
3711 if let SettingContent::DevSetting(content) = &self.data.content {
3712 Ok(content.key_display_format)
3713 } else {
3714 Err(SettingError::InvalidFile(DevSetting::file_name()))
3715 }
3716 }
3717
3718 /// Sets the value of the "Key display format" setting.
3719 ///
3720 /// # Parameters
3721 /// - `key_display_format`: The new value of the `KeyDisplayFormat` setting to be set.
3722 ///
3723 /// # Returns
3724 /// - `Ok(())` if the value is successfully set.
3725 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3726 ///
3727 /// # Errors
3728 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3729 pub fn set_key_display_format(&mut self, key_display_format: KeyDisplayFormat) -> Result<()> {
3730 if let SettingContent::DevSetting(content) = &mut self.data.content {
3731 content.key_display_format = key_display_format;
3732 Ok(())
3733 } else {
3734 Err(SettingError::InvalidFile(DevSetting::file_name()))
3735 }
3736 }
3737
3738 /// Gets the value of the "Waveform Current Position" setting.
3739 ///
3740 /// # Returns
3741 /// - `Ok(WaveformCurrentPosition)` if the `SettingContent` is of type `DevSetting`.
3742 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3743 ///
3744 /// # Errors
3745 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3746 pub fn get_waveform_current_position(&self) -> Result<WaveformCurrentPosition> {
3747 if let SettingContent::DevSetting(content) = &self.data.content {
3748 Ok(content.waveform_current_position)
3749 } else {
3750 Err(SettingError::InvalidFile(DevSetting::file_name()))
3751 }
3752 }
3753
3754 /// Sets the value of the "Waveform Current Position" setting.
3755 ///
3756 /// # Parameters
3757 /// - `waveform_current_position`: The new value of the `WaveformCurrentPosition` setting to be set.
3758 ///
3759 /// # Returns
3760 /// - `Ok(())` if the value is successfully set.
3761 /// - `Err(SettingError::InvalidFile)` if the `SettingContent` is not of type `DevSetting`.
3762 ///
3763 /// # Errors
3764 /// Returns an error if the `SettingContent` is not a `DevSetting` file.
3765 pub fn set_waveform_current_position(
3766 &mut self,
3767 waveform_current_position: WaveformCurrentPosition,
3768 ) -> Result<()> {
3769 if let SettingContent::DevSetting(content) = &mut self.data.content {
3770 content.waveform_current_position = waveform_current_position;
3771 Ok(())
3772 } else {
3773 Err(SettingError::InvalidFile(DevSetting::file_name()))
3774 }
3775 }
3776}