clean interface
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import type { SynthEngine } from './SynthEngine';
|
||||
import type { SynthEngine, PitchLock } from './SynthEngine';
|
||||
|
||||
enum EnvCurve {
|
||||
Linear,
|
||||
@ -380,9 +380,11 @@ export class AdditiveEngine implements SynthEngine<AdditiveParams> {
|
||||
}
|
||||
}
|
||||
|
||||
randomParams(): AdditiveParams {
|
||||
randomParams(pitchLock?: PitchLock): AdditiveParams {
|
||||
const baseFreqChoices = [55, 82.4, 110, 146.8, 220, 293.7, 440, 587.3, 880];
|
||||
const baseFreq = this.randomChoice(baseFreqChoices) * this.randomRange(0.95, 1.05);
|
||||
const baseFreq = pitchLock?.enabled
|
||||
? pitchLock.frequency
|
||||
: this.randomChoice(baseFreqChoices) * this.randomRange(0.95, 1.05);
|
||||
|
||||
const harmonicSeriesType = this.randomInt(0, 3) as HarmonicSeriesType;
|
||||
const distributionStrategy = this.randomInt(0, 9) as DistributionStrategy;
|
||||
@ -514,7 +516,7 @@ export class AdditiveEngine implements SynthEngine<AdditiveParams> {
|
||||
};
|
||||
}
|
||||
|
||||
mutateParams(params: AdditiveParams, mutationAmount: number = 0.15): AdditiveParams {
|
||||
mutateParams(params: AdditiveParams, mutationAmount: number = 0.15, pitchLock?: PitchLock): AdditiveParams {
|
||||
const newHarmonicSeriesType = Math.random() < 0.08 ? this.randomInt(0, 3) as HarmonicSeriesType : params.harmonicSeriesType;
|
||||
const newDistributionStrategy = Math.random() < 0.08 ? this.randomInt(0, 9) as DistributionStrategy : params.distributionStrategy;
|
||||
const ratios = this.generateRatiosForStrategy(newDistributionStrategy);
|
||||
@ -530,8 +532,10 @@ export class AdditiveEngine implements SynthEngine<AdditiveParams> {
|
||||
}
|
||||
}
|
||||
|
||||
const baseFreq = pitchLock?.enabled ? pitchLock.frequency : params.baseFreq;
|
||||
|
||||
return {
|
||||
baseFreq: params.baseFreq,
|
||||
baseFreq,
|
||||
partials: newPartials,
|
||||
stereoWidth: this.mutateValue(params.stereoWidth, mutationAmount, 0, 1),
|
||||
brightness: this.mutateValue(params.brightness, mutationAmount, 0, 1),
|
||||
|
||||
Reference in New Issue
Block a user