feat: mobile version of gain section
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
/* ---------- Page wrapper ---------- */
|
||||
|
||||
.gain-page {
|
||||
display: contents; /* invisible on desktop; a flex column on phones */
|
||||
}
|
||||
|
||||
.gain-tabs,
|
||||
.gain-rotate-hint {
|
||||
display: none; /* phones only */
|
||||
}
|
||||
|
||||
.gain-panel__btns {
|
||||
display: contents; /* desktop: buttons stay direct children of the panel */
|
||||
}
|
||||
|
||||
.gain-panel__btn-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------- Fader strip ---------- */
|
||||
|
||||
.gain-section {
|
||||
container-type: size;
|
||||
|
||||
@@ -5,6 +26,7 @@
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 20;
|
||||
|
||||
height: var(--dsp-control-heigth);
|
||||
|
||||
@@ -13,12 +35,9 @@
|
||||
justify-content: center;
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
background: var(--bg-panel);
|
||||
|
||||
z-index: 20;
|
||||
|
||||
border-top: var(--border-width) solid var(--border-hairline);
|
||||
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
@@ -33,39 +52,50 @@
|
||||
|
||||
.gain-panel {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
height: 100%;
|
||||
aspect-ratio: 1 / 4;
|
||||
flex: 0 0 auto;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 2cqh;
|
||||
|
||||
padding-bottom: 2cqh;
|
||||
box-sizing: border-box;
|
||||
|
||||
background: var(--bg-void);
|
||||
border: var(--border-width) solid var(--border-hairline);
|
||||
border-radius: var(--radius-md);
|
||||
box-sizing: border-box;
|
||||
gap: 2cqh;
|
||||
background: var(--bg-void);
|
||||
padding-bottom: 2cqh;
|
||||
}
|
||||
|
||||
.gain-panel__title {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
min-width: 0;
|
||||
|
||||
padding-block: 2cqh;
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 4cqh;
|
||||
font-weight: var(--font-weight-semibold);
|
||||
padding-top: 2cqh;
|
||||
padding-bottom: 2cqh;
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
text-align: center;
|
||||
|
||||
min-width: 0;
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.gain-panel .gain-panel__btn {
|
||||
width: 85%;
|
||||
min-height: 0;
|
||||
padding: 2cqh 0;
|
||||
font-size: 4cqh;
|
||||
}
|
||||
|
||||
/* ---------- Graphs ---------- */
|
||||
|
||||
.gain-linear-graph-section {
|
||||
flex: 0 0 calc(100% - var(--dsp-control-heigth));
|
||||
min-height: 0;
|
||||
@@ -94,17 +124,6 @@
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.gain-graph-title {
|
||||
flex: 0 0 auto;
|
||||
|
||||
text-align: center;
|
||||
padding: 1cqh;
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 2.5cqh;
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.gain-graph-panel > .container {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@@ -112,42 +131,49 @@
|
||||
|
||||
.gain-graph-title-row {
|
||||
flex: 0 0 auto;
|
||||
min-width: 0;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
gap: 0.75cqh;
|
||||
padding: 1cqh 1.5cqh;
|
||||
|
||||
min-width: 0;
|
||||
padding: 1cqh 1.5cqh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* First row: title left, Show stages right */
|
||||
/* Title left, "Show stages" right */
|
||||
.gain-graph-title-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1cqh;
|
||||
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
gap: 1cqh;
|
||||
}
|
||||
|
||||
.gain-graph-title {
|
||||
flex: 0 0 auto;
|
||||
padding: 1cqh;
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 2.5cqh;
|
||||
font-weight: var(--font-weight-semibold);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.gain-graph-title-line .gain-graph-title {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
|
||||
padding: 0;
|
||||
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Compact button on the right */
|
||||
.gain-stages-toggle {
|
||||
flex: 0 0 auto;
|
||||
|
||||
@@ -157,11 +183,11 @@
|
||||
padding: 0.4cqh 1cqh;
|
||||
font-size: 1.8cqh;
|
||||
line-height: 1.2;
|
||||
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Channel Selector */
|
||||
/* ---------- Channel selector ---------- */
|
||||
|
||||
.magnitude-selector {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
@@ -169,7 +195,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
|
||||
gap: 0.5cqh;
|
||||
|
||||
overflow: hidden;
|
||||
@@ -183,24 +208,21 @@
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
gap: 0.6cqh;
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 1.8cqh;
|
||||
|
||||
padding: 0.4cqh 1cqh;
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 1.8cqh;
|
||||
white-space: nowrap;
|
||||
|
||||
background: var(--bg-void);
|
||||
color: var(--text-muted);
|
||||
|
||||
border: var(--border-width) solid var(--border-hairline);
|
||||
border-radius: var(--radius-sm);
|
||||
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -211,19 +233,384 @@
|
||||
}
|
||||
|
||||
.magnitude-selector__swatch {
|
||||
flex: 0 0 auto;
|
||||
width: 1.2cqh;
|
||||
height: 1.2cqh;
|
||||
|
||||
border-radius: 50%;
|
||||
background: var(--chip-color);
|
||||
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.magnitude-selector__label {
|
||||
min-width: 0;
|
||||
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ---------- Phone (shared) ----------
|
||||
Landscape: tabs (Faders / Input curve / Output curve), one view at a time.
|
||||
Portrait: faders only + a hint to rotate for the graphs. */
|
||||
|
||||
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
|
||||
.gain-page {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
|
||||
/* ----- Tabs ----- */
|
||||
|
||||
.gain-tabs {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.gain-page .gain-tabs__tab {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 34px;
|
||||
padding: 0 var(--space-2);
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--font-xs);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
background: var(--bg-void);
|
||||
color: var(--text-muted);
|
||||
border: var(--border-width) solid var(--border-hairline);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.gain-page .gain-tabs__tab[aria-selected='true'] {
|
||||
background: var(--bg-raised);
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent-brand);
|
||||
}
|
||||
|
||||
/* ----- Which view is visible ----- */
|
||||
|
||||
.gain-page[data-view='faders'] .gain-linear-graph-section,
|
||||
.gain-page:not([data-view='faders']) .gain-section,
|
||||
.gain-page[data-view='input'] .gain-graph-panel[data-panel='output'],
|
||||
.gain-page[data-view='output'] .gain-graph-panel[data-panel='input'] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ----- Curve views: graph fills everything ----- */
|
||||
|
||||
.gain-linear-graph-section {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
padding: var(--space-1);
|
||||
}
|
||||
|
||||
.gain-graph-panel {
|
||||
flex: 1 1 0;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* Compact header: chips scroll on the left, "Show stages" on the right */
|
||||
.gain-graph-title-row {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
}
|
||||
|
||||
.gain-graph-title-line {
|
||||
order: 2;
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.gain-graph-title-line .gain-graph-title {
|
||||
display: none; /* the tab already says which graph this is */
|
||||
}
|
||||
|
||||
.gain-stages-toggle {
|
||||
min-height: 0;
|
||||
height: 32px;
|
||||
padding: 0 var(--space-3);
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.magnitude-selector {
|
||||
order: 1;
|
||||
flex: 1 1 auto;
|
||||
width: auto;
|
||||
gap: var(--space-1);
|
||||
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scrollbar-width: none;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.magnitude-selector::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.magnitude-selector__chip {
|
||||
flex: 0 0 auto;
|
||||
min-height: 0;
|
||||
height: 32px;
|
||||
padding: 0 var(--space-3);
|
||||
gap: var(--space-2);
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.magnitude-selector__swatch {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
/* ----- Faders view: mixer strips, swipe sideways, snap per group ----- */
|
||||
|
||||
.gain-section {
|
||||
position: relative;
|
||||
z-index: auto;
|
||||
flex: 1 1 0;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.gain-panels {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-2);
|
||||
box-sizing: border-box;
|
||||
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scroll-snap-type: x proximity;
|
||||
overscroll-behavior-x: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.gain-section .channel-group {
|
||||
flex: 0 0 auto;
|
||||
margin: 0;
|
||||
padding: 30px var(--space-2) var(--space-2);
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.gain-section .channel-group__label {
|
||||
top: 7px;
|
||||
font-size: var(--font-sm);
|
||||
}
|
||||
|
||||
.gain-section .channel-group__items {
|
||||
height: auto;
|
||||
align-self: stretch;
|
||||
}
|
||||
|
||||
.gain-panel {
|
||||
flex: 0 0 auto;
|
||||
width: clamp(64px, 10vw, 80px);
|
||||
height: auto; /* stretches to the row */
|
||||
aspect-ratio: auto;
|
||||
gap: var(--space-2);
|
||||
padding-bottom: var(--space-2);
|
||||
}
|
||||
|
||||
.gain-panel__title {
|
||||
padding-block: var(--space-2);
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
/* The fader (element right after the title) takes all remaining height.
|
||||
pan-x: vertical drags move the fader, horizontal swipes still scroll the strip. */
|
||||
.gain-panel__title + * {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Applied to the thumb/track too: a swipe that starts on them must scroll the
|
||||
strip, not drag the fader. */
|
||||
.gain-panel__title + *,
|
||||
.gain-panel__title + * * {
|
||||
touch-action: pan-x !important;
|
||||
}
|
||||
|
||||
/* Centered when everything fits, left-aligned and scrollable when it doesn't
|
||||
(auto margins collapse to 0 on overflow, unlike justify-content: center) */
|
||||
.gain-panels > .channel-group:first-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.gain-panels > .channel-group:last-child {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.gain-panel__btns {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
width: calc(100% - var(--space-3));
|
||||
}
|
||||
|
||||
.gain-panel .gain-panel__btns .gain-panel__btn {
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 0;
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Portrait phone: faders only, 2 rows (Input on top, Output below) ---------- */
|
||||
|
||||
@media (max-width: 768px) and (orientation: portrait) {
|
||||
.gain-tabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.gain-rotate-hint {
|
||||
flex: 0 0 auto;
|
||||
display: block;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--font-xs);
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
}
|
||||
|
||||
/* Whatever tab was active in landscape, portrait always shows the faders */
|
||||
.gain-page[data-view] .gain-linear-graph-section {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.gain-page[data-view] .gain-section {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Two rows: each group is a row that scrolls sideways on its own */
|
||||
.gain-panels {
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
overflow: hidden;
|
||||
scroll-snap-type: none;
|
||||
}
|
||||
|
||||
/* Each row is its own size container: everything sized in cqh inside
|
||||
(fader thumb, track, readout) scales to the row height, like in landscape,
|
||||
instead of to the whole screen. */
|
||||
.gain-section .channel-group {
|
||||
container-type: size;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 28px var(--space-2) var(--space-2);
|
||||
scroll-snap-align: none;
|
||||
}
|
||||
|
||||
.gain-section .channel-group__label {
|
||||
top: 6px;
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.gain-section .channel-group__items {
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
gap: var(--space-1);
|
||||
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scroll-snap-type: x proximity;
|
||||
overscroll-behavior-x: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.gain-section .channel-group__items > :first-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.gain-section .channel-group__items > :last-child {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/* Same strip as landscape: narrow, compact, buttons stacked */
|
||||
.gain-panel {
|
||||
width: clamp(60px, 17vw, 72px);
|
||||
gap: var(--space-1);
|
||||
padding-bottom: var(--space-1);
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.gain-panel__title {
|
||||
padding-block: var(--space-1);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.gain-panel__btns {
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.gain-panel .gain-panel__btns .gain-panel__btn {
|
||||
min-height: 36px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Landscape phone: thinner strips, buttons stacked ---------- */
|
||||
|
||||
@media (max-height: 500px) and (pointer: coarse) {
|
||||
.gain-panels {
|
||||
padding: var(--space-1) var(--space-2);
|
||||
}
|
||||
|
||||
.gain-section .channel-group {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
.gain-section .channel-group__label {
|
||||
top: 4px;
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.gain-panel {
|
||||
width: clamp(56px, 7.5vw, 76px);
|
||||
gap: var(--space-1);
|
||||
padding-bottom: var(--space-1);
|
||||
}
|
||||
|
||||
.gain-panel__title {
|
||||
padding-block: var(--space-1);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.gain-panel__btns {
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.gain-panel .gain-panels .gain-panel__btn,
|
||||
.gain-panel .gain-panel__btns .gain-panel__btn {
|
||||
min-height: 36px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,34 @@ import { getPeqCurvePoints } from '../../utils/graph/peq';
|
||||
import { getCrossoverCurvePoints } from '../../utils/graph/crossover';
|
||||
import { ChannelCurves, formatY, ResponseGraph } from './GainGraph';
|
||||
|
||||
// ---- Helpers ------------------------------------------------------------
|
||||
|
||||
type GainView = 'faders' | 'input' | 'output';
|
||||
|
||||
const GAIN_VIEWS: { id: GainView; label: string }[] = [
|
||||
{ id: 'faders', label: 'Faders' },
|
||||
{ id: 'input', label: 'Input curve' },
|
||||
{ id: 'output', label: 'Output curve' },
|
||||
];
|
||||
|
||||
function toggleInSet<T>(set: Set<T>, value: T): Set<T> {
|
||||
const next = new Set(set);
|
||||
if (next.has(value)) next.delete(value);
|
||||
else next.add(value);
|
||||
return next;
|
||||
}
|
||||
|
||||
function withLiveValue<K extends string | number>(
|
||||
prev: Partial<Record<K, number>>,
|
||||
key: K,
|
||||
value: number | null
|
||||
): Partial<Record<K, number>> {
|
||||
const next = { ...prev };
|
||||
if (value === null) delete next[key];
|
||||
else next[key] = value;
|
||||
return next;
|
||||
}
|
||||
|
||||
// ---- Curve construction -----------------------------------------------
|
||||
|
||||
function getGainCurvePoints(freqs: number[], gainDb: number): CurvePoint[] {
|
||||
@@ -131,15 +159,9 @@ function GainPanel({
|
||||
await setInverse(channel, !inverted);
|
||||
};
|
||||
|
||||
const handleLiveValue = (value: number) => {
|
||||
onLiveGain(value);
|
||||
};
|
||||
|
||||
const commitGain = async (value: number) => {
|
||||
const success = await setGain(channel, value);
|
||||
if (success) {
|
||||
onLiveGain(null);
|
||||
}
|
||||
if (success) onLiveGain(null);
|
||||
return success;
|
||||
};
|
||||
|
||||
@@ -154,42 +176,29 @@ function GainPanel({
|
||||
unit=" dB"
|
||||
value={gain}
|
||||
formatValue={(v, d) => (v > 0 ? `+${v.toFixed(d)}` : v.toFixed(d))}
|
||||
onInput={handleLiveValue}
|
||||
onInput={onLiveGain}
|
||||
onChange={commitGain}
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="toggle"
|
||||
className={muted ? 'active-danger' : ''}
|
||||
onClick={toggleMute}
|
||||
style={{
|
||||
width: '85%',
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
fontSize: '4cqh',
|
||||
paddingTop: '2cqh',
|
||||
paddingBottom: '2cqh',
|
||||
minHeight: 0,
|
||||
}}
|
||||
>
|
||||
{muted ? 'Muted' : 'Mute '}
|
||||
</Button>
|
||||
<Button
|
||||
variant="toggle"
|
||||
className={inverted ? 'active-warning' : ''}
|
||||
onClick={toggleInverse}
|
||||
style={{
|
||||
width: '85%',
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
fontSize: '4cqh',
|
||||
paddingTop: '2cqh',
|
||||
paddingBottom: '2cqh',
|
||||
minHeight: 0,
|
||||
}}
|
||||
>
|
||||
{inverted ? 'Inverted' : 'Invert'}
|
||||
</Button>
|
||||
<div className="gain-panel__btns">
|
||||
<Button
|
||||
variant="toggle"
|
||||
className={`gain-panel__btn${muted ? ' active-danger' : ''}`}
|
||||
onClick={toggleMute}
|
||||
>
|
||||
<span className="gain-panel__btn-long">{muted ? 'Muted' : 'Mute'}</span>
|
||||
<span className="gain-panel__btn-short">Mute</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="toggle"
|
||||
className={`gain-panel__btn${inverted ? ' active-warning' : ''}`}
|
||||
onClick={toggleInverse}
|
||||
>
|
||||
<span className="gain-panel__btn-long">{inverted ? 'Inverted' : 'Invert'}</span>
|
||||
<span className="gain-panel__btn-short">Inv</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -241,7 +250,11 @@ function GainSection({
|
||||
setInverse: (channel: Channel, inverted: boolean) => Promise<boolean>;
|
||||
}) {
|
||||
const [selectedInputs, setSelectedInputs] = useState<Set<InputChannel>>(new Set(INPUT_ORDER));
|
||||
const [selectedOutputs, setSelectedOutputs] = useState<Set<OutputChannel>>(new Set(OUTPUT_ORDER));
|
||||
const [selectedOutputs, setSelectedOutputs] = useState<Set<OutputChannel>>(
|
||||
new Set(OUTPUT_ORDER)
|
||||
);
|
||||
|
||||
const [view, setView] = useState<GainView>('faders');
|
||||
|
||||
const [showInputStages, setShowInputStages] = useState(false);
|
||||
const [showOutputStages, setShowOutputStages] = useState(false);
|
||||
@@ -251,70 +264,54 @@ function GainSection({
|
||||
{}
|
||||
);
|
||||
|
||||
const setLiveInputGain = (channel: InputChannel, value: number | null) => {
|
||||
setLiveInputGains((prev) => {
|
||||
if (value === null) {
|
||||
const next = { ...prev };
|
||||
delete next[channel];
|
||||
return next;
|
||||
}
|
||||
return { ...prev, [channel]: value };
|
||||
});
|
||||
};
|
||||
const setLiveInputGain = (channel: InputChannel, value: number | null) =>
|
||||
setLiveInputGains((prev) => withLiveValue(prev, channel, value));
|
||||
|
||||
const setLiveOutputGain = (channel: OutputChannel, value: number | null) => {
|
||||
setLiveOutputGains((prev) => {
|
||||
if (value === null) {
|
||||
const next = { ...prev };
|
||||
delete next[channel];
|
||||
return next;
|
||||
}
|
||||
return { ...prev, [channel]: value };
|
||||
});
|
||||
};
|
||||
const setLiveOutputGain = (channel: OutputChannel, value: number | null) =>
|
||||
setLiveOutputGains((prev) => withLiveValue(prev, channel, value));
|
||||
|
||||
const inputLabels: Record<InputChannel, string> = INPUT_ORDER.reduce(
|
||||
(acc, channel) => ({
|
||||
...acc,
|
||||
[channel]: dsp.state.current_config.input_states[channel].name,
|
||||
}),
|
||||
{} as Record<InputChannel, string>
|
||||
);
|
||||
const inputStates = dsp.state.current_config.input_states;
|
||||
const outputStates = dsp.state.current_config.output_states;
|
||||
|
||||
const outputLabels: Record<OutputChannel, string> = OUTPUT_ORDER.reduce(
|
||||
(acc, channel) => ({
|
||||
...acc,
|
||||
[channel]: dsp.state.current_config.output_states[channel].name,
|
||||
}),
|
||||
{} as Record<OutputChannel, string>
|
||||
);
|
||||
const inputLabels = Object.fromEntries(
|
||||
INPUT_ORDER.map((channel) => [channel, inputStates[channel].name])
|
||||
) as Record<InputChannel, string>;
|
||||
|
||||
const toggleInput = (channel: InputChannel) => {
|
||||
setSelectedInputs((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.has(channel) ? next.delete(channel) : next.add(channel);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const toggleOutput = (channel: OutputChannel) => {
|
||||
setSelectedOutputs((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.has(channel) ? next.delete(channel) : next.add(channel);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
const outputLabels = Object.fromEntries(
|
||||
OUTPUT_ORDER.map((channel) => [channel, outputStates[channel].name])
|
||||
) as Record<OutputChannel, string>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="gain-page" data-view={view}>
|
||||
{/* Phone only (hidden on desktop by CSS): one view at a time */}
|
||||
<div className="gain-tabs" role="tablist" aria-label="Gain views">
|
||||
{GAIN_VIEWS.map((v) => (
|
||||
<button
|
||||
key={v.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={view === v.id}
|
||||
className="gain-tabs__tab"
|
||||
onClick={() => setView(v.id)}
|
||||
>
|
||||
{v.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Portrait phone only (CSS): graphs need the width of landscape */}
|
||||
<div className="gain-rotate-hint">
|
||||
Rotate your phone to landscape to see the response graphs.
|
||||
</div>
|
||||
|
||||
<div className="gain-linear-graph-section">
|
||||
<div className="gain-graph-panel">
|
||||
<div className="gain-graph-panel" data-panel="input">
|
||||
<div className="gain-graph-title-row">
|
||||
<div className="gain-graph-title-line">
|
||||
<div className="gain-graph-title">Input Response</div>
|
||||
<Button
|
||||
variant="toggle"
|
||||
className={`gain-stages-toggle ${showInputStages ? 'active-info' : ''}`}
|
||||
className={`gain-stages-toggle${showInputStages ? ' active-info' : ''}`}
|
||||
onClick={() => setShowInputStages((v) => !v)}
|
||||
>
|
||||
Show stages
|
||||
@@ -325,12 +322,12 @@ function GainSection({
|
||||
labels={inputLabels}
|
||||
colors={INPUT_COLORS}
|
||||
selected={selectedInputs}
|
||||
onToggle={toggleInput}
|
||||
onToggle={(c) => setSelectedInputs((prev) => toggleInSet(prev, c))}
|
||||
/>
|
||||
</div>
|
||||
<ResponseGraph
|
||||
channels={INPUT_ORDER}
|
||||
states={dsp.state.current_config.input_states}
|
||||
states={inputStates}
|
||||
selected={selectedInputs}
|
||||
colors={INPUT_COLORS}
|
||||
showStages={showInputStages}
|
||||
@@ -340,30 +337,29 @@ function GainSection({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="gain-graph-panel">
|
||||
<div className="gain-graph-panel" data-panel="output">
|
||||
<div className="gain-graph-title-row">
|
||||
<div className="gain-graph-title-line">
|
||||
<div className="gain-graph-title">Output Response</div>
|
||||
<Button
|
||||
variant={showOutputStages ? 'outline' : 'ghost'}
|
||||
className="gain-stages-toggle"
|
||||
variant="toggle"
|
||||
className={`gain-stages-toggle${showOutputStages ? ' active-info' : ''}`}
|
||||
onClick={() => setShowOutputStages((v) => !v)}
|
||||
>
|
||||
Show stages
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ChannelSelector
|
||||
channels={OUTPUT_ORDER}
|
||||
labels={outputLabels}
|
||||
colors={OUTPUT_COLORS}
|
||||
selected={selectedOutputs}
|
||||
onToggle={toggleOutput}
|
||||
onToggle={(c) => setSelectedOutputs((prev) => toggleInSet(prev, c))}
|
||||
/>
|
||||
</div>
|
||||
<ResponseGraph
|
||||
channels={OUTPUT_ORDER}
|
||||
states={dsp.state.current_config.output_states}
|
||||
states={outputStates}
|
||||
selected={selectedOutputs}
|
||||
colors={OUTPUT_COLORS}
|
||||
showStages={showOutputStages}
|
||||
@@ -382,7 +378,7 @@ function GainSection({
|
||||
key={channel}
|
||||
dsp={dsp}
|
||||
channel={{ Input: channel }}
|
||||
title={dsp.state.current_config.input_states[channel].name}
|
||||
title={inputStates[channel].name}
|
||||
setGain={setGain}
|
||||
setMute={setMute}
|
||||
setInverse={setInverse}
|
||||
@@ -397,7 +393,7 @@ function GainSection({
|
||||
key={channel}
|
||||
dsp={dsp}
|
||||
channel={{ Output: channel }}
|
||||
title={dsp.state.current_config.output_states[channel].name}
|
||||
title={outputStates[channel].name}
|
||||
setGain={setGain}
|
||||
setMute={setMute}
|
||||
setInverse={setInverse}
|
||||
@@ -407,8 +403,8 @@ function GainSection({
|
||||
</ChannelGroup>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default GainSection;
|
||||
export default GainSection;
|
||||
Reference in New Issue
Block a user