feat: implement per-track and master effect chains (Option 3)
Architecture: - Each track now has its own effect chain stored in track.effectChain - Separate master effect chain for the final mix output - SidePanel has 3 tabs: Tracks, Track FX, Master FX Changes: - types/track.ts: Add effectChain field to Track interface - lib/audio/track-utils.ts: Initialize effect chain when creating tracks - lib/hooks/useMultiTrack.ts: Exclude effectChain from localStorage, recreate on load - components/editor/AudioEditor.tsx: - Add master effect chain state using useEffectChain hook - Add handlers for per-track effect chain manipulation - Pass both track and master effect chains to SidePanel - components/layout/SidePanel.tsx: - Update to 3-tab interface (Tracks | Track FX | Master FX) - Track FX tab shows effects for currently selected track - Master FX tab shows master bus effects with preset management - Different icons for track vs master effects tabs Note: Effect processing in Web Audio API not yet implemented. This commit sets up the data structures and UI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import type { Track, TrackColor } from '@/types/track';
|
||||
import { DEFAULT_TRACK_HEIGHT, TRACK_COLORS } from '@/types/track';
|
||||
import { createEffectChain } from '@/lib/audio/effects/chain';
|
||||
|
||||
/**
|
||||
* Generate a unique track ID
|
||||
@@ -33,6 +34,7 @@ export function createTrack(name?: string, color?: TrackColor): Track {
|
||||
mute: false,
|
||||
solo: false,
|
||||
recordEnabled: false,
|
||||
effectChain: createEffectChain(`${trackName} Effects`),
|
||||
collapsed: false,
|
||||
selected: false,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import type { Track } from '@/types/track';
|
||||
import { createTrack, createTrackFromBuffer } from '@/lib/audio/track-utils';
|
||||
import { createEffectChain } from '@/lib/audio/effects/chain';
|
||||
|
||||
const STORAGE_KEY = 'audio-ui-multi-track';
|
||||
|
||||
@@ -24,11 +25,12 @@ export function useMultiTrack() {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Note: AudioBuffers can't be serialized, so we only restore track metadata
|
||||
// Note: AudioBuffers and EffectChains can't be serialized, so we only restore track metadata
|
||||
return parsed.map((t: any) => ({
|
||||
...t,
|
||||
name: String(t.name || 'Untitled Track'), // Ensure name is always a string
|
||||
audioBuffer: null, // Will need to be reloaded
|
||||
effectChain: createEffectChain(`${t.name} Effects`), // Recreate effect chain
|
||||
}));
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -45,7 +47,7 @@ export function useMultiTrack() {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
try {
|
||||
// Only save serializable fields, excluding audioBuffer and any DOM references
|
||||
// Only save serializable fields, excluding audioBuffer, effectChain, and any DOM references
|
||||
const trackData = tracks.map((track) => ({
|
||||
id: track.id,
|
||||
name: String(track.name || 'Untitled Track'),
|
||||
@@ -58,6 +60,7 @@ export function useMultiTrack() {
|
||||
recordEnabled: track.recordEnabled,
|
||||
collapsed: track.collapsed,
|
||||
selected: track.selected,
|
||||
// Note: effectChain is excluded - will be recreated on load
|
||||
}));
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(trackData));
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user