Working on processors a tiny bit

This commit is contained in:
2025-10-13 18:09:47 +02:00
parent 65a1e16781
commit 6116745795
48 changed files with 1138 additions and 174 deletions

View File

@ -0,0 +1,34 @@
import type { AudioProcessor, ProcessorCategory } from './AudioProcessor';
export class PanLeftToRight implements AudioProcessor {
getName(): string {
return 'Pan L→R';
}
getDescription(): string {
return 'Gradually pans the sound from left to right';
}
getCategory(): ProcessorCategory {
return 'Space';
}
process(leftIn: Float32Array, rightIn: Float32Array): [Float32Array, Float32Array] {
const length = leftIn.length;
const leftOut = new Float32Array(length);
const rightOut = new Float32Array(length);
for (let i = 0; i < length; i++) {
const t = i / length;
const panAngle = t * Math.PI * 0.5;
const leftGain = Math.cos(panAngle);
const rightGain = Math.sin(panAngle);
const mono = (leftIn[i] + rightIn[i]) * 0.5;
leftOut[i] = mono * leftGain;
rightOut[i] = mono * rightGain;
}
return [leftOut, rightOut];
}
}