2025-11-17 20:59:36 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2025-11-17 21:28:38 +01:00
|
|
|
import { Plus, Upload } from 'lucide-react';
|
2025-11-17 20:59:36 +01:00
|
|
|
import { Button } from '@/components/ui/Button';
|
|
|
|
|
import { Track } from './Track';
|
2025-11-17 21:28:38 +01:00
|
|
|
import { ImportTrackDialog } from './ImportTrackDialog';
|
2025-11-17 20:59:36 +01:00
|
|
|
import type { Track as TrackType } from '@/types/track';
|
feat: add EffectBrowser dialog for adding effects to tracks
Created a beautiful effect browser dialog inspired by Ableton Live:
**EffectBrowser Component:**
- Modal dialog with search functionality
- Effects organized by category:
- Dynamics (Compressor, Limiter, Gate)
- Filters (Lowpass, Highpass, Bandpass, etc.)
- Time-Based (Delay, Reverb, Chorus, Flanger, Phaser)
- Distortion (Distortion, Bitcrusher)
- Pitch & Time (Pitch Shifter, Time Stretch)
- Utility (Normalize, Fade In/Out, Reverse)
- Grid layout with hover effects
- Real-time search filtering
- Click effect to add to track
**Integration:**
- "+" button in track strip opens EffectBrowser dialog
- Selecting an effect adds it to the track's effect chain
- Effects appear immediately in the Devices section
- Full enable/disable and remove functionality
**UX Flow:**
1. Click "+" in track Devices section
2. Browse or search for effect
3. Click effect to add it
4. Effect appears in Devices list
5. Toggle on/off with ●/○
6. Remove with × button
Effects are now fully manageable in the UI! Next: Apply them to audio.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 08:02:21 +01:00
|
|
|
import { createEffect, type EffectType, EFFECT_NAMES } from '@/lib/audio/effects/chain';
|
2025-11-17 20:59:36 +01:00
|
|
|
|
|
|
|
|
export interface TrackListProps {
|
|
|
|
|
tracks: TrackType[];
|
|
|
|
|
zoom: number;
|
|
|
|
|
currentTime: number;
|
|
|
|
|
duration: number;
|
2025-11-17 22:17:09 +01:00
|
|
|
selectedTrackId?: string | null;
|
|
|
|
|
onSelectTrack?: (trackId: string | null) => void;
|
2025-11-17 20:59:36 +01:00
|
|
|
onAddTrack: () => void;
|
2025-11-17 21:28:38 +01:00
|
|
|
onImportTrack?: (buffer: AudioBuffer, name: string) => void;
|
2025-11-17 20:59:36 +01:00
|
|
|
onRemoveTrack: (trackId: string) => void;
|
|
|
|
|
onUpdateTrack: (trackId: string, updates: Partial<TrackType>) => void;
|
|
|
|
|
onSeek?: (time: number) => void;
|
2025-11-18 13:05:05 +01:00
|
|
|
onSelectionChange?: (trackId: string, selection: { start: number; end: number } | null) => void;
|
2025-11-17 20:59:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TrackList({
|
|
|
|
|
tracks,
|
|
|
|
|
zoom,
|
|
|
|
|
currentTime,
|
|
|
|
|
duration,
|
2025-11-17 22:17:09 +01:00
|
|
|
selectedTrackId,
|
|
|
|
|
onSelectTrack,
|
2025-11-17 20:59:36 +01:00
|
|
|
onAddTrack,
|
2025-11-17 21:28:38 +01:00
|
|
|
onImportTrack,
|
2025-11-17 20:59:36 +01:00
|
|
|
onRemoveTrack,
|
|
|
|
|
onUpdateTrack,
|
|
|
|
|
onSeek,
|
2025-11-18 13:05:05 +01:00
|
|
|
onSelectionChange,
|
2025-11-17 20:59:36 +01:00
|
|
|
}: TrackListProps) {
|
2025-11-17 21:28:38 +01:00
|
|
|
const [importDialogOpen, setImportDialogOpen] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const handleImportTrack = (buffer: AudioBuffer, name: string) => {
|
|
|
|
|
if (onImportTrack) {
|
|
|
|
|
onImportTrack(buffer, name);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-17 20:59:36 +01:00
|
|
|
if (tracks.length === 0) {
|
|
|
|
|
return (
|
2025-11-17 21:28:38 +01:00
|
|
|
<>
|
|
|
|
|
<div className="flex-1 flex flex-col items-center justify-center gap-4 text-muted-foreground">
|
|
|
|
|
<p className="text-sm">No tracks yet. Add a track to get started.</p>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<Button onClick={onAddTrack} variant="secondary">
|
|
|
|
|
<Plus className="h-4 w-4 mr-2" />
|
|
|
|
|
Add Empty Track
|
|
|
|
|
</Button>
|
|
|
|
|
{onImportTrack && (
|
|
|
|
|
<Button onClick={() => setImportDialogOpen(true)} variant="secondary">
|
|
|
|
|
<Upload className="h-4 w-4 mr-2" />
|
|
|
|
|
Import Audio Files
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{onImportTrack && (
|
|
|
|
|
<ImportTrackDialog
|
|
|
|
|
open={importDialogOpen}
|
|
|
|
|
onClose={() => setImportDialogOpen(false)}
|
|
|
|
|
onImportTrack={handleImportTrack}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2025-11-17 20:59:36 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex-1 flex flex-col overflow-hidden">
|
|
|
|
|
{/* Track List */}
|
|
|
|
|
<div className="flex-1 overflow-y-auto custom-scrollbar">
|
|
|
|
|
{tracks.map((track) => (
|
|
|
|
|
<Track
|
|
|
|
|
key={track.id}
|
|
|
|
|
track={track}
|
|
|
|
|
zoom={zoom}
|
|
|
|
|
currentTime={currentTime}
|
|
|
|
|
duration={duration}
|
2025-11-17 22:17:09 +01:00
|
|
|
isSelected={selectedTrackId === track.id}
|
|
|
|
|
onSelect={onSelectTrack ? () => onSelectTrack(track.id) : undefined}
|
2025-11-17 20:59:36 +01:00
|
|
|
onToggleMute={() =>
|
|
|
|
|
onUpdateTrack(track.id, { mute: !track.mute })
|
|
|
|
|
}
|
|
|
|
|
onToggleSolo={() =>
|
|
|
|
|
onUpdateTrack(track.id, { solo: !track.solo })
|
|
|
|
|
}
|
|
|
|
|
onToggleCollapse={() =>
|
|
|
|
|
onUpdateTrack(track.id, { collapsed: !track.collapsed })
|
|
|
|
|
}
|
|
|
|
|
onVolumeChange={(volume) =>
|
|
|
|
|
onUpdateTrack(track.id, { volume })
|
|
|
|
|
}
|
|
|
|
|
onPanChange={(pan) =>
|
|
|
|
|
onUpdateTrack(track.id, { pan })
|
|
|
|
|
}
|
|
|
|
|
onRemove={() => onRemoveTrack(track.id)}
|
|
|
|
|
onNameChange={(name) =>
|
|
|
|
|
onUpdateTrack(track.id, { name })
|
|
|
|
|
}
|
|
|
|
|
onSeek={onSeek}
|
2025-11-18 07:06:46 +01:00
|
|
|
onLoadAudio={(buffer) =>
|
|
|
|
|
onUpdateTrack(track.id, { audioBuffer: buffer })
|
|
|
|
|
}
|
2025-11-18 07:46:27 +01:00
|
|
|
onToggleEffect={(effectId) => {
|
|
|
|
|
const updatedChain = {
|
|
|
|
|
...track.effectChain,
|
|
|
|
|
effects: track.effectChain.effects.map((e) =>
|
|
|
|
|
e.id === effectId ? { ...e, enabled: !e.enabled } : e
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
onUpdateTrack(track.id, { effectChain: updatedChain });
|
|
|
|
|
}}
|
|
|
|
|
onRemoveEffect={(effectId) => {
|
|
|
|
|
const updatedChain = {
|
|
|
|
|
...track.effectChain,
|
|
|
|
|
effects: track.effectChain.effects.filter((e) => e.id !== effectId),
|
|
|
|
|
};
|
|
|
|
|
onUpdateTrack(track.id, { effectChain: updatedChain });
|
|
|
|
|
}}
|
feat: complete Phase 7.4 - real-time track effects system
Implemented comprehensive real-time effect processing for multi-track audio:
Core Features:
- Per-track effect chains with drag-and-drop reordering
- Effect bypass/enable toggle per effect
- Real-time parameter updates (filters, dynamics, time-based, distortion, bitcrusher, pitch, timestretch)
- Add/remove effects during playback without interruption
- Effect chain persistence via localStorage
- Automatic playback stop when tracks are deleted
Technical Implementation:
- Effect processor with dry/wet routing for bypass functionality
- Real-time effect parameter updates using AudioParam setValueAtTime
- Structure change detection for add/remove/reorder operations
- Stale closure fix using refs for latest track state
- ScriptProcessorNode for bitcrusher, pitch shifter, and time stretch
- Dual-tap delay line for pitch shifting
- Overlap-add synthesis for time stretching
UI Components:
- EffectBrowser dialog with categorized effects
- EffectDevice component with parameter controls
- EffectParameters for all 19 real-time effect types
- Device rack with horizontal scrolling (Ableton-style)
Removed offline-only effects (normalize, fadeIn, fadeOut, reverse) as they don't fit the real-time processing model.
Completed all items in Phase 7.4:
- [x] Per-track effect chain
- [x] Effect rack UI
- [x] Effect bypass per track
- [x] Real-time effect processing during playback
- [x] Add/remove effects during playback
- [x] Real-time parameter updates
- [x] Effect chain persistence
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 12:08:33 +01:00
|
|
|
onUpdateEffect={(effectId, parameters) => {
|
|
|
|
|
const updatedChain = {
|
|
|
|
|
...track.effectChain,
|
|
|
|
|
effects: track.effectChain.effects.map((e) =>
|
|
|
|
|
e.id === effectId ? { ...e, parameters } : e
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
onUpdateTrack(track.id, { effectChain: updatedChain });
|
|
|
|
|
}}
|
feat: add EffectBrowser dialog for adding effects to tracks
Created a beautiful effect browser dialog inspired by Ableton Live:
**EffectBrowser Component:**
- Modal dialog with search functionality
- Effects organized by category:
- Dynamics (Compressor, Limiter, Gate)
- Filters (Lowpass, Highpass, Bandpass, etc.)
- Time-Based (Delay, Reverb, Chorus, Flanger, Phaser)
- Distortion (Distortion, Bitcrusher)
- Pitch & Time (Pitch Shifter, Time Stretch)
- Utility (Normalize, Fade In/Out, Reverse)
- Grid layout with hover effects
- Real-time search filtering
- Click effect to add to track
**Integration:**
- "+" button in track strip opens EffectBrowser dialog
- Selecting an effect adds it to the track's effect chain
- Effects appear immediately in the Devices section
- Full enable/disable and remove functionality
**UX Flow:**
1. Click "+" in track Devices section
2. Browse or search for effect
3. Click effect to add it
4. Effect appears in Devices list
5. Toggle on/off with ●/○
6. Remove with × button
Effects are now fully manageable in the UI! Next: Apply them to audio.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 08:02:21 +01:00
|
|
|
onAddEffect={(effectType) => {
|
|
|
|
|
const newEffect = createEffect(
|
|
|
|
|
effectType,
|
|
|
|
|
EFFECT_NAMES[effectType]
|
|
|
|
|
);
|
|
|
|
|
const updatedChain = {
|
|
|
|
|
...track.effectChain,
|
|
|
|
|
effects: [...track.effectChain.effects, newEffect],
|
|
|
|
|
};
|
|
|
|
|
onUpdateTrack(track.id, { effectChain: updatedChain });
|
|
|
|
|
}}
|
2025-11-18 13:05:05 +01:00
|
|
|
onSelectionChange={
|
|
|
|
|
onSelectionChange
|
|
|
|
|
? (selection) => onSelectionChange(track.id, selection)
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
2025-11-17 20:59:36 +01:00
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-17 21:28:38 +01:00
|
|
|
{/* Import Dialog */}
|
|
|
|
|
{onImportTrack && (
|
|
|
|
|
<ImportTrackDialog
|
|
|
|
|
open={importDialogOpen}
|
|
|
|
|
onClose={() => setImportDialogOpen(false)}
|
|
|
|
|
onImportTrack={handleImportTrack}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-11-17 20:59:36 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|