Getting there
This commit is contained in:
parent
ed5a4379db
commit
f300dbd394
43 changed files with 1213 additions and 459 deletions
|
|
@ -121,19 +121,19 @@ export class GardenAudioGraph {
|
|||
);
|
||||
}
|
||||
|
||||
public applyDelayProfile(): void {
|
||||
public applyDelayProfile(bpm: number): void {
|
||||
if (!this.context || !this.delayNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.delayNode.delayTime.setTargetAtTime(
|
||||
this.config.delay.timeSeconds,
|
||||
this.getDelayTimeSecondsForBpm(bpm),
|
||||
this.context.currentTime,
|
||||
this.config.delay.timeRampSeconds
|
||||
);
|
||||
}
|
||||
|
||||
public updateDelay(activity: number): void {
|
||||
public updateDelay(activity: number, bpm: number): void {
|
||||
if (!this.context || !this.delayNode || !this.delayFeedback || !this.delayOutput) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ export class GardenAudioGraph {
|
|||
const now = this.context.currentTime;
|
||||
const normalizedActivity = clamp(activity, 0, 1);
|
||||
this.delayNode.delayTime.setTargetAtTime(
|
||||
this.config.delay.timeSeconds,
|
||||
this.getDelayTimeSecondsForBpm(bpm),
|
||||
now,
|
||||
this.config.delay.timeRampSeconds
|
||||
);
|
||||
|
|
@ -214,7 +214,7 @@ export class GardenAudioGraph {
|
|||
const feedbackLowPass = context.createBiquadFilter();
|
||||
const returnLowPass = context.createBiquadFilter();
|
||||
|
||||
delayNode.delayTime.value = this.config.delay.timeSeconds;
|
||||
delayNode.delayTime.value = this.getDelayTimeSecondsForBpm(this.config.rhythm.bpm);
|
||||
delayFeedback.gain.value = this.config.delay.feedback;
|
||||
delayOutput.gain.value = this.config.delay.wetGain;
|
||||
feedbackHighPass.type = 'highpass';
|
||||
|
|
@ -283,6 +283,15 @@ export class GardenAudioGraph {
|
|||
});
|
||||
}
|
||||
|
||||
private getDelayTimeSecondsForBpm(bpm: number): number {
|
||||
const safeBpm = Number.isFinite(bpm) ? Math.max(1, bpm) : this.config.rhythm.bpm;
|
||||
return clamp(
|
||||
(60 / safeBpm) * this.config.delay.timeBeats,
|
||||
this.config.delay.timeMinSeconds,
|
||||
this.config.delay.timeMaxSeconds
|
||||
);
|
||||
}
|
||||
|
||||
private createNoiseBuffer(context: AudioContext): AudioBuffer {
|
||||
const buffer = context.createBuffer(
|
||||
1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue