-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In-CavernPipe layout change and 4.1.3 support
- Loading branch information
Showing
26 changed files
with
421 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Windows; | ||
|
||
using Cavern.Channels; | ||
|
||
namespace Cavern.WPF.Consts { | ||
/// <summary> | ||
/// Extension functions for calculating translated text. | ||
/// </summary> | ||
public static class LanguageExtensions { | ||
/// <summary> | ||
/// Display how a set of spatial <paramref name="channels"/> shall be wired for regular audio interfaces. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void DisplayWiring(this ReferenceChannel[] channels) => channels.DisplayWiring(null); | ||
|
||
/// <summary> | ||
/// Display how a set of spatial <paramref name="channels"/> shall be wired for regular audio interfaces when some channels are | ||
/// <paramref name="matrixed"/> into 8 channels to be extracted when the speaker is wired to two positive terminals. These matrixed channels | ||
/// are not part of the base <paramref name="channels"/>. | ||
/// </summary> | ||
public static void DisplayWiring(this ReferenceChannel[] channels, | ||
(ReferenceChannel source, ReferenceChannel posPhase, ReferenceChannel negPhase)[] matrixed) { | ||
ResourceDictionary language = Language.GetChannelSelectorStrings(); | ||
ChannelPrototype[] prototypes = ChannelPrototype.Get(channels); | ||
if (channels.Length > 8) { | ||
MessageBox.Show(string.Format((string)language["Over8"], string.Join(string.Empty, prototypes.Select(x => "\n- " + x.Name)), | ||
(string)language["WrGui"])); | ||
return; | ||
} | ||
|
||
StringBuilder output = new StringBuilder(); | ||
ReferenceChannel[] standard = ChannelPrototype.GetStandardMatrix(prototypes.Length); | ||
for (int i = 0; i < prototypes.Length; i++) { | ||
output.AppendLine(string.Format((string)language["ChCon"], channels[i].Translate(), standard[i].Translate())); | ||
} | ||
if (matrixed != null) { | ||
for (int i = 0; i < matrixed.Length; i++) { | ||
output.AppendLine(string.Format((string)language["ChCMx"], | ||
matrixed[i].source.Translate(), matrixed[i].posPhase.Translate(), matrixed[i].negPhase.Translate())); | ||
} | ||
} | ||
MessageBox.Show(output.ToString(), (string)language["WrGui"]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.IO; | ||
|
||
namespace Cavern.Internals { | ||
/// <summary> | ||
/// Functions to modify Cavern's global configuration. See <see cref="IKnowWhatIAmDoing"/> for warnings. | ||
/// </summary> | ||
public static class CavernConfiguration { | ||
/// <summary> | ||
/// These are very wild waters and you should really evaluate if you need these functions or not. | ||
/// You are given the power to modify the user's global settings which are reflected in all Cavern | ||
/// products and applications/games built on Cavern. If the user is not properly prompted that for | ||
/// example, the speakers are getting reordered in all applications, they can blame Cavern for bugs | ||
/// it doesn't have. Your page names, prompts, and UIs should completely convey that the user is | ||
/// editing the GLOBAL settings. You should really make it sure they WANT to do EXACTLY what is | ||
/// being called from here. To be safe and always support the Cavern ecosystem properly, just ask | ||
/// the user to use the Cavern Driver. If they never used Cavern Driver, Cavern falls back to 5.1, | ||
/// which is the only safe option to mix to any channel layout with limited system knowledge. | ||
/// If you're extra sure you won't break the user's setup, set this to true to use the class. | ||
/// </summary> | ||
public static bool IKnowWhatIAmDoing { get; set; } | ||
|
||
/// <summary> | ||
/// Get the path of the folder that contains Cavern's configuration files. | ||
/// </summary> | ||
public static string GetPath() { | ||
if (!IKnowWhatIAmDoing) { | ||
throw new DevHasNoIdeaException(); | ||
} | ||
|
||
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cavern"); | ||
if (!Directory.Exists(path)) { | ||
Directory.CreateDirectory(path); | ||
} | ||
return path; | ||
} | ||
|
||
/// <summary> | ||
/// Overwrite the global environment (including channel layout) used by all applications built on Cavern. | ||
/// </summary> | ||
public static void SaveCurrentLayoutAsDefault() => SaveCurrentLayoutAs("Save"); | ||
|
||
/// <summary> | ||
/// Save an environment (including channel layout) preset option that can be recalled in the Cavern Driver. | ||
/// </summary> | ||
public static void SaveCurrentLayoutAsPreset(string presetName) => SaveCurrentLayoutAs(presetPrefix + presetName); | ||
|
||
/// <summary> | ||
/// Delete a preset that was saved with <see cref="SaveCurrentLayoutAsPreset(string)"/>. | ||
/// </summary> | ||
public static void DeletePreset(string presetName) => File.Delete(Path.Combine(GetPath(), $"{presetPrefix}{presetName}.dat")); | ||
|
||
/// <summary> | ||
/// Save an environment (including channel layout) preset option that can be recalled in the Cavern Driver. | ||
/// </summary> | ||
static void SaveCurrentLayoutAs(string presetName) { | ||
Channel[] channels = Listener.Channels; | ||
string[] save = new string[channels.Length * 3 + 7]; | ||
save[0] = channels.Length.ToString(); | ||
int savePos = 1; | ||
for (int i = 0; i < channels.Length; i++) { | ||
save[savePos] = channels[i].X.ToString(CultureInfo.InvariantCulture); | ||
save[savePos + 1] = channels[i].Y.ToString(CultureInfo.InvariantCulture); | ||
save[savePos + 2] = channels[i].LFE.ToString(); | ||
savePos += 3; | ||
} | ||
save[savePos] = ((int)Listener.EnvironmentType).ToString(); | ||
save[savePos + 1] = Listener.EnvironmentSize.X.ToString(CultureInfo.InvariantCulture); | ||
save[savePos + 2] = Listener.EnvironmentSize.Y.ToString(CultureInfo.InvariantCulture); | ||
save[savePos + 3] = Listener.EnvironmentSize.Z.ToString(CultureInfo.InvariantCulture); | ||
save[savePos + 4] = Listener.HeadphoneVirtualizer.ToString(); | ||
save[savePos + 5] = string.Empty; // Was: environment compensation | ||
File.WriteAllLines(Path.Combine(GetPath(), presetName + ".dat"), save); | ||
} | ||
|
||
/// <summary> | ||
/// The name of all environment preset files in Cavern's configuration folder start with this. | ||
/// </summary> | ||
const string presetPrefix = "CavernPreset_"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace Cavern.Internals { | ||
/// <summary> | ||
/// Tells if the developer used something without properly understanding what it does. | ||
/// </summary> | ||
public class DevHasNoIdeaException : Exception { | ||
const string message = "The developer is very irresponsible."; | ||
|
||
/// <summary> | ||
/// Tells if the developer used something without properly understanding what it does. | ||
/// </summary> | ||
public DevHasNoIdeaException() : base(message) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.