Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ wgpu.
Waveforms, clips and the playhead are drawn on the GPU, so the timeline stays at 60 fps with thousands of clips.
Shortcuts cover the common moves: ⇧⌘T adds an instrument track, ⌘R reverses the selected clip, ⌘L loops the selected
clip or section, ⌘D duplicates the selected clip or section. Settings › Shortcuts lists them all by section; click
one's keys to record new ones, search by name or key, and reset to the defaults at any time. ↑/↓ select the track above
one's keys to record new ones, search by name or key, and reset to the defaults at any time. Its Preset menu swaps in
the keys of Ableton Live, Logic Pro, GarageBand, FL Studio, Fender Studio Pro, Bitwig, Pro Tools or BandLab. ↑/↓ select the track above
or below, ⇧↑/⇧↓ (⌘⇧ for an octave) transpose the selected MIDI clips, U folds a group, A shows automation, I
monitors the selected track's input and ⌘⌥M shows the mixer. In the piano roll, ⌘↑/⌘↓ (⌥ for 10) change the
selected notes' velocity and ←/→ (⇧ for a bar) move them. 0 or M mutes the selected clips (or the track), ←/→ step
Expand Down
19 changes: 16 additions & 3 deletions crates/dstudio-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ mod selftest;
mod send_to_sampler;
mod settings;
mod shape_rack;
mod shortcut_presets;
mod shortcuts;
mod showcase;
mod snap;
Expand Down Expand Up @@ -711,7 +712,9 @@ fn parse_args() -> Result<Args, String> {
| "review-shortcuts-strip"
| "review-shortcuts-zoom"
| "review-shortcuts-move"
| "review-shortcuts-mouse") => {
| "review-shortcuts-mouse"
| "review-shortcuts-preset-menu"
| "review-shortcuts-logic") => {
a.reference_default = true;
a.shortcuts_review = match st {
"review-shortcuts-recording" => 2,
Expand All @@ -723,12 +726,14 @@ fn parse_args() -> Result<Args, String> {
"review-shortcuts-zoom" => 8,
"review-shortcuts-move" => 9,
"review-shortcuts-mouse" => 10,
"review-shortcuts-preset-menu" => 11,
"review-shortcuts-logic" => 12,
_ => 1,
};
}
s => {
return Err(format!(
"unknown state {s} (supported: reference-default, reference-mixer, reference-assistant, reference-midi-clip, reference-pianoroll, reference-synth, reference-input-menu, reference-settings-audio, reference-devices-effects, reference-automation, reference-live, review-automation, review-automation-picker, review-recording, review-midi-recording, review-settings-midi, review-shortcuts, review-shortcuts-recording, review-shortcuts-unmapped, review-shortcuts-tracks, review-shortcuts-notes, review-shortcuts-transpose, review-shortcuts-strip, review-shortcuts-zoom, review-shortcuts-move, review-shortcuts-mouse, review-device-chain, review-devices-minimap, review-returns, review-returns-strip, review-returns-empty, review-returns-options, review-snap-menu, review-count-in-menu, review-clip-takes, review-track-menu, review-track-drag, review-clip-selection, review-transport-sig, review-transport-key, review-track-rename, review-audio-loop-drag, review-pr-zoom, review-pr-typing, review-pr-reverse, review-pr-velocity, reference-<built-in device id> e.g. reference-compressor, window-<id> and review-window-<id> (expanded window, review- with a test signal), reference-lfo, reference-chain, review-settings-plugins, review-strip-trim, review-plugin-folders, review-analyzers, review-assistant-<empty|turn|point|draft|steps|error|busy|highlight|narrow>)"
"unknown state {s} (supported: reference-default, reference-mixer, reference-assistant, reference-midi-clip, reference-pianoroll, reference-synth, reference-input-menu, reference-settings-audio, reference-devices-effects, reference-automation, reference-live, review-automation, review-automation-picker, review-recording, review-midi-recording, review-settings-midi, review-shortcuts, review-shortcuts-recording, review-shortcuts-unmapped, review-shortcuts-tracks, review-shortcuts-notes, review-shortcuts-transpose, review-shortcuts-strip, review-shortcuts-zoom, review-shortcuts-move, review-shortcuts-mouse, review-shortcuts-preset-menu, review-shortcuts-logic, review-device-chain, review-devices-minimap, review-returns, review-returns-strip, review-returns-empty, review-returns-options, review-snap-menu, review-count-in-menu, review-clip-takes, review-track-menu, review-track-drag, review-clip-selection, review-transport-sig, review-transport-key, review-track-rename, review-audio-loop-drag, review-pr-zoom, review-pr-typing, review-pr-reverse, review-pr-velocity, reference-<built-in device id> e.g. reference-compressor, window-<id> and review-window-<id> (expanded window, review- with a test signal), reference-lfo, reference-chain, review-settings-plugins, review-strip-trim, review-plugin-folders, review-analyzers, review-assistant-<empty|turn|point|draft|steps|error|busy|highlight|narrow>)"
));
}
},
Expand Down Expand Up @@ -941,6 +946,11 @@ fn key_name(text: &str) -> Option<String> {
"\u{F703}" => "Right",
"," => "Comma",
"." => "Period",
"\u{14}" => "CapsLock",
// F1..F12 (Slint sends them as private-use characters).
t if t.chars().count() == 1 && ('\u{F704}'..='\u{F70F}').contains(&t.chars().next().unwrap_or(' ')) => {
return Some(format!("F{}", t.chars().next().unwrap_or(' ') as u32 - 0xF704 + 1));
}
t if t.chars().count() == 1 && t.chars().all(|c| c.is_ascii_graphic()) => return Some(t.to_ascii_uppercase()),
_ => return None,
};
Expand Down Expand Up @@ -2614,12 +2624,15 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
8 => c.shortcuts_search("zoom"),
9 => c.shortcuts_search("move"),
10 => c.shortcuts_search("mouse"),
// The Preset menu open; Logic Pro's keys in use (prefs are never saved in --state runs).
11 => c.settings_dropdown(4),
12 => c.shortcuts_set_preset("Logic Pro"),
_ => {}
}
if args.shortcuts_review == 3 {
// SCREENSHOT-ONLY: a changed keymap (prefs are never saved in --state runs).
c.settings.keys.map.set_chords("transport.tap_tempo", Vec::new());
c.settings.prefs.shortcuts = shortcuts::changes(&c.settings.keys.map);
c.settings.prefs.shortcuts = shortcuts::changes(&c.settings.keys.map, &c.settings.prefs.shortcut_preset);
}
}
if args.settings_midi_review {
Expand Down
7 changes: 7 additions & 0 deletions crates/dstudio-app/src/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ pub struct Preferences {
/// `Chord::parse` form (an empty list = unmapped). Actions not listed keep their defaults.
#[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")]
pub shortcuts: std::collections::BTreeMap<String, Vec<String>>,
/// Settings › Shortcuts › Preset: the other DAW whose keys the keymap starts from
/// (`shortcut_presets::PRESETS`; empty = Device Studio's own). `shortcuts` holds the
/// changes on top of it.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub shortcut_preset: String,
}

fn is_zero_u8(v: &u8) -> bool {
Expand Down Expand Up @@ -221,6 +226,7 @@ mod tests {
plugin_folders: vec!["/opt/plugins".into()],
count_in_bars: 2,
shortcuts: [("transport.record".to_string(), vec!["primary+shift+r".to_string()])].into_iter().collect(),
shortcut_preset: "Logic Pro".into(),
};
save(&path, &p).unwrap();
assert_eq!(load(&path).unwrap(), Some(p.clone()));
Expand All @@ -236,6 +242,7 @@ mod tests {
assert!(loaded.midi.disabled_inputs.is_empty(), "MIDI inputs default to on");
assert!(loaded.plugin_folders.is_empty(), "files without custom plugin folders have none");
assert!(loaded.shortcuts.is_empty(), "files without shortcut changes keep the defaults");
assert!(loaded.shortcut_preset.is_empty(), "files without a preset use Device Studio's keys");
assert_eq!(loaded.count_in_bars, 0, "files without a count-in record straight away");
let _ = std::fs::remove_dir_all(dir);
}
Expand Down
52 changes: 52 additions & 0 deletions crates/dstudio-app/src/selftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12618,6 +12618,58 @@ fn shortcut_page_steps() -> Vec<Step> {
.ok_or(format!("saved {:?}", c.settings.prefs.shortcuts))
}),
),
Do("shortcuts: open the Preset menu", Box::new(|a| a.global::<Studio>().invoke_settings_dropdown(4))),
Check(
"shortcuts: the menu lists the nine presets, Device Studio checked",
Box::new(|_, a| {
let s = a.global::<Studio>();
let items = s.get_settings_menu_items();
let labels: Vec<String> = (0..slint::Model::row_count(&items))
.filter_map(|i| slint::Model::row_data(&items, i))
.map(|it| format!("{}{}", it.label, if it.checked { " ✓" } else { "" }))
.collect();
(s.get_settings_menu_open() && labels.len() == 9 && labels[0] == "Device Studio ✓" && labels[2] == "Logic Pro")
.then_some(())
.ok_or(format!("{labels:?}"))
}),
),
Do("shortcuts: pick Logic Pro", Box::new(|a| a.global::<Studio>().invoke_settings_menu_pick(2))),
Check(
"shortcuts: Logic Pro's keys are in use (Loop on / off on C), saved, nothing to reset",
Box::new(|c, a| {
let s = a.global::<Studio>();
let r = rows(a);
let lp = r.iter().find(|r| r.label == "Loop on / off");
let keys = lp.and_then(|p| slint::Model::row_data(&p.chords, 0)).map(|k| {
(0..slint::Model::row_count(&k.parts)).filter_map(|i| slint::Model::row_data(&k.parts, i)).collect::<Vec<_>>()
});
(c.settings.prefs.shortcut_preset == "Logic Pro"
&& s.get_shortcut_preset() == "Logic Pro"
&& !s.get_settings_menu_open()
&& keys == Some(vec!["C".into()])
&& !s.get_shortcut_reset_enabled())
.then_some(())
.ok_or(format!("preset {:?} keys {keys:?}", c.settings.prefs.shortcut_preset))
}),
),
Do(
"shortcuts: back to the Device Studio preset",
Box::new(|a| {
let s = a.global::<Studio>();
s.invoke_settings_dropdown(4);
s.invoke_settings_menu_pick(0);
}),
),
Check(
"shortcuts: the default keys are back",
Box::new(|c, a| {
(c.settings.keys.map == crate::app_keymap()
&& c.settings.prefs.shortcut_preset.is_empty()
&& a.global::<Studio>().get_shortcut_preset() == "Device Studio")
.then_some(())
.ok_or(format!("preset {:?}", c.settings.prefs.shortcut_preset))
}),
),
DoC("shortcuts: close Settings", Box::new(|_, ctl| ctl.borrow_mut().close_settings())),
]
}
Expand Down
13 changes: 12 additions & 1 deletion crates/dstudio-app/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ pub enum Field {
Input = 1,
SampleRate = 2,
BufferSize = 3,
/// Settings › Shortcuts › Preset.
ShortcutPreset = 4,
}

impl Field {
fn from_i32(i: i32) -> Option<Field> {
[Field::Output, Field::Input, Field::SampleRate, Field::BufferSize].into_iter().find(|f| *f as i32 == i)
[Field::Output, Field::Input, Field::SampleRate, Field::BufferSize, Field::ShortcutPreset].into_iter().find(|f| *f as i32 == i)
}
}

Expand All @@ -46,6 +48,7 @@ pub enum Choice {
Device(Option<(String, String)>), // (id, name)
Rate(f64),
Buffer(u32),
Preset(&'static str),
}

#[derive(Debug)]
Expand Down Expand Up @@ -308,6 +311,9 @@ impl Controller {
let rate = self.current_rate();
BUFFER_SIZES.iter().map(|&n| (fmt_buffer(n, rate), Choice::Buffer(n))).collect()
}
Field::ShortcutPreset => {
crate::shortcut_presets::PRESETS.iter().map(|p| (p.name.to_string(), Choice::Preset(p.name))).collect()
}
}
}

Expand All @@ -318,6 +324,7 @@ impl Controller {
(Field::Input, Choice::Device(d)) => d.as_ref().map(|d| &d.0) == a.input.as_ref(),
(Field::SampleRate, Choice::Rate(r)) => (r - self.current_rate()).abs() < 0.5,
(Field::BufferSize, Choice::Buffer(n)) => *n == self.current_buffer(),
(Field::ShortcutPreset, Choice::Preset(p)) => *p == crate::shortcut_presets::find(&self.settings.prefs.shortcut_preset).name,
_ => false,
}
}
Expand Down Expand Up @@ -345,6 +352,10 @@ impl Controller {
if self.is_current(f, &c) {
return;
}
if let Choice::Preset(name) = c {
self.shortcuts_set_preset(name);
return;
}
let mut next = self.settings.prefs.clone();
let a = &mut next.audio;
match (f, c) {
Expand Down
Loading
Loading