32 lines
753 B
TypeScript
32 lines
753 B
TypeScript
import type { AudioProcessor, ProcessorCategory } from './AudioProcessor';
|
|
|
|
export class Reverser implements AudioProcessor {
|
|
getName(): string {
|
|
return 'Reverser';
|
|
}
|
|
|
|
getDescription(): string {
|
|
return 'Plays the sound backwards';
|
|
}
|
|
|
|
getCategory(): ProcessorCategory {
|
|
return 'Time';
|
|
}
|
|
|
|
process(
|
|
leftChannel: Float32Array,
|
|
rightChannel: Float32Array
|
|
): [Float32Array, Float32Array] {
|
|
const length = leftChannel.length;
|
|
const outputLeft = new Float32Array(length);
|
|
const outputRight = new Float32Array(length);
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
outputLeft[i] = leftChannel[length - 1 - i];
|
|
outputRight[i] = rightChannel[length - 1 - i];
|
|
}
|
|
|
|
return [outputLeft, outputRight];
|
|
}
|
|
}
|