«Input Reverser Pseudo UGen» by michaeldzjap

on 09 Aug'19 17:08 in delayreverse

A pseudo UGen for reversing input. The dur argument determines the size of the buffer from which the reverse signal will be read.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Reverser {

	*ar { arg input, dur = 2;
		var channels, buffer, length, signal, phase, trig, flop;

                channels = input.isKindOf(Array).if { input.size } { 1 };
		buffer = { LocalBuf(dur * SampleRate.ir + BlockSize.ir, channels).clear } ! 2;
		length = BufFrames.ir(buffer.first);

		trig = [0, 0.5] collect: { |i| Impulse.ar(0.25, i) };
		flop = 2 collect: { |i| SetResetFF.ar(*trig.rotate(i)) };

		phase = flop collect: { |f, i| Phasor.ar(trig[i], 1, 0, length, 0) * f };
		phase do: { |p, i| BufWr.ar(input, buffer[i], length - p) };

		signal = (phase.reverse collect: { |p, i|
			var j = i + 1 % 2;

			BufRd.ar(channels, buffer[i], p) * flop[j] * EnvGen.ar(Env([0, 1, 1, 0], dur * [0.05, 0.9, 0.05]), trig[j])
		}).sum;

		^signal;
	}

}
raw 780 chars (focus & ctrl+a+c to copy)
reception
comments