feat: implement audio file splitting functionality

- Added `splitFile` method to `LibraryStore` for splitting audio files into segments.
- Introduced `SplitSegmentRequest` and `SegmentMetadataInput` interfaces in models for segment metadata handling.
- Created `EditModePanel` component for editing segments, including waveform visualization and metadata assignment.
- Developed `WaveformEditorCanvas` for interactive waveform editing, supporting segment creation and resizing.
- Enhanced metadata handling in IPC with new fields for author and copyright.
- Updated styles for new components and improved UI interactions.
This commit is contained in:
2025-11-11 02:45:34 +11:00
parent bb7d31e748
commit 781187c427
14 changed files with 1286 additions and 118 deletions

View File

@@ -45,7 +45,7 @@ export interface RendererApi {
/** Moves a file to another subdirectory under the library root. */
moveFile(fileId: number, targetRelativeDirectory: string): Promise<import('./models').AudioFileSummary>;
/** Automatically organizes a file based on its categories. */
organizeFile(fileId: number, metadata: { customName?: string | null; author?: string | null; rating?: number }): Promise<import('./models').AudioFileSummary>;
organizeFile(fileId: number, metadata: { customName?: string; author?: string; copyright?: string; rating?: number }): Promise<import('./models').AudioFileSummary>;
/** Updates the custom name for a file. */
updateCustomName(fileId: number, customName: string | null): Promise<import('./models').AudioFileSummary>;
/** Opens the file's containing folder in the system file explorer. */
@@ -63,11 +63,11 @@ export interface RendererApi {
/** Runs fuzzy search returning ranked results. */
search(query: string): Promise<import('./models').AudioFileSummary[]>;
/** Reads embedded metadata from a WAV file. */
readFileMetadata(fileId: number): Promise<{ author?: string; title?: string; rating?: number }>;
readFileMetadata(fileId: number): Promise<{ author?: string; copyright?: string; title?: string; rating?: number }>;
/** Lists distinct metadata values gathered from the library for quick suggestions. */
listMetadataSuggestions(): Promise<{ authors: string[] }>;
/** Updates metadata (author, rating) without organizing the file. */
updateFileMetadata(fileId: number, metadata: { author?: string | null; rating?: number }): Promise<void>;
listMetadataSuggestions(): Promise<{ authors: string[]; copyrights: string[] }>;
/** Updates metadata (author, copyright, rating) without organizing the file. */
updateFileMetadata(fileId: number, metadata: { author?: string; copyright?: string; rating?: number }): Promise<void>;
/** Listens for menu actions from the main process. Returns a cleanup function. */
onMenuAction(channel: string, callback: () => void): () => void;
}

View File

@@ -107,3 +107,33 @@ export interface AudioBufferPayload {
/** MIME type for the audio data. */
mimeType: string;
}
/**
* Optional metadata overrides applied while creating split segments.
*/
export interface SegmentMetadataInput {
/** Overrides the custom name embedded into the segment (null clears it). */
customName?: string | null;
/** Overrides the author/creator metadata. */
author?: string | null;
/** Overrides the rating metadata (1-5). */
rating?: number;
/** Overrides the applied free-form tags. */
tags?: string[];
/** Overrides the applied UCS categories. */
categories?: string[];
}
/**
* Describes a region that should be extracted as a new audio segment.
*/
export interface SplitSegmentRequest {
/** Inclusive start offset in milliseconds. */
startMs: number;
/** Exclusive end offset in milliseconds. */
endMs: number;
/** Optional display label used for segment naming. */
label?: string;
/** Metadata overrides to apply to the generated file. */
metadata?: SegmentMetadataInput;
}