<plugin resizable="true">
	<!-- Compute number of audio channels for processing -->
	<ui:set id="channels"
		value="${(ex :out_4) ? 4 :
		(ex :out_2) ? 2 : 1}" />

	<grid rows="2" cols="3" spacing="4">
		<!-- Graph -->
		<vbox spacing="4" expand="true">
			<group ui:inject="GraphGroup" ipadding="0" expand="true"
				fill="true" text="labels.graphs.spectrum">
				<graph width.min="320" height.min="200" expand="true">
					<origin hpos="-1" vpos="-1" visible="false" />

					<!-- Gray grid -->
					<ui:with ox="0" oy="1">
						<ui:for id="f" first="20" last="90" step="10">
							<marker v="${f}" color="graph_alt_1" />
							<marker v="${:f*10}" color="graph_alt_1" />
							<marker v="${:f*100}" color="graph_alt_1" />
						</ui:for>
						<marker value="20000" color="graph_alt_1" />
					</ui:with>
					<ui:for id="g" first="-36" last="36" step="24">
						<marker v="${g} db" ox="1" oy="0" color="graph_alt_1" />
					</ui:for>
					<ui:for id="g" first="-18" last="18" step="12">
						<marker v="${g} db" ox="1" oy="0" color="graph_alt_1"
							visibility=":zoom le -18 db" />
					</ui:for>
					<ui:for id="g" first="-9" last="9" step="6">
						<marker v="${g} db" ox="1" oy="0" color="graph_alt_1"
							visibility=":zoom le -33 db" />
					</ui:for>

					<!-- Yellow grid -->
					<ui:with ox="0" oy="1" color="graph_sec">
						<marker v="100" />
						<marker v="1000" />
						<marker v="10000" />
					</ui:with>
					<ui:with ox="1" oy="0" color="graph_sec">
						<marker v="+24 db" />
						<marker v="0 db" />
						<marker v="-24 db" />
					</ui:with>

					<!-- Piano keys -->
					<embed oy="3" start.x="midi_freq_start(12, 127)" start.y="20" end.x="midi_freq_end(12, 127)" end.y="44" valign="1" alpha="0" visibility=":_ui_graph_piano_layout">
						<piano natural="false" note.min="12" note.max="127" height="24" editable="false" selectable="false" border="0"/>
					</embed>

					<!-- Octave text -->
					<ui:with ox="0" oy="3" y="44" halign="1" valign="1" pgroup="0" priority="10" visibility=":_ui_graph_piano_layout" pad.b="2">
						<ui:for id="octave" first="0" last="9">
							<text x="midi_freq(12 * ${:octave + 1})" text="lists.notes.fmt.c" text:octave="${octave}" valign="1" halign="0"/>
						</ui:for>
					</ui:with>

					<!-- Meshes -->
					<ui:for id="i" first="1" count="4">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<mesh id="isg_${i}" width="2" smooth="true"
							color="graph_mesh_cycle" color.hue="${hue}"
							visibility=":ffti and :ffti_${i}" />
					</ui:for>
					<ui:for id="i" first="1" count="4">
						<ui:set id="hue" value="${(:i-1)/4.0}" />
						<mesh id="nsc_${i}" width="2" smooth="true"
							color="graph_mesh_cycle" color.hue="${hue}" fill="true"
							fcolor="graph_mesh_cycle" fcolor.hue="${hue}" fcolor.a="0.8" />
						<mesh id="nsg_${i}" width="2" smooth="true"
							color="graph_mesh_cycle" color.hue="${hue}"
							visibility=":fftg and :fftg_${i}" />
					</ui:for>

					<ui:for id="i" first="1" count="4">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<mesh id="osg_${i}" width="2" smooth="true"
							color="graph_mesh_cycle" color.hue="${hue}"
							visibility=":ffto and :ffto_${i}" />
					</ui:for>

					<!-- Boundaries -->
					<marker ox="2" oy="0" v="1" color="graph_prim"
						visibility="false" />
					<!-- +48 dB -->
					<marker ox="0" oy="1" v="24000" color="graph_prim"
						visibility="false" />

					<!-- Axis -->
					<axis min="10" max="24000" color="graph_prim" angle="0.0"
						log="true" visibility="false" />
					<axis min="-48 db / :zoom" max="48 db * :zoom"
						color="graph_prim" angle="0.5" log="true" visibility="false" />
					<!-- -48..+48 dB -->
					<axis min="-1" max="1" visible="false" angle="0.5" />
					<axis min="0" max=":_a_scaled_height" visibility="false" angle="0.5"/>

					<!-- Text -->
					<ui:with ox="0" oy="2" y="0" halign="1" valign="1">
						<text x="10" text="graph.units.hz" />
						<text x="20" text="20" />
						<text x="30" text="30" />
						<text x="50" text="50" />
						<text x="100" text="100" />
						<text x="200" text="200" />
						<text x="300" text="300" />
						<text x="500" text="500" />
						<text x="1000" text="graph.values.x_k" text:value="1" />
						<text x="2000" text="graph.values.x_k" text:value="2" />
						<text x="3000" text="graph.values.x_k" text:value="3" />
						<text x="5000" text="graph.values.x_k" text:value="5" />
						<text x="10000" text="graph.values.x_k" text:value="10" />
						<text x="20000" text="graph.values.x_k" text:value="20" />
					</ui:with>

					<ui:with x="10" halign="1">
						<text y="36 db" text="+36" valign="-1" />
						<text y="24 db" text="+24" valign="-1" />
						<text y="12 db" text="+12" valign="-1" />
						<text y="0 db" text="0" valign="1" />
						<text y="-12 db" text="-12" valign="1" />
						<text y="-24 db" text="-24" valign="1" />
						<text y="-36 db" text="-36" valign="1" />
						<text y="1" ox="0" oy="2" text="graph.units.db" valign="-1" />
					</ui:with>
					<ui:with x="10" halign="1" visibility=":zoom le -18 db">
						<text y="18 db" text="+18" valign="-1" />
						<text y="6 db" text="+6" valign="-1" />
						<text y="-6 db" text="-6" valign="1" />
						<text y="-18 db" text="-18" valign="1" />
					</ui:with>
					<ui:with x="10" halign="1" visibility=":zoom le -33 db">
						<text y="9 db" text="+9" valign="-1" />
						<text y="3 db" text="+3" valign="-1" />
						<text y="-3 db" text="-3" valign="1" />
						<text y="-9 db" text="-9" valign="1" />
					</ui:with>
				</graph>
			</group>

			<hbox spacing="4" bg.color="bg_schema" pad.h="6" pad.b="4"
				pad.t="4">
				<button id="ffti" text="labels.fft.fft_in" size="22"
					font.size="10" pad.r="6" expand="false" />
				<ui:if test=":channels igt 1">
					<ui:for id="i" first="1" count=":channels">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<button id="ffti_${i}" text="labels.chan.id" text:id="${i}"
							ui:inject="Button_Cycle" bright="(:ffti igt 0) ? 1 : 0.75"
							size="22" font.size="10" down.color.hue="${hue}"
							down.hover.color.hue="${hue}" text.down.color.hue="${hue}"
							text.down.hover.color.hue="${hue}" border.down.color.hue="${hue}"
							border.down.hover.color.hue="${hue}" pad.r="6" expand="false" />
					</ui:for>
				</ui:if>
				<vsep />
				<button id="ffto" text="labels.fft.fft_out" size="22"
					font.size="10" pad.r="6" pad.l="12" expand="false" />
				<ui:if test=":channels igt 1">
					<ui:for id="i" first="1" count=":channels">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<button id="ffto_${i}" text="labels.chan.id" text:id="${i}"
							ui:inject="Button_Cycle" bright="(:ffto igt 0) ? 1 : 0.75"
							size="22" font.size="10" down.color.hue="${hue}"
							down.hover.color.hue="${hue}" text.down.color.hue="${hue}"
							text.down.hover.color.hue="${hue}" border.down.color.hue="${hue}"
							border.down.hover.color.hue="${hue}" pad.r="6" expand="false" />
					</ui:for>
				</ui:if>
				<vsep />
				<button id="fftg" text="labels.noise_generator.fft_gen"
					size="22" font.size="10" pad.r="6" pad.l="12" expand="false" />
				<ui:for id="i" first="1" count="4">
					<ui:set id="hue" value="${(:i-1)/4.0}" />
					<button id="fftg_${i}" text="labels.chan.id" text:id="${i}"
						ui:inject="Button_Cycle" bright="(:fftg igt 0) ? 1 : 0.75"
						size="22" font.size="10" down.color.hue="${hue}"
						down.hover.color.hue="${hue}" text.down.color.hue="${hue}"
						text.down.hover.color.hue="${hue}" border.down.color.hue="${hue}"
						border.down.hover.color.hue="${hue}" pad.r="6" expand="false" />
				</ui:for>
				<void expand="true" />
			</hbox>
		</vbox>

		<hbox spacing="4" bg.color="bg">
			<!-- Zoom Fader -->
			<vbox vexpand="true" bg.color="bg_schema">
				<label font.name="lsp-icons" font.size="12"
					font.antialias="true" text="icons.main.zoom" color="text_icon" pad.b="4"
					pad.t="4" />
				<fader id="zoom" angle="1" vexpand="true" bg.inherit="true"
					flat="true" />
				<value id="zoom" width="40" />
			</vbox>

			<!-- Signal generators -->
			<group text="labels.noise_generator.signal" ipadding="0"
				fill="true">
				<grid rows="4" cols="${:channels*2-1}" transpose="true">
					<!-- row 1 -->
					<ui:for id="i" first="1" count=":channels">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />

						<label text="labels.chan.id" text:id="${i}" pad.v="4" />
						<cell bg.color="bg" pad.v="2" vreduce="true" vexpand="false">
							<hsep />
						</cell>
						<vbox pad.t="4">
							<label text="labels.noise_generator.mode" />
							<combo id="cm_${i}" pad.h="6"  />
							<ui:if test=":channels ge 2">
								<hbox pad.t="4" pad.h="6">
									<button id="chs_${i}" text="labels.chan.solo"
										ui:inject="Button_Cycle_8" down.color.hue="${hue}"
										down.hover.color.hue="${hue}" text.down.color.hue="${hue}"
										text.down.hover.color.hue="${hue}"
										border.down.color.hue="${hue}"
										border.down.hover.color.hue="${hue}" pad.r="6" hfill="true" />
									<button id="chm_${i}" text="labels.chan.mute"
										ui:inject="Button_Cycle_8" down.color.hue="${hue}"
										down.hover.color.hue="${hue}" text.down.color.hue="${hue}"
										text.down.hover.color.hue="${hue}"
										border.down.color.hue="${hue}"
										border.down.hover.color.hue="${hue}" hfill="true" />

								</hbox>
							</ui:if>
						</vbox>


						<grid rows="12" cols="2" pad.t="4" pad.h="6">
							<knob id="gin_${i}" scolor.hue="${hue}" pad.b="4" />
							<vbox fill="false">
								<label text="labels.chan.in" />
								<value id="gin_${i}" same_line="true" width.min="48" />
							</vbox>
							<ui:for id="j" first="1" count="4">
								<knob id="gg${j}_${i}" scolor.hue="${hue}" pad.b="4" />
								<vbox fill="false">
									<label text="labels.chan.id" text:id="${j}" />
									<value id="gg${j}_${i}" same_line="true" width.min="48" />
								</vbox>
							</ui:for>
							<knob id="gout_${i}" scolor.hue="${hue}" pad.b="4" />
							<vbox fill="false">
								<label text="labels.chan.out" />
								<value id="gout_${i}" same_line="true" width.min="48" />
							</vbox>
						</grid>

						<cell rows="4" bg.color="bg" pad.h="2">
							<vsep />
						</cell>
					</ui:for>
				</grid>
			</group>

			<!-- Signal meters -->
			<vbox vexpand="true" bg.color="bg_schema">
				<label text="labels.chan.in" pad.b="3" pad.t="3" />
				<ledmeter vexpand="true" angle="1">
					<ui:for id="i" first="1" count=":channels">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<ledchannel id="ilm_${i}" min="-72 db" max="+24 db"
							log="true" type="rms_peak" peak.visibility="true"
							value.color="mono_in" value.color.hue="${hue}" />
					</ui:for>
				</ledmeter>
			</vbox>

			<vbox vexpand="true" bg.color="bg_schema">
				<label text="labels.chan.out" pad.b="3" pad.t="3" />
				<ledmeter vexpand="true" angle="1">
					<ui:for id="i" first="1" count=":channels">
						<ui:set id="hue" value="${(:i-1.0)/:channels}" />
						<ledchannel id="olm_${i}" min="-72 db" max="+24 db"
							log="true" type="rms_peak" peak.visibility="true"
							value.color="mono_in" value.color.hue="${hue}" />
					</ui:for>
				</ledmeter>
			</vbox>
		</hbox>
		<!-- signal in out, analysis -->
		<vbox spacing="4">
			<group text="groups.signal" expand="true">
				<grid rows="2" cols="2" hspacing="4">
					<knob id="g_in" pad.r="4" />
					<vbox vfill="false">
						<label text="labels.input" halign="0" />
						<value id="g_in" sline="true" halign="0" />
					</vbox>

					<knob id="g_out" pad.r="4" />
					<vbox vfill="false">
						<label text="labels.output" expand="true" halign="0" />
						<value id="g_out" width.min="50" sline="true" halign="0" />
					</vbox>
				</grid>
			</group>
			<group text="groups.analysis" expand="true">
				<grid rows="2" cols="2" transpose="false" expand="true"
					hspacing="4">
					<knob id="react" size="20" pad.r="4" />
					<vbox vfill="false">
						<label text="labels.metering.reactivity" halign="0" />
						<value id="react" width.min="50" sline="true" halign="0" />
					</vbox>

					<knob id="shift" size="20" pad.r="4" />
					<vbox vfill="false">
						<label text="labels.metering.shift" halign="0" />
						<value id="shift" width.min="50" sline="true" halign="0" />
					</vbox>
				</grid>
			</group>
		</vbox>

		<cell cols="3">
			<group text="labels.noise_generator.generators" ipadding="0"
				fill="true">
				<grid rows="9" cols="25" transpose="true">

					<label text="labels.noise_generator.number_#" />
					<cell cols="25" bg.color="bg" pad.v="2" vreduce="true"
						vexpand="false">
						<hsep />
					</cell>
					<label text="labels.noise_generator.type" />
					<label text="labels.noise_generator.settings" />
					<label text="labels.noise_generator.color" />
					<label text="labels.noise_generator.distribution" pad.h="6" />
					<label text="labels.noise_generator.velvet_type" />
					<cell rows="2">
						<label text="labels.noise_generator.crush" />
					</cell>

					<ui:for id="i" first="1" count="4">
						<ui:set id="ch" value="_${i}" />
						<ui:set id="hue" value="${(:i-1)/4.0}" />

						<cell bg.color="bg" pad.h="2" hreduce="true" hexpand="false">
							<vsep />
						</cell>
						<cell rows="7" bg.color="bg" pad.h="2" hreduce="true"
							hexpand="false">
							<vsep />
						</cell>

						<ui:with expand="true"
							bright="(:nt${ch} igt 0) ? 1 : 0.75"
							bg.bright="(:nt${ch} igt 0) ? 1.0 : :const_bg_darken">
							<cell cols="5">
								<label text="labels.chan.id" text:id="${i}" pad="6" />
							</cell>
							<combo id="nt${ch}" pad.h="6" pad.v="4" />
							<hbox>
								<ui:if test=":channels ge 2">
									<button id="ns${ch}" text="labels.chan.S_olo"
										ui:inject="Button_Cycle" size="22" font.size="10"
										down.color.hue="${hue}" down.hover.color.hue="${hue}"
										text.down.color.hue="${hue}"
										text.down.hover.color.hue="${hue}"
										border.down.color.hue="${hue}"
										border.down.hover.color.hue="${hue}" pad.h="6" expand="false"
										fill="false" />
									<button id="nm${ch}" text="labels.chan.M_ute"
										ui:inject="Button_Cycle" size="22" font.size="10"
										down.color.hue="${hue}" down.hover.color.hue="${hue}"
										text.down.color.hue="${hue}"
										text.down.hover.color.hue="${hue}"
										border.down.color.hue="${hue}"
										border.down.hover.color.hue="${hue}" pad.r="6" expand="false"
										fill="false" />
								</ui:if>
								<button id="ni${ch}"
									text="labels.noise_generator.inaudible"
									ui:inject="Button_Cycle" height="22" font.size="10"
									down.color.hue="${hue}" down.hover.color.hue="${hue}"
									text.down.color.hue="${hue}" text.down.hover.color.hue="${hue}"
									border.down.color.hue="${hue}"
									border.down.hover.color.hue="${hue}" pad.r="6" hfill="true"
									hexpand="true" />
							</hbox>
							<combo id="cs${ch}" pad.h="6" pad.v="4" />
							<combo id="ld${ch}" pad.h="6" pad.v="4"
								bright="(:nt${ch} ieq 2) ? 1 : 0.75"
								bg.bright="(:nt${ch} ieq 2) ? 1.0 : :const_bg_darken" />
							<combo id="vt${ch}" pad.h="6" pad.v="4"
								bright="(:nt${ch} ieq 3) ? 1 : 0.75"
								bg.bright="(:nt${ch} ieq 3) ? 1.0 : :const_bg_darken" />

							<cell bg.color="bg" pad.v="2" vreduce="true" vexpand="false">
								<hsep />
							</cell>

							<button id="vc${ch}" text="labels.noise_generator.crush"
								ui:inject="Button_Cycle" height="22" font.size="10"
								down.color.hue="${hue}" down.hover.color.hue="${hue}"
								text.down.color.hue="${hue}" text.down.hover.color.hue="${hue}"
								border.down.color.hue="${hue}"
								border.down.hover.color.hue="${hue}" pad.h="6" hfill="true"
								hexpand="true" bright="(:nt${ch} ieq 3) ? 1 : 0.75"
								bg.bright="(:nt${ch} ieq 3) ? 1.0 : :const_bg_darken" />

							<cell rows="7" bg.color="bg" pad.h="2" hreduce="true"
								hexpand="false">
								<void />
							</cell>

							<cell rows="7">
								<grid rows="5" cols="3">
									<vbox fill="false" pad.v="4" width.min="72">
										<label text="labels.noise_generator.amp_litude"
											pad.b="4" />
										<knob id="na${ch}"
											scolor="(:nt${ch} igt 0) ? 'cycle' : 'cycle_inactive'"
											scolor.hue="${hue}" size="20" />
										<value id="na${ch}" detailed="false" precision="1" />
									</vbox>
									<void />
									<vbox fill="false" pad.v="4">
										<label text="labels.noise_generator.offs_et" pad.b="4" />
										<knob id="no${ch}"
											scolor="(:nt${ch} igt 0) ? 'cycle' : 'cycle_inactive'"
											scolor.hue="${hue}" size="20" />
										<value id="no${ch}" detailed="false" precision="1" />
									</vbox>

									<cell cols="3" bg.color="bg" pad.v="2" vreduce="true"
										vexpand="false">
										<void />
									</cell>
									<ui:with
										bright="(:cs${ch} igt 4 and :nt${ch} igt 0) ? 1 : 0.75"
										bg.bright="(:cs${ch} igt 4 and :nt${ch} igt 0) ? 1.0 : :const_bg_darken"
										scolor="(:cs${ch} igt 4 and :nt${ch} igt 0) ? 'cycle' : 'cycle_inactive'">
										<vbox fill="false" pad.v="4">
											<label text="labels.noise_generator.CuSToM" pad.b="4" />
											<hbox>
												<knob id="csn${ch}" scolor.hue="${hue}"
													visibility=":cs${ch} ilt 6" />
												<knob id="cso${ch}" scolor.hue="${hue}"
													visibility=":cs${ch} ieq 6" />
												<knob id="csd${ch}" scolor.hue="${hue}"
													visibility=":cs${ch} ieq 7" />
											</hbox>
											<hbox>
												<value id="csn${ch}" same_line="true"
													visibility=":cs${ch} ilt 6" />
												<value id="cso${ch}" same_line="true"
													visibility=":cs${ch} ieq 6" />
												<value id="csd${ch}" same_line="true"
													visibility=":cs${ch} ieq 7" />
											</hbox>
										</vbox>
									</ui:with>

									<cell rows="3" bg.color="bg" pad.h="2" hreduce="true"
										hexpand="false">
										<void />
									</cell>
									<ui:with bright="(:nt${ch} ieq 3) ? 1 : 0.75"
										bg.bright="(:nt${ch} ieq 3) ? 1.0 : :const_bg_darken">
										<vbox fill="false" pad.v="4">
											<label text="labels.noise_generator.window" pad.b="4" />
											<knob id="vw${ch}"
												scolor="(:nt${ch} ieq 3) ? 'cycle' : 'cycle_inactive'"
												scolor.hue="${hue}" size="20" />
											<value id="vw${ch}" detailed="false" precision="4" />
										</vbox>
									</ui:with>

									<cell bg.color="bg" pad.v="2" vreduce="true"
										vexpand="false">
										<void />
									</cell>

									<cell bg.color="bg" pad.v="2" vreduce="true"
										vexpand="false">
										<void />
									</cell>
									<ui:with
										bright="(:vt${ch} ieq 2 and :nt${ch} ieq 3) ? 1 : 0.75"
										bg.bright="(:vt${ch} ieq 2 and :nt${ch} ieq 3) ? 1.0 : :const_bg_darken">
										<vbox fill="false" pad.v="4" pad.h="6">
											<label text="labels.noise_generator.arn_delta"
												pad.b="4" />
											<knob id="vd${ch}"
												scolor="(:vt${ch} ieq 2 and :nt${ch} ieq 3) ? 'cycle' : 'cycle_inactive'"
												scolor.hue="${hue}" size="20" />
											<value id="vd${ch}" detailed="false" precision="4" />
										</vbox>
									</ui:with>

									<ui:with bright="(:nt${ch} ieq 3) ? 1 : 0.75"
										bg.bright="(:nt${ch} ieq 3) ? 1.0 : :const_bg_darken">
										<vbox fill="false" pad.v="4" pad.h="6">
											<label text="labels.noise_generator.crush_prob"
												pad.b="4" />
											<knob id="vp${ch}"
												scolor="(:nt${ch} ieq 3) ? 'cycle' : 'cycle_inactive'"
												scolor.hue="${hue}" size="20" />
											<value id="vp${ch}" detailed="false" precision="1" />
										</vbox>
									</ui:with>

								</grid>
							</cell>

							<cell rows="7" bg.color="bg" pad.h="2" hreduce="true"
								hexpand="false">
								<void width.max="0" />
							</cell>

							<cell rows="7" hexpand="false">
								<ledmeter vexpand="true" angle="1">
									<ledchannel id="nlm_${i}" min="-72 db" max="12 db"
										log="true" type="rms_peak" peak.visibility="true"
										value.color="mono" value.color.hue="${hue}" />
								</ledmeter>
							</cell>
						</ui:with>
					</ui:for>
				</grid>
			</group>
		</cell>
	</grid>
</plugin>
