fix: default mute feedback to the same note on all devices
M6.1: Remove APC USB identity and LED note restrictions. Note mute bindings with an output use their original channel and note with on=127/off=0. Alternate note/CC protocols and values remain explicit feedback configuration. Document the default and overrides. Tests: generic controller regression failed before implementation; cargo test -p fader-config --test editor (23 tests) and cargo test -p fader_master --lib feedback (2 tests) pass. Formatting, workspace all-target/all-feature check, strict Clippy, doctests and release build pass. Full workspace all-target/all-feature tests with --no-fail-fast exercise all targets: same four pre-existing Arch-profile fixture failures; all remaining tests pass. No hardware LED test performed.
This commit is contained in:
parent
7a0e8840ed
commit
1b32efec9f
|
|
@ -220,7 +220,7 @@ Persist a user surface ID plus matching hints: backend port identifier where usa
|
|||
|
||||
Keep bindings for absent surfaces. Re-enumerate ports on hotplug notifications or a bounded periodic scan, reconnect matching input/output ports independently, and resynchronize output from current observed state. Missing output does not disable input. Two devices may send the same channel/CC without collision because the surface ID is part of the key. [midir input/connection API](https://docs.rs/midir/latest/midir/struct.MidiInput.html), [udev discovery/monitoring](https://docs.rs/udev/latest/udev/)
|
||||
|
||||
Output capabilities are explicit: mute LED, value display, motorized fader, or none. Non-motorized devices may still receive supported LED/display feedback; never assume every surface has LEDs. Mixed mute uses a declared mixed indicator, otherwise LED on only for all-muted and the TUI shows mixed. Send full supported state on attach and incremental changes thereafter. Device feedback failures are separate from audio operation failures.
|
||||
Note-based mute bindings default to same-note feedback when an output port is configured. Other output capabilities (CC LEDs, value displays, motors) require explicit configuration. Mixed mute uses a declared mixed indicator, otherwise LED on only for all-muted and the TUI shows mixed. Send full supported state on attach and incremental changes thereafter. Device feedback failures are separate from audio operation failures.
|
||||
|
||||
The first implemented output slice is binding-level mute feedback. A binding
|
||||
with `feedback` sends its declared note or CC `on` value only for a uniformly
|
||||
|
|
@ -231,15 +231,13 @@ current refresh. Pending intent is never treated as confirmation.
|
|||
When learning a new mute binding, the editor may copy `on`/`off` values only
|
||||
from an unambiguous convention already used by feedback of the same message kind
|
||||
on that surface; the new feedback address follows the learned control. Missing
|
||||
or conflicting conventions remain explicitly unconfigured for unknown devices.
|
||||
The runtime resolves omitted feedback for the original APC Mini identified by
|
||||
USB `09e8:0028` and a configured output port: channel-1 mute note bindings on
|
||||
LED notes 0–71 and 82–89 use on=1/off=0. This covers the first learned binding
|
||||
in a fresh profile and existing profiles without feedback entries. Explicit
|
||||
feedback always wins; no defaults apply to CCs, other channels, Shift, unknown
|
||||
devices, or the MK2. Defaults are resolved without rewriting the user's TOML.
|
||||
The note map and LED values follow the original device's
|
||||
[captured protocol](https://github.com/TomasHubelbauer/akai-apc-mini).
|
||||
or conflicting conventions leave the explicit mapping absent. The runtime
|
||||
defaults every note-based mute binding to its input channel and note, with
|
||||
on=127/off=0, when its surface has an output port. No device identity or note
|
||||
whitelist is required. Explicit `feedback` settings override kind, channel,
|
||||
number, and on/off values for alternate device protocols. CC input bindings
|
||||
still require explicit feedback. Defaults are resolved without rewriting TOML
|
||||
and reflect confirmed mute state, not an immediate echo of every input event.
|
||||
|
||||
Non-motorized absolute controls default to pickup: after startup, external changes, another surface's move, or profile switch, wait until the physical value crosses or enters a configured tolerance around the observed target before sending volume commands. First input establishes position; an out-of-range external volume uses the nearest physical endpoint. Relative encoders do not need pickup. Reset pickup on disconnect/rebind. For motors, add touch-aware inhibition before enabling motor output; unsupported touch means no claimed touch protection.
|
||||
|
||||
|
|
|
|||
|
|
@ -472,10 +472,10 @@ impl Profile {
|
|||
&self.raw.bindings
|
||||
}
|
||||
|
||||
/// Resolves explicit feedback first, then supported device defaults.
|
||||
/// Resolves explicit feedback first, then same-note mute feedback.
|
||||
///
|
||||
/// The original APC Mini (USB 09e8:0028) has note LEDs on channel 1.
|
||||
/// Unknown devices, CCs, and controls without LEDs have no implicit output.
|
||||
/// Note mute bindings default to their input channel/note, with on=127 and
|
||||
/// off=0, whenever the surface has an output. Other protocols are explicit.
|
||||
/// This does not rewrite the document or override an explicit mapping.
|
||||
pub fn effective_feedback(&self, binding: &Binding) -> Option<Feedback> {
|
||||
if let Some(feedback) = binding.feedback() {
|
||||
|
|
@ -485,24 +485,17 @@ impl Profile {
|
|||
.surfaces()
|
||||
.iter()
|
||||
.find(|surface| surface.id() == binding.surface())?;
|
||||
let original_apc_mini = surface
|
||||
.usb_vendor_id()
|
||||
.is_some_and(|id| id.eq_ignore_ascii_case("09e8"))
|
||||
&& surface.usb_product_id() == Some("0028");
|
||||
if !original_apc_mini
|
||||
|| surface.output_port().is_none()
|
||||
if surface.output_port().is_none()
|
||||
|| binding.action() != Action::ToggleMute
|
||||
|| binding.message_kind() != MessageKind::Note
|
||||
|| binding.channel() != 1
|
||||
|| !matches!(binding.number(), 0..=71 | 82..=89)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(Feedback {
|
||||
kind: MessageKind::Note,
|
||||
channel: 1,
|
||||
channel: binding.channel(),
|
||||
number: binding.number(),
|
||||
on: 1,
|
||||
on: 127,
|
||||
off: 0,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,16 +171,16 @@ fn separator_presentation_round_trips_without_changing_order() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fresh_apc_feedback_defaults_are_device_and_control_scoped() {
|
||||
fn default_note_feedback_preserves_address_and_allows_configured_protocols() {
|
||||
let mut draft = ProfileDocument::empty("fresh").unwrap();
|
||||
draft
|
||||
.add_surface(
|
||||
"controller",
|
||||
"APC MINI",
|
||||
"APC MINI:APC MINI MIDI 1",
|
||||
Some("APC MINI:APC MINI MIDI 1"),
|
||||
Some("09e8"),
|
||||
Some("0028"),
|
||||
"Controller",
|
||||
"Controller MIDI",
|
||||
Some("Controller MIDI"),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
|
@ -190,11 +190,12 @@ fn fresh_apc_feedback_defaults_are_device_and_control_scoped() {
|
|||
(MessageKind::Note, 1, 0, true),
|
||||
(MessageKind::Note, 1, 64, true),
|
||||
(MessageKind::Note, 1, 71, true),
|
||||
(MessageKind::Note, 1, 72, false),
|
||||
(MessageKind::Note, 1, 72, true),
|
||||
(MessageKind::Note, 1, 82, true),
|
||||
(MessageKind::Note, 1, 89, true),
|
||||
(MessageKind::Note, 1, 98, false),
|
||||
(MessageKind::Note, 2, 64, false),
|
||||
(MessageKind::Note, 1, 98, true),
|
||||
(MessageKind::Note, 2, 64, true),
|
||||
(MessageKind::Note, 16, 127, true),
|
||||
(MessageKind::Cc, 1, 64, false),
|
||||
] {
|
||||
draft
|
||||
|
|
@ -218,7 +219,7 @@ fn fresh_apc_feedback_defaults_are_device_and_control_scoped() {
|
|||
feedback.on(),
|
||||
feedback.off()
|
||||
),
|
||||
(1, number, 1, 0)
|
||||
(channel, number, 127, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -234,9 +235,7 @@ fn fresh_apc_feedback_defaults_are_device_and_control_scoped() {
|
|||
.unwrap();
|
||||
let source = draft.source();
|
||||
for unsupported in [
|
||||
source.replace("0028", "0029"),
|
||||
source.replace("09e8", "1234"),
|
||||
source.replace("output_port = \"APC MINI:APC MINI MIDI 1\"", ""),
|
||||
source.replace("output_port = \"Controller MIDI\"", ""),
|
||||
source
|
||||
.replace("action = \"toggle_mute\"", "action = \"volume\"")
|
||||
.replace("kind = \"note\"", "kind = \"cc\"")
|
||||
|
|
@ -246,11 +245,15 @@ fn fresh_apc_feedback_defaults_are_device_and_control_scoped() {
|
|||
assert!(profile.effective_feedback(&profile.bindings()[0]).is_none());
|
||||
}
|
||||
let explicit = format!(
|
||||
"{source}\nfeedback = {{ kind = \"note\", channel = 1, number = 65, on = 3, off = 0 }}\n"
|
||||
"{source}\nfeedback = {{ kind = \"cc\", channel = 3, number = 65, on = 3, off = 2 }}\n"
|
||||
);
|
||||
let profile = fader_config::Profile::parse(&explicit).unwrap();
|
||||
let feedback = profile.effective_feedback(&profile.bindings()[0]).unwrap();
|
||||
assert_eq!((feedback.number(), feedback.on()), (65, 3));
|
||||
assert_eq!(
|
||||
(feedback.message_kind(), feedback.channel(), feedback.off()),
|
||||
(MessageKind::Cc, 3, 2)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -278,16 +278,24 @@ green value. Relearning a mute binding moves its feedback assignment to the new
|
|||
control. A new mute binding inherits `on`/`off` values only when existing
|
||||
feedback entries on the same surface and message kind establish one unambiguous
|
||||
convention; its feedback address follows the newly learned control. Conflicting
|
||||
or absent conventions leave feedback unset for unknown controllers.
|
||||
or absent conventions leave the explicit mapping unset.
|
||||
|
||||
The original APC Mini (`usb_vendor_id = "09e8"`, `usb_product_id = "0028"`)
|
||||
has built-in mute LED defaults when `output_port` is configured. Channel-1 note
|
||||
bindings for LEDs 0–71 and 82–89 use on=1/off=0, so learning the first mute button
|
||||
in a new configuration works without copying another binding. Existing missing
|
||||
mappings also use these defaults after Save or server restart. Explicit
|
||||
`feedback` overrides them. Shift, CC faders, other channels, and the APC Mini
|
||||
MK2 do not use these defaults. Other controllers still require their own
|
||||
feedback values and output-port details in the profile.
|
||||
By default, every note-based mute binding sends the same note back on the same
|
||||
channel: Note On velocity 127 for confirmed mute, and velocity 0 for unmuted or
|
||||
mixed state. This requires `output_port`, but no device identity or predefined
|
||||
note map. Missing mappings use these defaults after Save or server restart.
|
||||
This reports confirmed state; it does not echo each press/release immediately.
|
||||
|
||||
Configure alternate protocols per binding with `feedback`. For example, use
|
||||
on=1/off=0 for a device-specific LED value, or override the message address and
|
||||
kind for a controller whose feedback uses CC:
|
||||
|
||||
```toml
|
||||
feedback = { kind = "cc", channel = 3, number = 65, on = 3, off = 0 }
|
||||
```
|
||||
|
||||
Explicit mappings always take precedence. CC input bindings require an explicit
|
||||
feedback mapping; volume bindings do not automatically drive motors.
|
||||
|
||||
## Validation, migration, and Save
|
||||
|
||||
|
|
|
|||
|
|
@ -801,16 +801,16 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fresh_apc_profile_sends_feedback_without_an_existing_feedback_binding() {
|
||||
fn fresh_profile_sends_same_note_feedback_without_device_metadata() {
|
||||
let mut document = fader_config::ProfileDocument::empty("fresh").unwrap();
|
||||
document
|
||||
.add_surface(
|
||||
"controller",
|
||||
"APC MINI",
|
||||
"APC MINI:APC MINI MIDI 1",
|
||||
Some("APC MINI:APC MINI MIDI 1"),
|
||||
Some("09e8"),
|
||||
Some("0028"),
|
||||
"Controller",
|
||||
"Controller MIDI",
|
||||
Some("Controller MIDI"),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
|
@ -822,7 +822,7 @@ mod tests {
|
|||
"master-fader",
|
||||
fader_config::Action::ToggleMute,
|
||||
fader_config::MessageKind::Note,
|
||||
1,
|
||||
16,
|
||||
89,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -834,11 +834,11 @@ mod tests {
|
|||
let fader = FaderId::new("master-fader").unwrap();
|
||||
let attached = BTreeSet::from([surface.clone()]);
|
||||
assert!(feedback.plan(&BTreeMap::new(), &attached).is_empty());
|
||||
for (muted, value) in [(false, 0), (true, 1), (false, 0)] {
|
||||
for (muted, value) in [(false, 0), (true, 127), (false, 0)] {
|
||||
let confirmed = BTreeMap::from([(fader.clone(), muted)]);
|
||||
let messages = feedback.plan(&confirmed, &attached);
|
||||
assert_eq!(messages.len(), 1);
|
||||
assert_eq!(messages[0].bytes, [0x90, 89, value]);
|
||||
assert_eq!(messages[0].bytes, [0x9f, 89, value]);
|
||||
feedback.record_sent(&messages[0]);
|
||||
assert!(feedback.plan(&confirmed, &attached).is_empty());
|
||||
feedback.invalidate_surface(&surface);
|
||||
|
|
|
|||
10
task.md
10
task.md
|
|
@ -227,7 +227,7 @@ and no-default-feature checks/tests pass.
|
|||
|
||||
Dependencies: M4, M5.
|
||||
|
||||
- [x] **M6.0 Confirmed mute lights:** opt-in note/CC feedback follows confirmed
|
||||
- [x] **M6.0 Confirmed mute lights:** default same-note or configured note/CC feedback follows confirmed
|
||||
uniform mute state, treats mixed as off, does not guess for offline targets,
|
||||
deduplicates successful writes, and resynchronizes after independent output
|
||||
reconnect. Output failures remain surface-local and do not disable MIDI
|
||||
|
|
@ -235,10 +235,12 @@ Dependencies: M4, M5.
|
|||
deduplication, unavailable state, surface scoping, and reconnect refresh;
|
||||
physical LED verification remains part of M6.1.
|
||||
- [ ] **M6.1 Output profiles:** mute LED/value/motor capabilities, output pairing, mixed-state policy. Tests: confirmed/internal and external changes reach all bound surfaces; outputless surfaces receive no unsupported message; pending/failed writes never produce false success feedback.
|
||||
Original APC Mini USB identity now supplies missing mute LED defaults for
|
||||
supported notes, including the first learned binding in an empty profile.
|
||||
All note mute bindings now default to same-channel/same-note on=127/off=0
|
||||
with an output port, including the first learned binding in an empty profile.
|
||||
Device-specific protocols live in explicit feedback configuration rather than
|
||||
USB-identity branches or note whitelists.
|
||||
Tests cover save/reload, on/off, reconnect/deduplication, explicit overrides,
|
||||
and exclusion of outputless/unknown devices and unsupported controls.
|
||||
all channels/notes, and exclusion of outputless surfaces and volume controls.
|
||||
Other device profiles and physical hardware verification remain outstanding.
|
||||
- [ ] **M6.2 Feedback lifecycle:** attach snapshot, rate limits, deduplication, separate audio/output errors, documented device-specific echo suppression. Tests: feedback echoed as input cannot oscillate volume/mute; rapid updates converge; suppression does not swallow a genuine tested input sequence.
|
||||
- [ ] **M6.3 Extended controllers:** 14-bit CC/pitch bend, explicit relative encoder modes, motor output and touch handling for declared profiles. Tests: endpoints/byte-pair ordering, relative increments, no motor push while touched, and non-motorized profile never receives motor commands. Hardware-verify every shipped specialized profile.
|
||||
|
|
|
|||
Loading…
Reference in New Issue