Adding more effects
This commit is contained in:
27
src/lib/audio/processors/Reverser.ts
Normal file
27
src/lib/audio/processors/Reverser.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import type { AudioProcessor } from './AudioProcessor';
|
||||
|
||||
export class Reverser implements AudioProcessor {
|
||||
getName(): string {
|
||||
return 'Reverser';
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return 'Plays the sound backwards';
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user