Adding more effects

This commit is contained in:
2025-10-11 16:47:20 +02:00
parent be7ba5fad8
commit 7f150e8bb4
19 changed files with 2495 additions and 9 deletions

View File

@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
This is a Svelte + TypeScript audio synthesis application that generates and manipulates sounds using various synthesis recipes (modes). Each recipe is a different flavour of audio synthesis, generating random audio samples that musicians can use in their compositions. Users can generate random sounds, mutate existing ones, visualize waveforms, and export audio as WAV files.
This is a Svelte + TypeScript audio synthesis application that generates and manipulates sounds using various synthesis recipes (modes). Each recipe is a different flavour of audio synthesis, generating random audio samples that musicians can use in their compositions. Users can generate random sounds, mutate existing ones, apply audio processors to transform sounds, visualize waveforms, and export audio as WAV files.
## Build System
@ -19,21 +19,28 @@ This is a Svelte + TypeScript audio synthesis application that generates and man
### Audio Pipeline
The audio system follows a layered architecture:
The audio system follows a layered architecture: **Engine → Processor → Output**
1. **SynthEngine interface** (`src/lib/audio/engines/SynthEngine.ts`): Abstract interface for synthesis engines
- Defines `generate()`, `randomParams()`, and `mutateParams()` methods
- All engines must generate stereo output: `[Float32Array, Float32Array]`
- Time-based parameters (envelopes, LFOs) stored as ratios (0-1) and scaled by duration during generation
2. **Engines**
2. **Engines**: Registered in `src/lib/audio/engines/registry.ts`
3. **AudioService** (`src/lib/audio/services/AudioService.ts`): Web Audio API wrapper
3. **AudioProcessor interface** (`src/lib/audio/processors/AudioProcessor.ts`): Abstract interface for audio processors
- Defines `process()` method that transforms existing audio buffers
- Takes stereo input and returns stereo output: `[Float32Array, Float32Array]`
- Applied after engine generation, before final output
4. **Processors**: Registered in `src/lib/audio/processors/registry.ts`
5. **AudioService** (`src/lib/audio/services/AudioService.ts`): Web Audio API wrapper
- Manages AudioContext, gain node, and playback
- Provides playback position tracking via animation frames
- Fixed sample rate: 44100 Hz
4. **WAVEncoder** (`src/lib/audio/utils/WAVEncoder.ts`): Audio export functionality
6. **WAVEncoder** (`src/lib/audio/utils/WAVEncoder.ts`): Audio export functionality
### State Management
@ -64,6 +71,27 @@ The audio system follows a layered architecture:
8. **Register the engine** by adding it to the `engines` array in `src/lib/audio/engines/registry.ts`
9. The mode buttons in the UI will automatically update to include your new engine
### Adding New Audio Processors
**CRITICAL: Each processor must be completely self-contained in a single file.** Do not create separate utility files, helper classes, or subdirectories for processor components. All DSP code, algorithms, and processing logic should be private methods within the processor class.
1. Implement the `AudioProcessor` interface in a single file under `src/lib/audio/processors/`
2. Implement `getName()` to return the processor's display name
3. Implement `getDescription()` to return a brief description of the processor
4. Ensure `process()` takes stereo input and returns stereo output: `[Float32Array, Float32Array]`
5. Processors operate on existing audio buffers and should not generate new sounds from scratch
6. Keep all helper functions, enums, and types in the same file
7. **Register the processor** by adding it to the `processors` array in `src/lib/audio/processors/registry.ts`
8. Processors are randomly selected when the user clicks "Process"
### User Workflow
1. **Generate**: User clicks "Random" to generate a raw, unprocessed sound using the current engine
2. **Refine**: User can "Mutate" the sound (adjusting parameters) or generate a new random sound
3. **Process**: User clicks "Process" to apply a random audio processor to the sound
4. **Iterate**: After processing, "Mutate" disappears but "Process" remains available for multiple processing passes
5. **Reset**: Clicking "Random" generates a new raw sound and returns to the initial state
### Duration Handling
Duration is user-adjustable. All time-based synthesis parameters (attack, decay, release, LFO rates) must scale with duration. Store envelope timings as ratios of total duration, not absolute seconds.