diff --git a/src/as/dsp/build.ts b/src/as/dsp/build.ts index a9f4cf1..ce55424 100644 --- a/src/as/dsp/build.ts +++ b/src/as/dsp/build.ts @@ -376,9 +376,24 @@ export function TrackBuild(track: Track) { setupVm.CreateValues(context.values) setupVm.End() - let L = program.scope.vars['L'] - let R = program.scope.vars['R'] - let LR = program.scope.vars['LR'] + let L: AstNode | undefined = program.scope.vars['L'] + let R: AstNode | undefined = program.scope.vars['R'] + let LR: AstNode | undefined = program.scope.vars['LR'] + + // @ts-ignore + if (L?.value?.kind !== ValueBase.Kind.Audio && L?.value?.kind !== ValueBase.Kind.Dynamic) { + L = undefined + } + + // @ts-ignore + if (R?.value?.kind !== ValueBase.Kind.Audio && R?.value?.kind !== ValueBase.Kind.Dynamic) { + R = undefined + } + + // @ts-ignore + if (LR?.value?.kind !== ValueBase.Kind.Audio && LR?.value?.kind !== ValueBase.Kind.Dynamic) { + LR = undefined + } const slice = program.scope.stack.slice(-2) if (slice.length === 2) { @@ -389,6 +404,33 @@ export function TrackBuild(track: Track) { LR ??= slice.pop()! } + // @ts-ignore + if (L?.value?.kind !== ValueBase.Kind.Audio && L?.value?.kind !== ValueBase.Kind.Dynamic) { + L = undefined + } + + // @ts-ignore + if (R?.value?.kind !== ValueBase.Kind.Audio && R?.value?.kind !== ValueBase.Kind.Dynamic) { + R = undefined + } + + // @ts-ignore + if (LR?.value?.kind !== ValueBase.Kind.Audio && LR?.value?.kind !== ValueBase.Kind.Dynamic) { + LR = undefined + } + + if (!LR) { + if (L && R) { } + else if (L) { + LR = L + L = undefined + } + else if (R) { + LR = R + R = undefined + } + } + const out = { L: L?.value as Value.Audio | undefined, R: R?.value as Value.Audio | undefined, diff --git a/src/comp/DspEditorUi.tsx b/src/comp/DspEditorUi.tsx index 605911b..ec63a47 100644 --- a/src/comp/DspEditorUi.tsx +++ b/src/comp/DspEditorUi.tsx @@ -2,13 +2,11 @@ import { BUFFER_SIZE, createDspNode, PreviewService, SoundValue } from 'dsp' import type { Pane } from 'editor' import { Gfx, Matrix, Rect, wasm as wasmGfx } from 'gfx' import type { Token } from 'lang' -import { $, dispose, Sigui } from 'sigui' +import { Sigui } from 'sigui' import { Canvas } from 'ui' import { assign, dom, Lru, throttle } from 'utils' -import { cn } from '~/lib/cn.ts' import { DspEditor } from '~/src/comp/DspEditor.tsx' import { screen } from '~/src/screen.ts' -import { state } from '~/src/state.ts' import { ListMarkWidget, RmsDecoWidget, WaveGlDecoWidget } from '~/src/ui/editor/widgets/index.ts' import { copyRingInto } from '~/src/util/copy-ring-into.ts' @@ -364,7 +362,7 @@ export function DspEditorUi() { info.el =