Include.pcm_split.File "/common/pcm/split.conf"

Macro [
	{
		SplitPCM {
			Name "scarlett2i_mono_in"
			Direction Capture
			Format S32_LE
			Channels 1
			HWChannels 2
			HWChannelPos0 MONO
			HWChannelPos1 MONO
		}
	}
]

If.2i4 {
	Condition {
		Type String
		String1 "${var:PlaybackChannels}"
		String2 "4"
	}
	True.Macro [
		{
			SplitPCM {
				Name "scarlett2i_stereo_out"
				Direction Playback
				Format S32_LE
				Channels 2
				HWChannels 4
				HWChannelPos0 FL
				HWChannelPos1 FR
				HWChannelPos2 FL
				HWChannelPos3 FR
			}
		}
	]
}

SectionDevice."Line1" {
	Comment "${var:Playback1Name}"

	Value {
		PlaybackPriority 200
	}
	If.2i4 {
		Condition {
			Type String
			String1 "${var:PlaybackChannels}"
			String2 "4"
		}
		True.Macro.pcm_split.SplitPCMDevice {
			Name "scarlett2i_stereo_out"
			Direction Playback
			HWChannels 4
			Channels 2
			Channel0 0
			Channel1 1
			ChannelPos0 FL
			ChannelPos1 FR
		}
		False.Value {
			PlaybackPCM "hw:${CardId}"
		}
	}
}

If.2i4 {
	Condition {
		Type String
		String1 "${var:PlaybackChannels}"
		String2 "4"
	}
	True.SectionDevice."Line2" {
		Comment "${var:Playback2Name}"

		Value {
			PlaybackPriority 100
		}
		Macro.pcm_split.SplitPCMDevice {
			Name "scarlett2i_stereo_out"
			Direction Playback
			HWChannels 4
			Channels 2
			Channel0 2
			Channel1 3
			ChannelPos0 FL
			ChannelPos1 FR
		}
	}
}

SectionDevice."Mic1" {
	Comment "${var:Capture1Name}"

	Value {
		CapturePriority 200
	}
	Macro.pcm_split.SplitPCMDevice {
		Name "scarlett2i_mono_in"
		Direction Capture
		HWChannels 2
		Channels 1
		Channel0 0
		ChannelPos0 MONO
	}
}

SectionDevice."Mic2" {
	Comment "${var:Capture2Name}"

	Value {
		CapturePriority 100
	}
	Macro.pcm_split.SplitPCMDevice {
		Name "scarlett2i_mono_in"
		Direction Capture
		HWChannels 2
		Channels 1
		Channel0 1
		ChannelPos0 MONO
	}
}
