feat: Footswitch Modes — Stomp/Preset/Snapshot/Combo with scribble strips

Implements multi-mode footswitch system for the Helix Stadium-inspired pedal UI:

- Footswitch mode context provider with 4 modes: stomp, preset, snapshot, combo
- ModeSelector in status bar (collapsed cycling mode for mobile)
- Stomp mode: footswitches toggle individual blocks on/off, scribble strips show block name + status
- Preset mode: footswitches show Bank Up/Down + preset selection, scribble strips show preset name + number
- Snapshot mode: footswitches recall 8 snapshots, scribble strips show snapshot name
- Combo mode: first 4 stomp + bank nav + preset select + global bypass
- ScribbleStrip LCD component with LED indicator and double-tap support
- Double-tap gesture hook for secondary actions (tuner, snapshot save, etc.)
- FootswitchBar container with 8 capacitive-touch footswitch buttons and LED rings
- usePedalState hook (WebSocket + API polling, ported from frontend-react/App.jsx)
- Dark pedal theme CSS (Helix-inspired) with responsive mobile layout
- Full App.tsx rewrite with status bar, footswitch bar, tab bar, and all screens
This commit is contained in:
2026-06-12 19:22:50 -04:00
parent b6dff3c0f3
commit 214f3c13d7
13 changed files with 2389 additions and 417 deletions
+355
View File
@@ -0,0 +1,355 @@
/**
* FootswitchMode Context — provides the current mode and mode switching
* to all footswitch components.
*/
import { createContext, useContext, useState, useCallback, type ReactNode } from 'react';
import type { FootswitchMode, ScribbleStripData, PedalState, PedalBlock } from '../types';
import { apiPost, activatePreset } from "./hooks/usePedalState";
// ── Context Shape ─────────────────────────────────────────────
interface FootswitchModeContextValue {
mode: FootswitchMode;
setMode: (mode: FootswitchMode) => void;
/** Scribble strip data for each footswitch position (07) */
scribbleData: ScribbleStripData[];
/** Handle a footswitch press at a given position */
handleFootswitch: (index: number) => void;
/** Handle secondary action (double-tap / long-press) at a given position */
handleSecondary: (index: number) => void;
/** Current banks/presets for preset mode */
currentBankIndex: number;
currentPresetIndex: number;
setBank: (bank: number) => void;
setPreset: (preset: number) => void;
/** Whether the preset has been modified */
dirty: boolean;
}
const FootswitchModeContext = createContext<FootswitchModeContextValue | null>(null);
// ── Mode-specific scribble strip generators ───────────────────
function stompScribbles(
blocks: PedalBlock[],
_state: PedalState | null,
): ScribbleStripData[] {
const items: ScribbleStripData[] = [];
for (let i = 0; i < 8; i++) {
const block = blocks[i];
if (block) {
items.push({
key: `stomp-${block.id}`,
label: block.title.length > 6 ? block.title.slice(0, 6) : block.title,
sublabel: block.bypassed ? 'BYP' : 'ON',
color: block.bypassed ? 'off' : 'green',
active: !block.bypassed,
bypassed: block.bypassed,
});
} else {
items.push({
key: `stomp-empty-${i}`,
label: '—',
sublabel: '',
color: 'off',
active: false,
bypassed: false,
});
}
}
return items;
}
function presetScribbles(
state: PedalState | null,
bankIndex: number,
bankNames: string[],
): ScribbleStripData[] {
const items: ScribbleStripData[] = [];
// FS 0-1: Bank navigation
items.push({
key: 'bank-down',
label: 'BANK',
sublabel: bankIndex > 0 ? `${bankNames[bankIndex - 1] || ''}` : '—',
color: 'blue',
active: bankIndex > 0,
});
items.push({
key: 'bank-up',
label: 'BANK',
sublabel: bankIndex < bankNames.length - 1 ? `${bankNames[bankIndex + 1] || '+'}` : '—',
color: 'blue',
active: bankIndex < bankNames.length - 1,
});
// FS 2-7: Preset slots
for (let i = 0; i < 6; i++) {
const presetIdx = i;
const isActive = state?.current_preset?.program === presetIdx &&
state?.current_preset?.bank === bankIndex;
items.push({
key: `preset-${presetIdx}`,
label: String(presetIdx + 1),
sublabel: state?.current_preset && state.current_preset.program === presetIdx
? state.current_preset.name : '',
color: isActive ? 'green' : 'off',
active: isActive,
});
}
return items;
}
function snapshotScribbles(
snapshots: { name: string; active: boolean }[],
): ScribbleStripData[] {
const items: ScribbleStripData[] = [];
for (let i = 0; i < 8; i++) {
const snap = snapshots[i];
if (snap) {
items.push({
key: `snapshot-${i}`,
label: snap.name.length > 6 ? snap.name.slice(0, 6) : (snap.name || `Snap ${i + 1}`),
sublabel: snap.active ? 'ACTIVE' : '',
color: snap.active ? 'amber' : 'off',
active: snap.active,
});
} else {
items.push({
key: `snapshot-empty-${i}`,
label: `Snap ${i + 1}`,
sublabel: '',
color: 'off',
active: false,
});
}
}
return items;
}
function comboScribbles(
blocks: PedalBlock[],
state: PedalState | null,
bankNames: string[],
bankIndex: number,
): ScribbleStripData[] {
// Combo = first 4 stomp + bank/preset info on last 4
const stomp = stompScribbles(blocks.slice(0, 4), state);
// FS 4: bank down, FS 5: bank up, FS 6-7: preset select
return [
...stomp.slice(0, 4),
{
key: 'bank-down',
label: 'BANK',
sublabel: bankIndex > 0 ? '▼' : '—',
color: 'blue',
active: bankIndex > 0,
},
{
key: 'bank-up',
label: 'BANK',
sublabel: bankIndex < bankNames.length - 1 ? '▲' : '—',
color: 'blue',
active: bankIndex < bankNames.length - 1,
},
{
key: 'preset-select',
label: state?.current_preset?.name?.slice(0, 6) || '—',
sublabel: state?.current_preset ? `B${bankIndex + 1}` : '',
color: 'amber',
active: true,
},
{
key: 'global-bypass',
label: 'BYP',
sublabel: state?.bypass ? 'ON' : 'OFF',
color: state?.bypass ? 'red' : 'off',
active: !!state?.bypass,
},
];
}
// ── Provider ──────────────────────────────────────────────────
interface FootswitchModeProviderProps {
children: ReactNode;
state: PedalState | null;
connected: boolean;
refresh: () => void;
blocks: PedalBlock[];
bankNames: string[];
/** Current snapshot definitions */
snapshots: { name: string; active: boolean }[];
/** Called when a block toggle needs to happen */
onToggleBlock?: (blockId: number, bypassed: boolean) => void;
}
export function FootswitchModeProvider({
children,
state,
connected,
refresh,
blocks,
bankNames,
snapshots,
onToggleBlock,
}: FootswitchModeProviderProps) {
const [mode, setMode] = useState<FootswitchMode>('stomp');
const [currentBankIndex, setCurrentBankIndex] = useState(0);
const [currentPresetIndex, setCurrentPresetIndex] = useState(0);
const [dirty, setDirty] = useState(false);
// Generate scribble data based on mode
let scribbleData: ScribbleStripData[];
switch (mode) {
case 'stomp':
scribbleData = stompScribbles(blocks, state);
break;
case 'preset':
scribbleData = presetScribbles(state, currentBankIndex, bankNames);
break;
case 'snapshot':
scribbleData = snapshotScribbles(snapshots);
break;
case 'combo':
scribbleData = comboScribbles(blocks, state, bankNames, currentBankIndex);
break;
default:
scribbleData = stompScribbles(blocks, state);
}
const handleFootswitch = useCallback((index: number) => {
switch (mode) {
case 'stomp': {
const block = blocks[index];
if (block && onToggleBlock) {
onToggleBlock(block.id, !block.bypassed);
}
break;
}
case 'preset': {
// FS 0 = bank down, FS 1 = bank up, FS 2-7 = presets
if (index === 0) {
setCurrentBankIndex(prev => Math.max(0, prev - 1));
} else if (index === 1) {
setCurrentBankIndex(prev => Math.min(bankNames.length - 1, prev + 1));
} else {
const presetIndex = index - 2;
if (connected) {
activatePreset(currentBankIndex, presetIndex).then(() => refresh());
setCurrentPresetIndex(presetIndex);
}
}
break;
}
case 'snapshot': {
// Recall snapshot at index
if (connected) {
apiPost(`/api/snapshots/${index}/recall`).catch(() => {});
}
break;
}
case 'combo': {
// FS 0-3 = stomp toggles, FS 4 = bank down, FS 5 = bank up,
// FS 6 = open preset browser, FS 7 = global bypass
if (index < 4) {
const block = blocks[index];
if (block && onToggleBlock) {
onToggleBlock(block.id, !block.bypassed);
}
} else if (index === 4) {
setCurrentBankIndex(prev => Math.max(0, prev - 1));
} else if (index === 5) {
setCurrentBankIndex(prev => Math.min(bankNames.length - 1, prev + 1));
} else if (index === 6) {
setMode('preset');
} else if (index === 7) {
if (connected) {
apiPost('/api/bypass', { bypass: !state?.bypass }).catch(() => {});
}
}
break;
}
}
}, [mode, blocks, onToggleBlock, connected, currentBankIndex, bankNames, state, refresh]);
const handleSecondary = useCallback((index: number) => {
// Double-tap / long-press secondary actions per mode
switch (mode) {
case 'stomp': {
// Secondary: toggle tuner on FS 7 (last footswitch), or reset block params
if (index === 7 && connected) {
apiPost('/api/tuner', { enabled: !state?.tuner_enabled }).catch(() => {});
}
break;
}
case 'preset': {
// Secondary on bank switches: jump to first/last bank
if (index === 0) {
setCurrentBankIndex(0);
} else if (index === 1) {
setCurrentBankIndex(bankNames.length - 1);
}
break;
}
case 'snapshot': {
// Secondary: save current state to snapshot
if (connected) {
apiPost(`/api/snapshots/${index}/save`).catch(() => {});
}
break;
}
case 'combo': {
// Secondary on stomp blocks: edit block params (would open param panel)
// Secondary on bypass: enter tuner mode
if (index === 7 && connected) {
apiPost('/api/tuner', { enabled: !state?.tuner_enabled }).catch(() => {});
}
break;
}
}
}, [mode, state, connected, bankNames]);
const setBank = useCallback((bank: number) => {
setCurrentBankIndex(bank);
}, []);
const setPreset = useCallback((preset: number) => {
setCurrentPresetIndex(preset);
if (connected) {
activatePreset(currentBankIndex, preset).then(() => refresh());
}
}, [connected, currentBankIndex, refresh]);
const value: FootswitchModeContextValue = {
mode,
setMode,
scribbleData,
handleFootswitch,
handleSecondary,
currentBankIndex,
currentPresetIndex,
setBank,
setPreset,
dirty,
};
return (
<FootswitchModeContext.Provider value={value}>
{children}
</FootswitchModeContext.Provider>
);
}
// ── Consumer Hook ─────────────────────────────────────────────
export function useFootswitchMode(): FootswitchModeContextValue {
const ctx = useContext(FootswitchModeContext);
if (!ctx) {
throw new Error('useFootswitchMode must be used within a FootswitchModeProvider');
}
return ctx;
}
+41
View File
@@ -0,0 +1,41 @@
/**
* FootswitchBar — the bottom bar of 8 footswitches with scribble strip LCDs.
*
* Renders the appropriate scribble data per mode (handled via FootswitchModeContext).
* Each footswitch supports single-tap (primary action) and double-tap (secondary).
*/
import { useFootswitchMode } from '../FootswitchModeContext';
import { ScribbleStrip } from './ScribbleStrip';
export function FootswitchBar() {
const { scribbleData, handleFootswitch, handleSecondary } = useFootswitchMode();
return (
<div className="footswitch-bar">
{scribbleData.map((sd, i) => (
<div key={sd.key} className="footswitch-slot">
{/* Scribble strip LCD above the switch */}
<ScribbleStrip
data={sd}
onPress={() => handleFootswitch(i)}
onSecondary={() => handleSecondary(i)}
/>
{/* Footswitch button */}
<div
className={`footswitch-btn ${sd.active ? 'footswitch-btn-active' : ''} ${sd.bypassed ? 'footswitch-btn-bypassed' : ''}`}
onClick={() => handleFootswitch(i)}
onContextMenu={(e) => { e.preventDefault(); handleSecondary(i); }}
style={{
'--fs-color': sd.color,
} as React.CSSProperties}
>
<div className="footswitch-ring" />
<div className="footswitch-cap" />
</div>
</div>
))}
</div>
);
}
+56
View File
@@ -0,0 +1,56 @@
/**
* ModeSelector — mode switch buttons shown in the status bar.
* Lets the user cycle between Stomp, Preset, Snapshot, and Combo modes.
*/
import { useFootswitchMode } from '../FootswitchModeContext';
import type { FootswitchMode } from '../types';
import { FOOTSWITCH_MODE_LABELS } from '../types';
const MODES: FootswitchMode[] = ['stomp', 'preset', 'snapshot', 'combo'];
const MODE_ICONS: Record<FootswitchMode, string> = {
stomp: '◉',
preset: '☆',
snapshot: '◆',
combo: '◈',
transport: '▶',
};
interface ModeSelectorProps {
collapsed?: boolean;
}
export function ModeSelector({ collapsed = false }: ModeSelectorProps) {
const { mode, setMode } = useFootswitchMode();
if (collapsed) {
// Compact: just a single click target that cycles
const nextIdx = (MODES.indexOf(mode) + 1) % MODES.length;
return (
<div
className="mode-selector mode-selector-collapsed"
onClick={() => setMode(MODES[nextIdx])}
title={`Mode: ${FOOTSWITCH_MODE_LABELS[mode]} — tap to switch`}
>
<span className="mode-icon">{MODE_ICONS[mode]}</span>
<span className="mode-label">{FOOTSWITCH_MODE_LABELS[mode]}</span>
</div>
);
}
return (
<div className="mode-selector">
{MODES.map(m => (
<button
key={m}
className={`mode-btn ${mode === m ? 'mode-btn-active' : ''}`}
onClick={() => setMode(m)}
title={FOOTSWITCH_MODE_LABELS[m]}
>
<span className="mode-btn-icon">{MODE_ICONS[m]}</span>
<span className="mode-btn-label">{FOOTSWITCH_MODE_LABELS[m]}</span>
</button>
))}
</div>
);
}
+60
View File
@@ -0,0 +1,60 @@
/**
* ScribbleStrip — the LCD-like label display above each footswitch.
*
* Shows block/preset/snapshot name and status, mimicking the
* Helix / Line 6 scribble strip LCDs.
*/
import type { ScribbleStripData, ScribbleColor } from '../types';
import { SCRIBBLE_COLORS } from '../types';
import { useDoubleTap } from '../hooks/useDoubleTap';
interface ScribbleStripProps {
data: ScribbleStripData;
onPress: () => void;
onSecondary: () => void;
}
export function ScribbleStrip({ data, onPress, onSecondary }: ScribbleStripProps) {
const { handleTap } = useDoubleTap({
onSingleTap: onPress,
onDoubleTap: onSecondary,
});
const color = SCRIBBLE_COLORS[data.color ?? 'off'];
const isActive = data.active ?? false;
const isBypassed = data.bypassed ?? false;
return (
<div
className="scribble-strip"
data-active={isActive}
data-bypassed={isBypassed}
onClick={handleTap}
style={{
'--scribble-color': color,
} as React.CSSProperties}
>
{/* LED indicator */}
<div
className="scribble-led"
style={{
background: color,
boxShadow: isActive ? `0 0 6px ${color}` : 'none',
opacity: isActive ? 1 : 0.25,
}}
/>
{/* Label area — LCD-style */}
<div className="scribble-label-wrap">
<span className="scribble-label">{data.label || '—'}</span>
{data.sublabel && (
<span className="scribble-sublabel">{data.sublabel}</span>
)}
</div>
{/* Icon (optional) */}
{data.icon && <span className="scribble-icon">{data.icon}</span>}
</div>
);
}
+82
View File
@@ -0,0 +1,82 @@
/**
* Double-tap gesture hook for footswitch capacitive touch / secondary actions.
*
* Detects two rapid taps within a configurable threshold and fires
* onDoubleTap. Single taps fire onSingleTap after a short debounce.
*/
import { useRef, useCallback } from 'react';
interface UseDoubleTapOptions {
/** Max ms between taps to count as double-tap (default: 300) */
threshold?: number;
/** Called on single tap after debounce */
onSingleTap?: () => void;
/** Called on double tap */
onDoubleTap?: () => void;
}
export function useDoubleTap({
threshold = 300,
onSingleTap,
onDoubleTap,
}: UseDoubleTapOptions) {
const lastTapRef = useRef(0);
const singleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const handleTap = useCallback(() => {
const now = Date.now();
const sinceLast = now - lastTapRef.current;
if (sinceLast < threshold) {
// Double tap detected
if (singleTimerRef.current) {
clearTimeout(singleTimerRef.current);
singleTimerRef.current = null;
}
lastTapRef.current = 0;
onDoubleTap?.();
} else {
// Potential single tap — wait for double-tap window to close
lastTapRef.current = now;
if (singleTimerRef.current) {
clearTimeout(singleTimerRef.current);
}
singleTimerRef.current = setTimeout(() => {
onSingleTap?.();
singleTimerRef.current = null;
}, threshold);
}
}, [threshold, onSingleTap, onDoubleTap]);
return { handleTap };
}
/**
* Hook for long-press gesture detection.
* Fires onLongPress after `duration` ms of continuous hold.
*/
export function useLongPress({
duration = 500,
onLongPress,
}: {
duration?: number;
onLongPress?: () => void;
}) {
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const handleStart = useCallback(() => {
timerRef.current = setTimeout(() => {
onLongPress?.();
}, duration);
}, [duration, onLongPress]);
const handleEnd = useCallback(() => {
if (timerRef.current) {
clearTimeout(timerRef.current);
timerRef.current = null;
}
}, []);
return { handleStart, handleEnd };
}
+155
View File
@@ -0,0 +1,155 @@
/**
* Pi Multi-FX Pedal — State Hook
*
* API helpers, WebSocket real-time updates, and pedal state management.
* Ported and organized from frontend-react/App.jsx.
*/
import { useState, useRef, useEffect, useCallback } from 'react';
import type { PedalState, PresetListResponse } from '../types';
// ── API Base ──────────────────────────────────────────────────
const API = window.location.origin;
const WS_URL = API.replace(/^http/, 'ws') + '/ws';
// ── API Helpers ───────────────────────────────────────────────
export async function apiGet<T>(path: string): Promise<T> {
const r = await fetch(`${API}${path}`);
if (!r.ok) throw new Error(`${path} => ${r.status}`);
return r.json();
}
export async function apiPost<T>(path: string, data?: unknown): Promise<T> {
const r = await fetch(`${API}${path}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: data != null ? JSON.stringify(data) : undefined,
});
if (!r.ok) throw new Error(`${path} => ${r.status}`);
return r.json();
}
export async function apiPut<T>(path: string, data: unknown): Promise<T> {
const r = await fetch(`${API}${path}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!r.ok) throw new Error(`${path} => ${r.status}`);
return r.json();
}
export async function apiDelete<T>(path: string): Promise<T> {
const r = await fetch(`${API}${path}`, { method: 'DELETE' });
if (!r.ok) throw new Error(`${path} => ${r.status}`);
return r.json();
}
export async function apiUpload<T>(path: string, file: File): Promise<T> {
const fd = new FormData();
fd.append('file', file);
const r = await fetch(`${API}${path}`, { method: 'POST', body: fd });
if (!r.ok) throw new Error(`${path} => ${r.status}`);
return r.json();
}
// ── usePedalState Hook ────────────────────────────────────────
export interface PedalStateResult {
state: PedalState | null;
connected: boolean;
refresh: () => void;
}
export function usePedalState(): PedalStateResult {
const [state, setState] = useState<PedalState | null>(null);
const [connected, setConnected] = useState(false);
const wsRef = useRef<WebSocket | null>(null);
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
useEffect(() => {
// Fetch initial state
apiGet<PedalState>('/api/state')
.then(s => { setState(s); setConnected(true); })
.catch(() => { setConnected(false); });
// WebSocket for real-time updates
let reconnectTimer: ReturnType<typeof setTimeout>;
function connect() {
try {
const ws = new WebSocket(WS_URL);
ws.onmessage = (e) => {
try {
const msg = JSON.parse(e.data);
if (msg.type === 'connected' || msg.type === 'state') {
setState(msg.state);
setConnected(true);
}
if (msg.type === 'preset_changed' && msg.state) setState(msg.state);
if (msg.type === 'bypass_changed') {
setState(prev => prev ? { ...prev, bypass: msg.bypass } : prev);
}
if (msg.type === 'tuner_changed') {
setState(prev => prev ? { ...prev, tuner_enabled: msg.tuner_enabled } : prev);
}
if (msg.type === 'routing_changed') {
setState(prev => prev ? {
...prev,
routing_mode: msg.routing_mode,
routing_breakpoint: msg.routing_breakpoint,
} : prev);
}
if (msg.type === 'model_loaded' || msg.type === 'ir_loaded') {
apiGet<PedalState>('/api/state').then(s => setState(s));
}
} catch {
// ignore parse errors
}
};
ws.onclose = () => {
setConnected(false);
reconnectTimer = setTimeout(connect, 3000);
};
ws.onerror = () => ws.close();
wsRef.current = ws;
} catch {
reconnectTimer = setTimeout(connect, 3000);
}
}
connect();
// Polling fallback every 5s
pollRef.current = setInterval(() => {
apiGet<PedalState>('/api/state')
.then(s => { setState(s); setConnected(true); })
.catch(() => {});
}, 5000);
return () => {
if (pollRef.current) clearInterval(pollRef.current);
clearTimeout(reconnectTimer);
if (wsRef.current) wsRef.current.close();
};
}, []);
const refresh = useCallback(() => {
apiGet<PedalState>('/api/state')
.then(s => { setState(s); setConnected(true); })
.catch(() => {});
}, []);
return { state, connected, refresh };
}
// ── Preset helpers ────────────────────────────────────────────
export async function fetchPresets(): Promise<PresetListResponse> {
return apiGet<PresetListResponse>('/api/presets');
}
export async function activatePreset(bank: number, program: number): Promise<void> {
await apiPost(`/api/presets/${bank}/${program}/activate`);
}
+447
View File
@@ -0,0 +1,447 @@
/* ══════════════════════════════════════════════════════════════
Pi Multi-FX Pedal — Styles
Dark pedal theme with Helix-inspired footswitch bar
══════════════════════════════════════════════════════════════ */
/* ── Design Tokens ─────────────────────────────────────────── */
:root {
--pedal-bg: #0A0A0C;
--pedal-panel: #141418;
--pedal-surface: #1C1C22;
--pedal-border: #2A2A32;
--pedal-border-light: #3A3A48;
--pedal-amber: #E8A030;
--pedal-amber-dim: #7A5218;
--pedal-blue: #3A7BA8;
--pedal-blue-dim: #1E4060;
--pedal-green: #3AB87A;
--pedal-green-dim: #1E6040;
--pedal-red: #C84040;
--pedal-red-dim: #602020;
--pedal-purple: #9B59B6;
--pedal-cyan: #1ABC9C;
--pedal-text: #F0EDE6;
--pedal-text-sec: #8888A0;
--pedal-text-dim: #444458;
--pedal-radius: 0.625rem;
--pedal-fs-height: 80px;
}
/* ── Status Bar ────────────────────────────────────────────── */
.pedal-statusbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 6px 12px 4px;
background: var(--pedal-panel);
border-bottom: 1px solid var(--pedal-border);
flex-shrink: 0;
gap: 8px;
min-height: 32px;
}
.pedal-statusbar-left,
.pedal-statusbar-right {
display: flex;
align-items: center;
gap: 6px;
}
.pedal-statusbar-mid {
display: flex;
align-items: center;
gap: 4px;
flex: 1;
justify-content: center;
}
.pedal-brand {
font-family: 'JetBrains Mono', 'SF Mono', monospace;
font-size: 9px;
color: var(--pedal-text-sec);
letter-spacing: 0.08em;
text-transform: uppercase;
}
/* ── Mode Selector ─────────────────────────────────────────── */
.mode-selector {
display: flex;
gap: 2px;
background: var(--pedal-surface);
border-radius: 6px;
border: 1px solid var(--pedal-border);
overflow: hidden;
}
.mode-selector-collapsed {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 8px;
cursor: pointer;
border-radius: 5px;
background: var(--pedal-surface);
border: 1px solid var(--pedal-border);
transition: background 0.15s;
}
.mode-selector-collapsed:hover {
background: var(--pedal-border);
}
.mode-btn {
flex: 1;
display: flex;
align-items: center;
gap: 3px;
padding: 5px 7px;
font-size: 10px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
background: none;
border: none;
color: var(--pedal-text-dim);
cursor: pointer;
transition: all 0.12s;
white-space: nowrap;
}
.mode-btn:hover {
color: var(--pedal-text-sec);
}
.mode-btn-active {
background: var(--pedal-amber-dim);
color: var(--pedal-amber) !important;
}
.mode-btn-icon {
font-size: 11px;
}
.mode-icon {
font-size: 12px;
color: var(--pedal-amber);
}
.mode-label {
font-size: 10px;
color: var(--pedal-text-sec);
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
}
/* ── Badge chips in status bar ─────────────────────────────── */
.pedal-badge {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 1px 5px;
border-radius: 3px;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.pedal-badge-amber {
background: rgba(232, 160, 48, 0.2);
color: var(--pedal-amber);
}
.pedal-badge-green {
background: rgba(58, 184, 122, 0.2);
color: var(--pedal-green);
}
.pedal-badge-red {
background: rgba(200, 64, 64, 0.2);
color: var(--pedal-red);
}
.pedal-badge-blue {
background: rgba(58, 123, 168, 0.2);
color: var(--pedal-blue);
}
/* ── Status LED dot ────────────────────────────────────────── */
.pedal-led-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
/* ── Footswitch Bar ────────────────────────────────────────── */
.footswitch-bar {
display: flex;
gap: 3px;
padding: 4px 6px 6px;
background: var(--pedal-panel);
border-top: 1px solid var(--pedal-border);
flex-shrink: 0;
justify-content: center;
}
.footswitch-slot {
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
flex: 1;
min-width: 0;
max-width: 56px;
}
/* ── Scribble Strip ────────────────────────────────────────── */
.scribble-strip {
display: flex;
flex-direction: column;
align-items: center;
gap: 1px;
width: 100%;
padding: 3px 2px;
background: #0D0D10;
border: 1px solid var(--pedal-border);
border-radius: 3px;
cursor: pointer;
transition: border-color 0.15s;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.scribble-strip[data-active="true"] {
border-color: var(--scribble-color, var(--pedal-amber));
}
.scribble-strip[data-bypassed="true"] {
opacity: 0.5;
}
.scribble-led {
width: 4px;
height: 4px;
border-radius: 50%;
flex-shrink: 0;
transition: opacity 0.15s;
margin-bottom: 1px;
}
.scribble-label-wrap {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
min-height: 22px;
justify-content: center;
}
.scribble-label {
font-family: 'JetBrains Mono', 'SF Mono', monospace;
font-size: 8px;
font-weight: 600;
color: var(--pedal-text);
text-align: center;
line-height: 1.1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
.scribble-sublabel {
font-family: 'JetBrains Mono', 'SF Mono', monospace;
font-size: 6.5px;
color: var(--scribble-color, var(--pedal-text-sec));
text-align: center;
line-height: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.scribble-icon {
font-size: 9px;
line-height: 1;
}
/* ── Footswitch Button ─────────────────────────────────────── */
.footswitch-btn {
position: relative;
width: 42px;
height: 42px;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
transition: transform 0.08s;
}
.footswitch-btn:active {
transform: scale(0.93);
}
.footswitch-ring {
position: absolute;
inset: 0;
border-radius: 50%;
border: 2.5px solid var(--pedal-border);
background: radial-gradient(circle at 40% 35%, #2A2A38, #141418);
transition: border-color 0.12s, box-shadow 0.12s;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.footswitch-btn-active .footswitch-ring {
border-color: var(--fs-color, var(--pedal-green));
box-shadow:
0 2px 6px rgba(0, 0, 0, 0.5),
inset 0 1px 0 rgba(255, 255, 255, 0.06),
0 0 8px var(--fs-color, var(--pedal-green));
}
.footswitch-btn-bypassed .footswitch-ring {
opacity: 0.5;
border-color: var(--pedal-text-dim);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.footswitch-cap {
position: absolute;
inset: 8px;
border-radius: 50%;
background: radial-gradient(circle at 38% 32%, #3A3A48, #1A1A22);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.08),
inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.footswitch-cap::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 8px;
height: 8px;
border-radius: 50%;
background: radial-gradient(circle at 50% 35%, #5A5A6A, #2A2A38);
}
/* ── Tab bar (existing, aligned) ───────────────────────────── */
.pedal-tabbar {
display: flex;
background: var(--pedal-panel);
border-top: 1px solid var(--pedal-border);
flex-shrink: 0;
}
.pedal-tab {
flex: 1;
padding: 8px 4px 6px;
font-size: 9px;
font-weight: 500;
letter-spacing: 0.04em;
text-align: center;
text-transform: uppercase;
color: var(--pedal-text-dim);
cursor: pointer;
border-top: 2px solid transparent;
transition: all 0.12s;
user-select: none;
}
.pedal-tab-active {
color: var(--pedal-amber);
border-top-color: var(--pedal-amber);
}
.pedal-tab-icon {
font-size: 13px;
display: block;
margin-bottom: 1px;
}
/* ── Screen Area ───────────────────────────────────────────── */
.pedal-screen {
flex: 1;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 420px) {
.footswitch-bar {
padding: 3px 3px 5px;
gap: 2px;
}
.footswitch-slot {
max-width: 48px;
}
.footswitch-btn {
width: 36px;
height: 36px;
}
.footswitch-cap {
inset: 6px;
}
.footswitch-cap::after {
width: 6px;
height: 6px;
}
.scribble-label {
font-size: 7px;
}
.mode-btn {
padding: 3px 5px;
font-size: 9px;
}
.mode-btn-label {
display: none;
}
}
/* ── Pedal Shell ───────────────────────────────────────────── */
.pedal-shell {
width: 100%;
max-width: 440px;
margin: 0 auto;
height: 100dvh;
display: flex;
flex-direction: column;
background: var(--pedal-bg);
color: var(--pedal-text);
overflow: hidden;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
@media (min-width: 441px) {
.pedal-shell {
border-left: 1px solid var(--pedal-border);
border-right: 1px solid var(--pedal-border);
}
}
+164
View File
@@ -0,0 +1,164 @@
/**
* Pi Multi-FX Pedal — Type Definitions
*
* Core types for footswitch modes, pedal state, and UI components.
*/
// ── Footswitch Modes ──────────────────────────────────────────
export type FootswitchMode = 'stomp' | 'preset' | 'snapshot' | 'combo' | 'transport';
export const FOOTSWITCH_MODES: FootswitchMode[] = ['stomp', 'preset', 'snapshot', 'combo'];
export const FOOTSWITCH_MODE_LABELS: Record<FootswitchMode, string> = {
stomp: 'Stomp',
preset: 'Preset',
snapshot: 'Snapshot',
combo: 'Combo',
transport: 'Transport',
};
// ── Scribble Strip ────────────────────────────────────────────
export interface ScribbleStripData {
/** Main label shown on the strip (uppercase track name) */
label: string;
/** Optional secondary line below the label */
sublabel?: string;
/** LED color for the footswitch ring / indicator */
color?: ScribbleColor;
/** Whether the footswitch is active/enabled */
active?: boolean;
/** Whether the block is bypassed (stomp mode) */
bypassed?: boolean;
/** Unique key for this footswitch */
key: string;
/** Optional icon */
icon?: string;
}
export type ScribbleColor =
| 'amber'
| 'green'
| 'red'
| 'blue'
| 'purple'
| 'cyan'
| 'white'
| 'off';
export const SCRIBBLE_COLORS: Record<ScribbleColor, string> = {
amber: '#E8A030',
green: '#3AB87A',
red: '#C84040',
blue: '#3A7BA8',
purple: '#9B59B6',
cyan: '#1ABC9C',
white: '#F0EDE6',
off: '#444458',
};
// ── Footswitch Action ─────────────────────────────────────────
export type FootswitchAction =
| { type: 'toggle_block'; blockId: string }
| { type: 'bank_up' }
| { type: 'bank_down' }
| { type: 'select_preset'; bank: number; program: number }
| { type: 'recall_snapshot'; snapshotIndex: number }
| { type: 'global_bypass' }
| { type: 'tap_tempo' }
| { type: 'tuner' }
| { type: 'bank_select'; bank: number };
// ── Pedal State (from API) ────────────────────────────────────
export interface PedalState {
master_volume?: number;
bypass?: boolean;
tuner_enabled?: boolean;
cpu_percent?: number;
sample_rate?: number;
nam_loaded?: boolean;
nam_model?: string;
ir_loaded?: boolean;
ir_name?: string;
current_preset?: { name: string; bank: number; program: number };
input_level?: number;
output_level?: number;
routing_mode?: string;
routing_breakpoint?: number;
wifi?: {
connected: boolean;
ssid?: string;
ip?: string;
signal?: number;
hotspot_active: boolean;
hotspot_ssid?: string;
};
bluetooth?: {
powered: boolean;
discoverable: boolean;
midi_enabled: boolean;
name?: string;
address?: string;
};
blocks?: PedalBlock[];
}
export interface PedalBlock {
id: number;
fx_type: string;
title: string;
bypassed: boolean;
params?: BlockParam[];
}
export interface BlockParam {
name: string;
key: string;
default?: number;
min?: number;
max?: number;
}
// ── Preset Data ───────────────────────────────────────────────
export interface PresetData {
name: string;
bank: number;
program: number;
chain?: PedalBlock[];
}
export interface BankData {
name: string;
number: number;
presets: (PresetData | null)[];
}
export interface PresetListResponse {
banks: BankData[];
}
// ── Snapshot ──────────────────────────────────────────────────
export interface SnapshotData {
name: string;
index: number;
/** Block bypass states at snapshot time */
blockStates: Record<number, boolean>;
/** Parameter values at snapshot time (blockId -> paramKey -> value) */
paramValues: Record<number, Record<string, number>>;
}
// ── WebSocket Messages ────────────────────────────────────────
export type WsMessage =
| { type: 'connected'; state: PedalState }
| { type: 'state'; state: PedalState }
| { type: 'preset_changed'; state: PedalState }
| { type: 'bypass_changed'; bypass: boolean }
| { type: 'tuner_changed'; tuner_enabled: boolean }
| { type: 'routing_changed'; routing_mode: string; routing_breakpoint: number }
| { type: 'model_loaded' }
| { type: 'ir_loaded' };