Skip to main content

ClipTrack

Represents a track containing multiple audio clips in the multi-track editing model.

Import

import type { ClipTrack } from '@waveform-playlist/core';

Type Definition

interface ClipTrack {
  id: string;
  name: string;
  clips: AudioClip[];
  muted: boolean;
  soloed: boolean;
  volume: number;
  pan: number;
  color?: string;
  height?: number;
  effects?: TrackEffectsFunction;
  renderMode?: RenderMode;
  spectrogramConfig?: SpectrogramConfig;
  spectrogramColorMap?: ColorMapValue;
}

Properties

id
string
required
Unique identifier for this track
name
string
required
Display name for this track
clips
AudioClip[]
required
Array of audio clips on this track. See Clip Types for details.
muted
boolean
required
Whether this track is muted
soloed
boolean
required
Whether this track is soloed (only soloed tracks play when any track is soloed)
volume
number
required
Track volume level (0.0 to 1.0+)
pan
number
required
Stereo pan position (-1.0 = left, 0 = center, 1.0 = right)
color
string
Optional color for visual distinction in the UI (any CSS color value)
height
number
Track height in pixels for the UI
effects
TrackEffectsFunction
Optional effects processing function for this track. See Effects Types for details.
renderMode
RenderMode
Visualization render mode. Default: ‘waveform’. Can be ‘waveform’ or ‘spectrogram’.
spectrogramConfig
SpectrogramConfig
Per-track spectrogram configuration (FFT size, window type, frequency scale, etc.)
spectrogramColorMap
ColorMapValue
Per-track spectrogram color map name or custom color array

Track Factory

Create a new track with sensible defaults using the createTrack helper function.

Import

import { createTrack } from '@waveform-playlist/core';

Function Signature

function createTrack(options: CreateTrackOptions): ClipTrack

Options

interface CreateTrackOptions {
  name: string;
  clips?: AudioClip[];
  muted?: boolean;
  soloed?: boolean;
  volume?: number;
  pan?: number;
  color?: string;
  height?: number;
  spectrogramConfig?: SpectrogramConfig;
  spectrogramColorMap?: ColorMapValue;
}

Example

import { createTrack } from '@waveform-playlist/core';

const track = createTrack({
  name: 'Vocals',
  clips: [],
  volume: 0.8,
  pan: 0,
  muted: false,
  soloed: false,
  color: '#3b82f6',
  height: 128
});

Timeline

Represents the entire multi-track project/timeline.

Import

import type { Timeline } from '@waveform-playlist/core';

Type Definition

interface Timeline {
  tracks: ClipTrack[];
  duration: number;
  sampleRate: number;
  name?: string;
  tempo?: number;
  timeSignature?: {
    numerator: number;
    denominator: number;
  };
}

Properties

tracks
ClipTrack[]
required
All tracks in the timeline
duration
number
required
Total timeline duration in seconds
sampleRate
number
required
Sample rate for all audio (typically 44100 or 48000)
name
string
Optional project name
tempo
number
Optional tempo in BPM for grid snapping
timeSignature
object
Optional time signature for grid snapping

Example

import { createTimeline, createTrack } from '@waveform-playlist/core';

const track1 = createTrack({ name: 'Track 1' });
const track2 = createTrack({ name: 'Track 2' });

const timeline = createTimeline(
  [track1, track2],
  44100,
  {
    name: 'My Project',
    tempo: 120,
    timeSignature: { numerator: 4, denominator: 4 }
  }
);

Legacy Track Interface

The library also supports a simpler single-track model for backward compatibility.

Import

import type { Track } from '@waveform-playlist/core';

Type Definition

interface Track {
  id: string;
  name: string;
  src?: string | AudioBuffer;
  gain: number;
  muted: boolean;
  soloed: boolean;
  stereoPan: number;
  startTime: number;
  endTime?: number;
  fadeIn?: Fade;
  fadeOut?: Fade;
  cueIn?: number;
  cueOut?: number;
}
This interface is maintained for backward compatibility. For new projects, use the clip-based model with ClipTrack and AudioClip instead.

Build docs developers (and LLMs) love