Mirror

Similar to hard clip in the use of a processing threshold, but in this case we mirror the signal (folding it back) when it exceeds the threshold. The signal is unmodified below the clipping threshold. This technique has no direct eqivalent in the analog processing domain, but we can use it as a crude emulation of the "rectifier" effect found in some analog distortion circuitry. To achieve the rectifier effect, we will use asymmetrical mirror thresholds (leaving the positive signal unmodified, only mirroring the negative part of the signal).

Signal flow

Audio signal graphs

A Sine wave
Mirror
Mirror rectify

Sound examples


440 Hz Sine wave, clean

440 Hz Sine wave, mirrored at a threshold of 0.9

440 Hz Sine wave, mirrored at a threshold of 0.6

440 Hz Sine wave, mirrored at a threshold of 0.3

440 Hz Sine wave, mirror rectified

Csound code

The following Csound code generates a sine wave and processes it by mirror clipping. The mirror threshold is set independently for the positive and negative parts of the signal. As in hard clipping, we set the threshold as a fraction of full level, so a threshold of 0.5 clips at 50% of full signal level. The output amplitude is adjusted with the use of makeup gain, so the output amplitude shouuld equal the input amplitude regardless of the mirror thresholds.

;***************************************************
; Mirror signal
;***************************************************
	instr	1

	iamp		= ampdbfs(p4)		; Amp in -dB
	icps		= p5			; Frequency for the tone generator
	iMirrorPos	= p6			; Mirror level, positive part
	iMirrorNeg	= p7			; Mirror level, negative part 
	iMakeupGain	= 1/iMirrorPos		; Make up for gain loss in clipping stage

; audio generator
	a1		oscili	1, icps, giSine

; mirror
	a1		mirror	a1, iMirrorNeg, iMirrorPos	; mirror signal at threshold

; output gain
	a1		= a1*iamp*iMakeupGain

; audio out
	outs		a1, a1
	endin
;***************************************************