User-Defined Opcode Database

stereoRotate

Stereo 'panning' using the middle-side technique.

Download UDO File

Description

Rotates a stereo image. It uses M/S methods to create a natural-sounding way to rotate the stereo image, as if you were rotating a stand holding a stereo microphone.

Syntax

al, ar stereoRotate ainl, ainr, kangle

Initialization

ainl, ainr -- input audio signal

kangle -- the angle of rotation in degrees, usually in the range of -45 to +45. Negative values result in a rotation rightward. Positive values rotate leftward.

Code

opcopcode stereoRotate, aa, aak

	ainl, ainr, ktheta xin

	; constants
	ipi		=	3.141592653589793
	iradfac	=	ipi/180

	;compute coeffs
	ktheta	=	iradfac*ktheta
	kstheta	=	sin(ktheta)
	kctheta	=	cos(ktheta)
	
	;Do Rotate
	aoutl		=	kctheta*ainl + kstheta*ainr
	aoutr		=	-kstheta*ainl + kctheta*ainr

	xout aoutl, aoutr

endop	

Examples

instr 1

ainl, ainr ins
aoutl, aoutr stereoRotate ainl, ainr, -45 ; rotate 45 degrees to the right
outs aoutl, aoutr

endin

Credits

Joseph Anderson and ma++, jan 2005, revised 2011


Previous Home Next
stereoMS   stereoBformat