Ajout du sampler et de l'input
This commit is contained in:
31
src/lib/audio/processors/StereoWidener.ts
Normal file
31
src/lib/audio/processors/StereoWidener.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import type { AudioProcessor } from "./AudioProcessor";
|
||||
|
||||
export class StereoWidener implements AudioProcessor {
|
||||
getName(): string {
|
||||
return "Stereo Widener";
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return "Expands stereo field using mid-side processing";
|
||||
}
|
||||
|
||||
async process(
|
||||
leftChannel: Float32Array,
|
||||
rightChannel: Float32Array
|
||||
): Promise<[Float32Array, Float32Array]> {
|
||||
const widthFactor = 1.5 + Math.random() * 1.5;
|
||||
|
||||
const newLeft = new Float32Array(leftChannel.length);
|
||||
const newRight = new Float32Array(rightChannel.length);
|
||||
|
||||
for (let i = 0; i < leftChannel.length; i++) {
|
||||
const mid = (leftChannel[i] + rightChannel[i]) * 0.5;
|
||||
const side = (leftChannel[i] - rightChannel[i]) * 0.5 * widthFactor;
|
||||
|
||||
newLeft[i] = mid + side;
|
||||
newRight[i] = mid - side;
|
||||
}
|
||||
|
||||
return [newLeft, newRight];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user