<?xml version="1.0"?>
<BeHappy.Extension xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://workspaces.gotdotnet.com/behappy">
	<AudioDSP UniqueID="9579E57B-2D27-4583-99A4-921718E25B41">
		<Plugin>
			<MultiOptionDSP Type="BeHappy.Extensions.MultiOptionDSP, BeHappy">
				<DialogWidth>450</DialogWidth>				
				<TitleFormatString>5.1 Upmix - {0}</TitleFormatString>
				<ScriptPrologue>
					# Store clip in variable
					Stereo_{2} = last
					function f{2}(clip a) {3}
				</ScriptPrologue>
				<Option>
					<ToolTip>
						Profile to use with audio sources that have mostly mono content. 20ms delay and -3db attenuation on surround
						Note: the center channel is very weak for this profile
					</ToolTip>
					<Name>Audio with mostly dialog (ie. Comedy, Drama)</Name>
					<Value>
						# Profile to use with audio sources that have mostly mono content. 20ms delay and -3db attenuation on surround
						# Note: the center channel is very weak for this profile
						front = a.soxfilter("filter 20-20000")
						back = a.soxfilter("filter 100-7000")
						fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.794,-0.794)
						fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.794,-0.794)
						cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.224,0.224)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.596")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.562,-0.562)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.562,-0.562)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<Option default="true">
					<ToolTip>
						Profile to use with audio sources that have a wider range of sound content. 20ms delay and -3db attenuation on surround
						Note: General purpose profile
					</ToolTip>					
					<Name>Audio with a mix of sounds (ie. Action, Adventure)</Name>
					<Value>
						# Profile to use with audio sources that have a wider range of sound content. 20ms delay and -3db attenuation on surround
						# Note: General purpose profile
						front = a.soxfilter("filter 20-20000")
						back = a.soxfilter("filter 100-7000")
						fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.668,-0.668)
						fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.668,-0.668)
						cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.398,0.398)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.447")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.473,-0.473)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.473,-0.473)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<Option>
					<ToolTip>
						Gerzen approach Profile modified with 20ms delay and some attenuation on surround
					</ToolTip>
					<Name>Gerzen Profile</Name>
					<Value>
						# Gerzen approach Profile modified with 20ms delay and some attenuation on surround
						front = a.soxfilter("filter 20-20000")
						back = a.soxfilter("filter 100-7000")
						fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.885,-0.115)
						fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.885,-0.115)
						cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.4511,0.4511)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<Option>
					<ToolTip>
						Farina/Sursound approach Profile M=L+R, S=L-R, c=0.75, L' = (1-c/4)*M+(1+c/4)*S, C' = c*M, R' = (1-c/4)*M-(1+c/4)*S
						also added with 20ms delay and some attenuation on surround
					</ToolTip>					
					<Name>Farina Profile</Name>
					<Value>
						# Farina/Sursound approach Profile M=L+R, S=L-R, c=0.75, L' = (1-c/4)*M+(1+c/4)*S, C' = c*M, R' = (1-c/4)*M-(1+c/4)*S
						# also added with 20ms delay and some attenuation on surround
						front = a.soxfilter("filter 20-20000")
						back = a.soxfilter("filter 100-7000")
						fl = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,1.1875)
						fr = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,-1.1875)
						cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.375,0.375)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<Option>
					<ToolTip>
						Multisonic approach Profile modified with 20ms delay and some attenuation on surround
					</ToolTip>					
					<Name>Multisonic Profile</Name>
					<Value>
						# Multisonic approach Profile modified with 20ms delay and some attenuation on surround
						front = a.soxfilter("filter 20-20000")
						back = a.soxfilter("filter 100-7000")
						fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),1,-0.5)
						fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),1,-0.5)
						cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.5,0.5)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<Option>
					<ToolTip>
						SOS approach Profile with 20ms delay and some attenuation on surround
					</ToolTip>					
					<Name>Sound On Sound Profile</Name>
					<Value>
						# SOS approach Profile with 20ms delay and some attenuation on surround
						back = a.soxfilter("filter 100-7000")
						fl = a.GetLeftChannel()
						fr = a.GetRightChannel()
						cc = mixaudio(a.GetRightChannel(),a.GetLeftChannel,0.5,0.5)
						lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
						sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
						sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
						sl = DelayAudio(sl,0.02)
						sr = DelayAudio(sr,0.02)
					</Value>
				</Option>
				<ScriptEpilogue>
					# Return result
					return MergeChannels( fl, fr, cc, lfe, sl, sr)
					{4}
					# Call function
					2==AudioChannels(Stereo_{2})?f{2}(ConvertAudioToFloat(Stereo_{2})):Stereo_{2}
				</ScriptEpilogue>
				<LogoBitmap> </LogoBitmap>
			</MultiOptionDSP>
		</Plugin>
	</AudioDSP>
</BeHappy.Extension>
