"use client"; import { useState } from "react"; import { CaretRight, DiceFive, Waveform as WaveIcon } from "@phosphor-icons/react"; import { Button, Field, NumberInput, Panel, SegmentedControl, Slider, Switch } from "@/components/ui"; import { INSTRUMENTAL_LORAS, REAL_AUDIO_BASE_CHECKPOINT, REAL_AUDIO_LORAS, instrumentalRequirementsMet, } from "@/lib/comfy/graph"; import { formatClock } from "@/lib/presets"; import type { AdvancedParams, ComfyCapabilities, OutputFormat, PlanMode, ScoreSource, } from "@/lib/types"; export interface RenderSettings { scoreSource: ScoreSource; mode: PlanMode; maxDuration: number; seed: number; randomizeSeed: boolean; tiledDecode: boolean; realAudioMatch: boolean; realAudioStrength: number; instrumentalArrangement: boolean; instrumentalStrength: number; outputFormat: OutputFormat; checkpoint: string; audioEncoder: string; advanced: AdvancedParams; } export function RenderPanel({ settings, onChange, capabilities, hasReference, hasScore, onOpenScore, busy, error, onRender, }: { settings: RenderSettings; onChange: (next: RenderSettings) => void; capabilities: ComfyCapabilities | null; hasReference: boolean; hasScore: boolean; onOpenScore: () => void; busy: boolean; error: string | null; onRender: () => void; }) { const [showAdvanced, setShowAdvanced] = useState(false); const installed = capabilities?.loras ?? []; const loraReady = REAL_AUDIO_LORAS.every((file) => installed.includes(file)); // The adapter was built against the bf16 layout. On the int8 checkpoint the // deltas land on rotated, quantised weights and the result is unpredictable. const wrongBase = Boolean(settings.checkpoint) && settings.checkpoint !== REAL_AUDIO_BASE_CHECKPOINT; const instReady = INSTRUMENTAL_LORAS.every((file) => installed.includes(file)); const instUsable = instrumentalRequirementsMet(settings); const set = (key: K, value: RenderSettings[K]) => onChange({ ...settings, [key]: value }); const setAdvanced = (key: K, value: AdvancedParams[K]) => onChange({ ...settings, advanced: { ...settings.advanced, [key]: value } }); return (
name="Score source" value={settings.scoreSource} onChange={(value) => set("scoreSource", value)} options={[ { value: "model", label: "YuE2 writes it" }, { value: "reference", label: hasReference ? "From the reference" : "From a reference", hint: hasReference ? undefined : "Upload a song first", }, { value: "manual", label: "Score I edited", hint: hasScore ? undefined : "Paste one in" }, { value: "none", label: "Skip the score" }, ]} /> {/* The editor used to be reachable only from the dock, which needs a finished take, so "Score I edited" could never be populated before the first render. This is the way in. */} name="Plan mode" value={settings.mode} onChange={(value) => set("mode", value)} options={[ { value: "full", label: "Melody and chords" }, { value: "melody", label: "Melody only" }, ]} /> {/* The honest framing matters here. This adapter changes how the renderer sounds, it does not hand the model a second channel into the reference, because the tokenizer head that would do that has no ComfyUI node. Overselling it would send people chasing a knob. */} set("realAudioMatch", value)} label="Real-audio adapter" /> {settings.realAudioMatch && loraReady ? (
set("realAudioStrength", value)} />
) : null}
set("instrumentalArrangement", value)} label="Instrumental arrangement" /> {settings.instrumentalArrangement && instReady ? (
set("instrumentalStrength", value)} /> {!instUsable ? ( ) : null}
) : null}
set("maxDuration", value)} />
set("seed", value)} />
set("randomizeSeed", value)} label="New seed on every render" />
{showAdvanced ? (
setAdvanced("temperature", v)} /> setAdvanced("topP", v)} /> setAdvanced("topK", v)} /> setAdvanced("repetitionPenalty", v)} /> setAdvanced("cfgScale", v)} /> setAdvanced("steps", v)} /> setAdvanced("abcTemperature", v)} />
{(["flac", "mp3", "opus"] as OutputFormat[]).map((format) => ( ))}
set("tiledDecode", value)} label="Tiled decode" />

Slower, but it keeps the VAE inside a 24 GB card on long songs.

{capabilities?.checkpoints.length ? ( set("checkpoint", value)} /> ) : null} {capabilities?.audioEncoders.length ? ( set("audioEncoder", value)} /> ) : null}
) : null}
{error ?

{error}

: null}
); } const SCORE_HELP: Record = { model: "YuE2 drafts melody and chords first, then sings them.", reference: "SheetSage2 transcribes the uploaded song, YuE2 performs your lyrics on that melody.", manual: "Uses the score in the panel as written, edits included.", none: "No symbolic plan. Fastest, least control over the tune.", }; function Picker({ id, value, options, onChange, }: { id: string; value: string; options: string[]; onChange: (value: string) => void; }) { return ( ); }