Skip to content

Commit

Permalink
Option to start with a clear configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed May 5, 2024
1 parent 6043702 commit 12d27a2
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Cavern.Channels;
using Cavern.Filters.Utilities;
using Cavern.Filters;

namespace Cavern.Format.ConfigurationFile {
/// <summary>
/// Cavern Filter Studio's own export format for full grouped filter pipelines.
/// </summary>
public class CavernFilterStudioConfigurationFile : ConfigurationFile {
/// <summary>
/// Cavern Filter Studio's own export format for full grouped filter pipelines.
/// </summary>
public CavernFilterStudioConfigurationFile(int channelCount) : base(ChannelPrototype.GetStandardMatrix(channelCount)) {
for (int i = 0; i < channelCount; i++) { // Output markers
InputChannels[i].root.AddChild(new FilterGraphNode(new OutputChannel(InputChannels[i].name)));
}
}
}
}
10 changes: 10 additions & 0 deletions Cavern.QuickEQ.Format/ConfigurationFile/ConfigurationFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ public abstract class ConfigurationFile {
/// processed on two separate pipelines from the root.</remarks>
public (string name, FilterGraphNode root)[] InputChannels { get; }

/// <summary>
/// Create an empty configuration file with the passed input channels.
/// </summary>
protected ConfigurationFile(ReferenceChannel[] inputs) {
InputChannels = new (string name, FilterGraphNode root)[inputs.Length];
for (int i = 0; i < inputs.Length; i++) {
InputChannels[i] = (inputs[i].GetShortName(), new FilterGraphNode(new InputChannel(inputs[i])));
}
}

/// <summary>
/// Create an empty configuration file with the passed input channel names/labels.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Cavern/Channels/ChannelPrototype.Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ public static readonly ChannelPrototype
/// Semi-standard (Equalizer APO) channel names.
/// </summary>
internal const string frontLeftMark = "L",
frontLeftMarkFull = "FL",
frontRightMark = "R",
frontRightMarkFull = "FR",
frontCenterMark = "C",
frontCenterMarkFull = "FC",
screenLFEMark = "LFE",
subwooferMark = "SUB",
rearLeftMark = "RL",
Expand Down
3 changes: 3 additions & 0 deletions Cavern/Channels/ChannelPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ public partial struct ChannelPrototype : IEquatable<ChannelPrototype> {
public static ChannelPrototype FromStandardName(string name) {
switch (name) {
case frontLeftMark:
case frontLeftMarkFull:
return FrontLeft;
case frontRightMark:
case frontRightMarkFull:
return FrontRight;
case frontCenterMark:
case frontCenterMarkFull:
return FrontCenter;
case screenLFEMark:
case subwooferMark:
Expand Down
3 changes: 3 additions & 0 deletions Cavern/Channels/ReferenceChannelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ public static bool IsHeight(this ReferenceChannel channel) =>
public static ReferenceChannel FromStandardName(string name) {
switch (name) {
case ChannelPrototype.frontLeftMark:
case ChannelPrototype.frontLeftMarkFull:
return ReferenceChannel.FrontLeft;
case ChannelPrototype.frontRightMark:
case ChannelPrototype.frontRightMarkFull:
return ReferenceChannel.FrontRight;
case ChannelPrototype.frontCenterMark:
case ChannelPrototype.frontCenterMarkFull:
return ReferenceChannel.FrontCenter;
case ChannelPrototype.screenLFEMark:
case ChannelPrototype.subwooferMark:
Expand Down
11 changes: 4 additions & 7 deletions CavernSamples/FilterStudio/Graphs/ManipulatableGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ManipulatableGraph : ScrollViewer {
/// <summary>
/// Handle to MSAGL.
/// </summary>
/// <remarks>Setting to null doesn't clear the last displayed graph.</remarks>
public Graph Graph {
get => viewer.Graph;
set {
Expand All @@ -39,12 +40,6 @@ public Graph Graph {
}
}

/// <summary>
/// An inner panel that acts as a window for the graph. The <see cref="ScrollViewer"/> is the curtain,
/// it keeps the graph in the bounds of the control wherever the user moves it.
/// </summary>
readonly DockPanel panel;

/// <summary>
/// Handles displaying and manipulating the graph.
/// </summary>
Expand All @@ -55,7 +50,9 @@ public Graph Graph {
/// </summary>
public ManipulatableGraph() {
VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
panel = new DockPanel();
// An inner panel that acts as a window for the graph. The ScrollViewer is the curtain,
// it keeps the graph in the bounds of the control wherever the user moves it.
DockPanel panel = new();
AddChild(panel);
viewer = new GraphViewer();
viewer.BindToPanel(panel);
Expand Down
2 changes: 1 addition & 1 deletion CavernSamples/FilterStudio/MainWindow.Graph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ partial class MainWindow {
/// <summary>
/// When selecting a node, open it for modification.
/// </summary>
void GraphLeftClick(object element) {
void GraphLeftClick(object _) {
StyledNode node = graph.SelectedNode;
if (node == null || node.Filter == null) {
selectedNode.Text = (string)language["NNode"];
Expand Down
1 change: 1 addition & 0 deletions CavernSamples/FilterStudio/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="{StaticResource MFile}" Style="{StaticResource RootMenuItem}">
<MenuItem Header="{StaticResource OpNew}" Click="NewConfiguration"/>
<MenuItem Header="{StaticResource OpCfg}" Click="LoadConfiguration"/>
</MenuItem>
<MenuItem Header="{StaticResource MFilt}" Style="{StaticResource RootMenuItem}">
Expand Down
8 changes: 8 additions & 0 deletions CavernSamples/FilterStudio/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ protected override void OnClosed(EventArgs e) {
base.OnClosed(e);
}

/// <summary>
/// Create a new empty configuration.
/// </summary>
void NewConfiguration(object _, RoutedEventArgs e) {
rootNodes = new CavernFilterStudioConfigurationFile(8).InputChannels;
ReloadGraph();
}

/// <summary>
/// Open a configuration file of known formats.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="MFile">_Fájl</system:String>
<system:String x:Key="OpNew">_Új konfiguráció</system:String>
<system:String x:Key="OpCfg">_Konfigurációs fájl megnyitása</system:String>

<system:String x:Key="MFilt">_Szűrő hozzáadása</system:String>
<system:String x:Key="FShif">_Párhuzamos hozzáadás (Shift nyomva tartásával azonos)</system:String>
<system:String x:Key="FLabe">_Címke</system:String>
<system:String x:Key="FGain">_Erősítés</system:String>
<system:String x:Key="FDela">_Késleltetés</system:String>
<system:String x:Key="FBiqu">E_gyszerű parametrikus szűrő</system:String>
<system:String x:Key="FBiqu">E_gyszerű parametrikus szűrő...</system:String>

<system:String x:Key="MGrap">_Gráf</system:String>
<system:String x:Key="OpRec">Középre _mozgatás</system:String>
Expand Down
3 changes: 2 additions & 1 deletion CavernSamples/FilterStudio/Resources/MainWindowStrings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="MFile">_File</system:String>
<system:String x:Key="OpNew">_New configuration</system:String>
<system:String x:Key="OpCfg">_Open configuration file</system:String>

<system:String x:Key="MFilt">_Add filter</system:String>
<system:String x:Key="FShif">_Add in parallel (same as holding Shift)</system:String>
<system:String x:Key="FLabe">_Label</system:String>
<system:String x:Key="FGain">_Gain</system:String>
<system:String x:Key="FDela">_Delay</system:String>
<system:String x:Key="FBiqu">_Basic parametric filter</system:String>
<system:String x:Key="FBiqu">_Basic parametric filter...</system:String>

<system:String x:Key="MGrap">_Graph</system:String>
<system:String x:Key="OpRec">_Recenter</system:String>
Expand Down

0 comments on commit 12d27a2

Please sign in to comment.