/** * The nodes of a sound FX graph with a tab of their own, opened by a double-click on them: a * Parametric EQ (#370), a Compressor (#378) and a Filter (#385). A tab is a document named by its * kind, the asset and the node (`eq::`). */ import type { GraphNode } from '../../core/graph'; import type { Project } from '../../core/model/Project'; import { SoundFxCompressor, SoundFxFilter, SoundFxParametricEq } from '../../core/soundfx/nodes'; import { compressorNodeOf, compressorTabLabel } from './CompressorEditor'; import { eqTabLabel } from './EqEditor'; import { eqNodeOf } from './EqPanel'; import { filterNodeOf } from './FilterPanel'; export type NodeTabKind = 'eq' | 'compressor' | 'filter'; export const NODE_TAB_KINDS: readonly NodeTabKind[] = ['eq', 'compressor', 'filter']; const KIND_OF_TYPE: Readonly> = { [SoundFxParametricEq.type]: 'eq', [SoundFxCompressor.type]: 'compressor', [SoundFxFilter.type]: 'filter', }; /** The kind of tab a node opens, or null for one without. */ export const nodeTabOf = (type: string): NodeTabKind | null => KIND_OF_TYPE[type] ?? null; const NODE_OF: Readonly> = { eq: eqNodeOf, compressor: compressorNodeOf, filter: filterNodeOf, }; /** The node a tab is about, or null once it, or its asset, is gone. */ export function nodeOfTab( project: Project, kind: NodeTabKind, assetId: string, nodeId: string, ): GraphNode | null { return NODE_OF[kind](project, assetId, nodeId); } export function nodeTabLabel(project: Project, kind: NodeTabKind, assetId: string, nodeId: string): string { return kind === 'compressor' ? compressorTabLabel(project, assetId, nodeId) : eqTabLabel(project, assetId, nodeId); }