Initial CoolSoup implementation

CoolSoup is a React + TypeScript + Vite application that generates visual patterns and converts them to audio through spectral synthesis. Features multiple image generators (Tixy expressions, geometric tiles, external APIs) and an advanced audio synthesis engine that treats images as spectrograms.
This commit is contained in:
2025-09-29 14:44:48 +02:00
parent b564e41820
commit 623082ce3b
79 changed files with 6247 additions and 951 deletions

View File

@ -0,0 +1,55 @@
import type { GeneratedImage } from '../stores'
import { processPhoto } from './from-photo-generator'
export async function generateFromPhotoImage(file: File, size: number): Promise<GeneratedImage> {
try {
const result = await processPhoto(file, {
targetSize: size,
contrastEnhancement: true,
grayscaleConversion: true
})
const image: GeneratedImage = {
id: `from-photo-${Date.now()}`,
canvas: result.canvas,
imageData: result.imageData,
generator: 'from-photo',
params: {
fileName: file.name,
fileSize: file.size,
fileType: file.type,
processedAt: new Date().toISOString(),
size,
contrastEnhanced: true,
grayscaleConverted: true
}
}
return image
} catch (error) {
console.error('Failed to process photo:', error)
// Fallback: create a black canvas
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')!
canvas.width = size
canvas.height = size
ctx.fillStyle = '#000000'
ctx.fillRect(0, 0, size, size)
const imageData = ctx.getImageData(0, 0, size, size)
const fallbackImage: GeneratedImage = {
id: `from-photo-error-${Date.now()}`,
canvas,
imageData,
generator: 'from-photo',
params: {
fileName: file.name,
error: error instanceof Error ? error.message : 'Unknown error',
size
}
}
return fallbackImage
}
}