import type { GraphNode } from '../../core/graph'; import { InstrumentChip, InstrumentEnvelope } from '../../core/instrument/nodes'; import { SoundFxCompressor, SoundFxDelay, SoundFxFilter, SoundFxLimiter, SoundFxParametricEq, SoundFxReverb, SoundFxSaturation, } from '../../core/soundfx/nodes'; import type { NodeFace } from '../graph/nodeFace'; import type { EditorState } from '../state'; import { ChipFace } from './ChipFace'; import { CompressorFace } from './CompressorFace'; import { CurveFace } from './CurveFace'; import { DelayFace } from './DelayFace'; import { EnvelopeFace } from './EnvelopeFace'; import { EqPanel } from './EqPanel'; import { FilterPanel } from './FilterPanel'; import { KnobFace } from './KnobFace'; import { GAIN_DEVICE, MIX_DEVICE, PAN_DEVICE, PITCH_DEVICE } from './KnobPanel'; import { LimiterFace } from './LimiterFace'; import { ReverbFace } from './ReverbFace'; import { SaturationFace } from './SaturationFace'; /** The nodes drawn as a face of their own instead of rows (#380, #381, #384–#386, #388–#390, #392, #393, #396, #397), by type. */ export function nodeFaceFor(state: EditorState, assetId: string, node: GraphNode): NodeFace | null { if (node.type === InstrumentChip.type) return new ChipFace(state, assetId, node.id); if (node.type === InstrumentEnvelope.type) return new EnvelopeFace(state, assetId, node.id); if (node.type === SoundFxCompressor.type) return new CompressorFace(state, assetId, node.id); if (node.type === SoundFxParametricEq.type) return new CurveFace(new EqPanel(state, true), assetId, node.id); if (node.type === SoundFxFilter.type) return new CurveFace(new FilterPanel(state, true), assetId, node.id); const knobbed = [GAIN_DEVICE, PITCH_DEVICE, MIX_DEVICE, PAN_DEVICE].find( (device) => device.type === node.type, ); if (knobbed) return new KnobFace(state, assetId, node.id, knobbed); if (node.type === SoundFxReverb.type) return new ReverbFace(state, assetId, node.id); if (node.type === SoundFxDelay.type) return new DelayFace(state, assetId, node.id); if (node.type === SoundFxSaturation.type) return new SaturationFace(state, assetId, node.id); if (node.type === SoundFxLimiter.type) return new LimiterFace(state, assetId, node.id); return null; }