Enhance FM synthesis + cleaning code architecture
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user