Ajout du sampler et de l'input
This commit is contained in:
31
src/lib/audio/processors/PhaseInverter.ts
Normal file
31
src/lib/audio/processors/PhaseInverter.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import type { AudioProcessor } from "./AudioProcessor";
|
||||
|
||||
export class PhaseInverter implements AudioProcessor {
|
||||
getName(): string {
|
||||
return "Phase Inverter";
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return "Inverts polarity of one or both channels";
|
||||
}
|
||||
|
||||
async process(
|
||||
leftChannel: Float32Array,
|
||||
rightChannel: Float32Array
|
||||
): Promise<[Float32Array, Float32Array]> {
|
||||
const mode = Math.floor(Math.random() * 3);
|
||||
|
||||
const newLeft = new Float32Array(leftChannel.length);
|
||||
const newRight = new Float32Array(rightChannel.length);
|
||||
|
||||
const invertLeft = mode === 0 || mode === 2;
|
||||
const invertRight = mode === 1 || mode === 2;
|
||||
|
||||
for (let i = 0; i < leftChannel.length; i++) {
|
||||
newLeft[i] = invertLeft ? -leftChannel[i] : leftChannel[i];
|
||||
newRight[i] = invertRight ? -rightChannel[i] : rightChannel[i];
|
||||
}
|
||||
|
||||
return [newLeft, newRight];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user