Enhance FM synthesis + cleaning code architecture

This commit is contained in:
2025-10-06 13:48:14 +02:00
parent 324cf9d2ed
commit ff5add97e8
38 changed files with 893 additions and 548 deletions

View File

@@ -1,11 +1,16 @@
import type { TileState } from '../types/tiles'
import { getDefaultEngineValues, getDefaultEffectValues } from '../config/effects'
import { getDefaultEngineValues, getDefaultEffectValues } from '../config/parameters'
import { getDefaultLFOValues } from '../stores/settings'
export interface FMPatchConfig {
algorithm: number
feedback: number
lfoRates: [number, number, number, number]
pitchLFO: {
waveform: number
depth: number
baseRate: number
}
}
export function generateRandomFMPatch(complexity: number = 1): FMPatchConfig {
@@ -32,7 +37,13 @@ export function generateRandomFMPatch(complexity: number = 1): FMPatchConfig {
0.25 + Math.random() * 0.9
]
return { algorithm, feedback, lfoRates }
const pitchLFO = {
waveform: Math.floor(Math.random() * 4),
depth: Math.random() < 0.4 ? 0.03 + Math.random() * 0.22 : 0,
baseRate: 0.1 + Math.random() * 9.9
}
return { algorithm, feedback, lfoRates, pitchLFO }
}
export function createFMTileState(patch: FMPatchConfig): TileState {