feat(audio): Focusrite 2i2 stereo JACK config for 4CM
Adds: - AudioConfig.mode field: 'mono' (default) or 'stereo_4cm' - capture_channels / playback_channels properties for dynamic JACK -i/-o counts - FOCUSRITE_PROFILES dict with focusrite_2i2_3gen entry - AudioSystem.channel_mapping_help() static method - stereo_4cm port auto-connect wiring (4 cable method) - Systemd service content uses dynamic channel counts - Default config YAML includes 'mode: mono' - 11 new tests (31 total pass) - Focusrite 4CM wiring docs in docs/config-audio.md
This commit is contained in:
+65
-1
@@ -291,4 +291,68 @@ raspi-gpio get 18 19 20 21
|
||||
| 5V | — | Pins 2, 4 | Power | RPi → HAT |
|
||||
| GND | — | Pins 6, 9, 14, 25, 30, 34, 39 | Ground | — |
|
||||
|
||||
The I2S HAT uses a **stacking header** (2×20 female socket) to pass through all 40 GPIO pins so footswitches, LEDs, and display are accessible from the top of the HAT.
|
||||
The I2S HAT uses a **stacking header** (2×20 female socket) to pass through all 40 GPIO pins so footswitches, LEDs, and display are accessible from the top of the HAT.
|
||||
|
||||
---
|
||||
|
||||
## Focusrite Scarlett 2i2 — 4CM (Four Cable Method)
|
||||
|
||||
> **Interface:** Focusrite Scarlett 2i2 (3rd gen) USB audio interface
|
||||
> **Mode:** `stereo_4cm` in `audio.mode`
|
||||
> **Device:** `hw:1,0` (USB card index, may vary)
|
||||
|
||||
### Wiring
|
||||
|
||||
```
|
||||
Guitar ─────→ Input 1 (ADC channel 0) ─→ hw:1,0 capture_0 ─→ Pipeline input_0
|
||||
Amp FX Send ─→ Input 2 (ADC channel 1) ─→ hw:1,0 capture_1 ─→ Pipeline input_1
|
||||
|
||||
Pipeline output_0 (pre-amp) ─→ Output 1 (DAC channel 0) ─→ hw:1,0 playback_0 ─→ Amp Input (Send)
|
||||
Pipeline output_1 (post-amp) ─→ Output 2 (DAC channel 1) ─→ hw:1,0 playback_1 ─→ Amp FX Return
|
||||
```
|
||||
|
||||
### JACK Config
|
||||
|
||||
```bash
|
||||
# Kill PulseAudio first — it grabs USB audio devices
|
||||
pulseaudio --kill
|
||||
|
||||
# Start JACK at 48kHz/128 frames, 2 capture + 2 playback channels
|
||||
jackd -R -d alsa -d hw:1,0 -r 48000 -p 128 -n 3 -C 2 -P 2
|
||||
```
|
||||
|
||||
### Application Config
|
||||
|
||||
Set these fields in `~/.pedal/config.yaml`:
|
||||
|
||||
```yaml
|
||||
audio:
|
||||
hat_type: "focusrite_2i2_3gen"
|
||||
profile: "standard"
|
||||
mode: "stereo_4cm"
|
||||
input_device: "hw:1,0"
|
||||
output_device: "hw:1,0"
|
||||
jack_enabled: true
|
||||
auto_connect: true
|
||||
```
|
||||
|
||||
### Port Auto-Connect
|
||||
|
||||
When `auto_connect: true` and mode is `stereo_4cm`, the system creates these JACK connections:
|
||||
|
||||
| Source | Destination | Signal |
|
||||
|--------|-------------|--------|
|
||||
| `system:capture_1` | `fx_in:input_0` | Guitar → pre-amp DSP |
|
||||
| `system:capture_2` | `fx_in:input_1` | FX Send → post-amp DSP |
|
||||
| `fx_out:output_0` | `system:playback_1` | Pre-amp DSP → amp input |
|
||||
| `fx_out:output_1` | `system:playback_2` | Post-amp DSP → FX return |
|
||||
|
||||
### Channel Mapping Helper
|
||||
|
||||
At runtime, call `AudioSystem.channel_mapping_help("stereo_4cm")` to get these mappings as structured data.
|
||||
|
||||
### Notes
|
||||
|
||||
- The Focusrite 2i2 registers as ALSA card index **1** when the I2S HAT is card 0 (Linux arranges by driver probe order). If HDMI audio or other USB devices are present, the index may shift — use `aplay -l` / `arecord -l` to confirm.
|
||||
- 2-in/2-out at 24-bit/48kHz. JACK runs at 24-bit by default over ALSA.
|
||||
- At 48kHz/128 frames × 3 periods, round-trip latency is ~6-8ms — well within the 10ms target for real-time guitar DSP.
|
||||
Reference in New Issue
Block a user