Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High Level API #92

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

High Level API #92

wants to merge 13 commits into from

Conversation

Holzhaus
Copy link
Owner

This is an attempt to look into a high-level API to make it easier to read from (and later also write to) Rekordbox device exports without knowing much about the internals.

As first step, I only added support for setting files:

let mut export = DeviceExport::default();
export.load(path)?;
let settings = export.get_settings();

The CLI makes use of the new API when calling the new list-settings subcommand:

$ rekordcrate list-settings data/complete_export/demo_tracks/
On Air Display:                 On
LCD Brightness:                 3
Quantize:                       On
Auto Cue Level:                 Memory
Language:                       English
Jog Ring Brightness:            2 (Bright)
Jog Ring Indicator:             On
Slip Flashing:                  On
Disc Slot Illumination:         2 (Bright)
Eject Lock:                     Unlock
Sync:                           Off
Play Mode:                      Single / Off
Quantize Beat Value:            1 Beat
Hotcue Autoload:                On
Hotcue Color:                   Off
Needle Lock:                    Lock
Time Mode:                      Remain
Jog Mode:                       Vinyl
Auto Cue:                       On
Master Tempo:                   Off
Tempo Range:                    ±10%
Phase Meter:                    Type 1
Vinyl Speed Adjust:             Touch
Jog Display Mode:               Auto
Pad Button Brightness:          3
Jog LCD Brightness:             3
Waveform Divisions:             Phrase
Waveform:                       Waveform
Beat Jump Beat Value:           16 Beat
Channel Fader Curve:            Linear
Crossfader Curve:               Fast Cut
Headphones Pre Eq:              Post EQ
Headphones Mono Split:          Stereo
Beat FX Quantize:               On
Mic Low Cut:                    On
Talk Over Mode:                 Advanced
Talk Over Level:                -18dB
MIDI Channel:                   1
MIDI Button Type:               Toggle
Display Brightness:             5
Indicator Brightness:           3
Channel Fader Curve Long Fader: Exponential
Overview Waveform Type:         Half Waveform
Waveform Color:                 Blue
Key Display Format:             Classic
Waveform Current Position:      Center

Based on #90 and #91.

@Holzhaus Holzhaus changed the title High level api High Level API Oct 11, 2022
Copy link
Contributor

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate a bit more on the high-level principle of these Settings? What data is contained in which file, what files are exported, which are expected to be present on an external drive, etc?

Also in terms of code, I'm getting a bit confused because I regularly mix up Settings (high-level API) and Setting (binrw).

Comment on lines 26 to 31
pub mod anlz;
pub mod device;
pub mod pdb;
pub mod setting;
pub mod util;
pub(crate) mod xor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make the more internal modules private when they have a nicer API counterpart.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Maybe we should group the low-level stuff in a separate submodule or crate but leave it public for people who want to experiment or squeeze out maximum performance?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Holzhaus another layer makes sense. Basically a "core" library.

(hi gang, I've been watching the progress and though I would chime in. Hope it's not TOO weird to have me just pop into the conversation).

Comment on lines +76 to +157
#[derive(Debug, Default, PartialEq, Eq, Clone)]
pub struct Settings {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we want the Default to be? Just a struct with all Nones (which is derived) or with the actual default settings from rekordbox?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rekordbox' default settings probably make sense.

src/device.rs Outdated Show resolved Hide resolved
src/main.rs Outdated
Comment on lines 125 to 172
let mut export = DeviceExport::default();
export.load(path)?;
let settings = export.get_settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO constructing a mutable default and then loading from a file doesn't seem very rusty to me. Why not make load a constructor? Also allows for nice chaining.

Suggested change
let mut export = DeviceExport::default();
export.load(path)?;
let settings = export.get_settings();
let settings = DeviceExport::load(path)?.get_settings();

@Holzhaus Holzhaus force-pushed the high-level-api branch 2 times, most recently from 0679936 to 8a75859 Compare October 11, 2022 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants