Cleaning the codebase
This commit is contained in:
20
CLAUDE.md
20
CLAUDE.md
@@ -16,12 +16,15 @@ CoolSoup is a React + TypeScript + Vite application that generates visual patter
|
||||
## Architecture Overview
|
||||
|
||||
### Core Application Structure
|
||||
|
||||
- **State Management**: Uses Nanostores for reactive state with persistent atoms
|
||||
- **UI Layout**: Two-panel design - main content area (generator + image grid) and collapsible audio panel
|
||||
- **Generator Pattern**: Pluggable generator system where each generator implements a common interface
|
||||
|
||||
### Main Store (`src/stores/index.ts`)
|
||||
|
||||
Central state management with these key atoms:
|
||||
|
||||
- `appSettings` - Generator selection, grid size, colors
|
||||
- `generatedImages` - Array of generated images with metadata
|
||||
- `selectedImage` - Current image for audio synthesis
|
||||
@@ -29,13 +32,16 @@ Central state management with these key atoms:
|
||||
- `panelOpen` - Audio panel visibility
|
||||
|
||||
### Generator System
|
||||
|
||||
Four built-in generators located in `src/generators/`:
|
||||
|
||||
- **Tixy** (`tixy.ts`) - Mathematical expressions using t,i,x,y variables
|
||||
- **Waveform** (`waveform.ts`) - Procedural random waveforms with various interpolation curves
|
||||
- **Picsum** (`picsum.ts`) - External random images API
|
||||
- **Art Institute** (`art-institute.ts`) - Art Institute of Chicago API
|
||||
|
||||
Each generator returns `GeneratedImage[]` with:
|
||||
|
||||
- `id` - Unique identifier
|
||||
- `canvas` - HTMLCanvasElement
|
||||
- `imageData` - ImageData for synthesis
|
||||
@@ -43,13 +49,16 @@ Each generator returns `GeneratedImage[]` with:
|
||||
- `params` - Generation parameters
|
||||
|
||||
### Spectral Synthesis Engine (`src/spectral-synthesis/`)
|
||||
|
||||
Advanced image-to-audio synthesis library:
|
||||
|
||||
- **Core Logic** (`core/synthesizer.ts`) - Main ImageToAudioSynthesizer class
|
||||
- **Types** (`core/types.ts`) - SynthesisParams and related interfaces
|
||||
- **Audio Export** (`audio/export.ts`) - WAV file generation and download
|
||||
- **Utilities** (`core/utils.ts`) - Helper functions for frequency mapping and peak detection
|
||||
|
||||
Key features:
|
||||
|
||||
- Mel-scale frequency mapping for perceptual accuracy
|
||||
- Spectral peak detection to reduce noise
|
||||
- Temporal smoothing for coherent audio trajectories
|
||||
@@ -57,7 +66,9 @@ Key features:
|
||||
- Configurable synthesis parameters (duration, frequency range, resolution)
|
||||
|
||||
### Audio Export System (`src/audio-export/`)
|
||||
|
||||
Batch audio processing capabilities:
|
||||
|
||||
- Single image export with custom parameters
|
||||
- Batch export of all generated images
|
||||
- ZIP file generation for batch downloads
|
||||
@@ -66,6 +77,7 @@ Batch audio processing capabilities:
|
||||
## Key Implementation Details
|
||||
|
||||
### Image Generation Flow
|
||||
|
||||
1. User selects generator and parameters in `GeneratorSelector`
|
||||
2. `App.tsx` calls appropriate generator function
|
||||
3. Generator returns array of `GeneratedImage` objects
|
||||
@@ -73,6 +85,7 @@ Batch audio processing capabilities:
|
||||
5. User can click image to select for audio synthesis
|
||||
|
||||
### Audio Synthesis Flow
|
||||
|
||||
1. User selects image from grid (sets `selectedImage`)
|
||||
2. `AudioPanel` provides synthesis parameter controls
|
||||
3. Synthesis triggered via spectral-synthesis library
|
||||
@@ -80,6 +93,7 @@ Batch audio processing capabilities:
|
||||
5. Batch export processes all generated images
|
||||
|
||||
### Component Architecture
|
||||
|
||||
- **App.tsx** - Main layout and generation orchestration
|
||||
- **GeneratorSelector** - Generator picker with settings
|
||||
- **ImageGrid** - Grid display of generated images
|
||||
@@ -87,15 +101,18 @@ Batch audio processing capabilities:
|
||||
- **AudioControls** - Playback controls for generated audio
|
||||
|
||||
## Generator Module Structure
|
||||
|
||||
Both tixy-generator and waveform-generator modules are designed as standalone packages:
|
||||
|
||||
**Tixy Generator**:
|
||||
|
||||
- `README.md` - Documentation and usage examples
|
||||
- `core/types.ts` - Type definitions
|
||||
- `index.ts` - Main exports
|
||||
- Generator-specific files (evaluator, patterns, etc.)
|
||||
|
||||
**Waveform Generator**:
|
||||
|
||||
- `README.md` - Documentation and usage examples
|
||||
- `core/types.ts` - Interfaces and configuration
|
||||
- `core/interpolation.ts` - Curve interpolation functions (linear, exponential, logarithmic, cubic)
|
||||
@@ -104,8 +121,9 @@ Both tixy-generator and waveform-generator modules are designed as standalone pa
|
||||
- `index.ts` - Main exports and convenience functions
|
||||
|
||||
## Development Notes
|
||||
|
||||
- Uses Rolldown Vite for improved performance
|
||||
- Tailwind CSS for styling (no rounded corners per user preference)
|
||||
- ESLint configured for React + TypeScript
|
||||
- All generators support time-based animation parameters
|
||||
- Image synthesis supports real-time parameter adjustment
|
||||
- Image synthesis supports real-time parameter adjustment
|
||||
|
||||
Reference in New Issue
Block a user