diff --git a/SteelSeriesAPI.Sample/Program.cs b/SteelSeriesAPI.Sample/Program.cs index 3390ffe..326e9f5 100644 --- a/SteelSeriesAPI.Sample/Program.cs +++ b/SteelSeriesAPI.Sample/Program.cs @@ -18,14 +18,14 @@ static void Main(string[] args) // If I want to detect changes made on GG, I can use the listener (require admin rights) sonarManager.StartListener(); // Then I register the events I want (I've put them all to demonstrate) - sonarManager.EventManager.OnSonarModeChange += OnModeChangeHandler; // When the mode is change - sonarManager.EventManager.OnSonarVolumeChange += OnVolumeChangeHandler; // When the volume of a Sonar Channel or Mix is changed - sonarManager.EventManager.OnSonarMuteChange += OnMuteChangeHandler; // When a Sonar Channel or Mix is muted or unmuted - sonarManager.EventManager.OnSonarConfigChange += OnConfigChangeHandler; // When a new config is set to a Sonar Channel - sonarManager.EventManager.OnSonarChatMixChange += OnChatMixChangeHandler; // When the ChatMix value is changed - sonarManager.EventManager.OnSonarRedirectionDeviceChange += OnRedirectionDeviceChangeHandler; // When the Redirection Channel of a Sonar Channel is changed - sonarManager.EventManager.OnSonarRedirectionStateChange += OnRedirectionStateChangeHandler; // When the Redirection of a Sonar Mix is muted or unmuted - sonarManager.EventManager.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; // When the Audience Monitoring is muted or unmuted + sonarManager.Event.OnSonarModeChange += OnModeChangeHandler; // When the mode is change + sonarManager.Event.OnSonarVolumeChange += OnVolumeChangeHandler; // When the volume of a Sonar Channel or Mix is changed + sonarManager.Event.OnSonarMuteChange += OnMuteChangeHandler; // When a Sonar Channel or Mix is muted or unmuted + sonarManager.Event.OnSonarConfigChange += OnConfigChangeHandler; // When a new config is set to a Sonar Channel + sonarManager.Event.OnSonarChatMixChange += OnChatMixChangeHandler; // When the ChatMix value is changed + sonarManager.Event.OnSonarRedirectionDeviceChange += OnRedirectionDeviceChangeHandler; // When the Redirection Channel of a Sonar Channel is changed + sonarManager.Event.OnSonarRedirectionStateChange += OnRedirectionStateChangeHandler; // When the Redirection of a Sonar Mix is muted or unmuted + sonarManager.Event.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; // When the Audience Monitoring is muted or unmuted // Get current sonar mode Mode mode = sonarManager.GetMode(); @@ -33,27 +33,28 @@ static void Main(string[] args) sonarManager.SetMode(Mode.STREAMER); // Get current volume of a Sonar Channel - double vol = sonarManager.GetVolume(Channel.MEDIA); + double vol = sonarManager.VolumeSettings.GetVolume(Channel.MEDIA); // Get current volume of a Sonar Mix - double vol2 = sonarManager.GetVolume(Channel.CHAT, Mix.STREAM); + double vol2 = sonarManager.VolumeSettings.GetVolume(Channel.CHAT, Mix.STREAM); // Set the volume of a Sonar Channel - sonarManager.SetVolume(0.75, Channel.GAME); + sonarManager.VolumeSettings.SetVolume(0.75, Channel.GAME); // Set the volume of a Sonar Mix - sonarManager.SetVolume(0.1, Channel.MEDIA, Mix.MONITORING); + sonarManager.VolumeSettings.SetVolume(0.1, Channel.MEDIA, Mix.MONITORING); // Get the current mute state of a Sonar Channel - bool state = sonarManager.GetMute(Channel.CHAT); - bool state2 = sonarManager.GetMute(Channel.MASTER, Mix.MONITORING); + bool state = sonarManager.VolumeSettings.GetMute(Channel.CHAT); + bool state2 = sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.MONITORING); // Set the current mute state of a Sonar Channel - sonarManager.SetMute(true, Channel.CHAT); // Mute chat + sonarManager.VolumeSettings.SetMute(true, Channel.CHAT); // Mute chat // Get audio configs - List allConfigs = sonarManager.GetAllAudioConfigurations().ToList(); // Return all configs (A SonarAudioConfiguration contains an Id, a Name and an AssociatedChannel) - List mediaConfigs = sonarManager.GetAudioConfigurations(Channel.MEDIA).ToList(); // Return all configs of a Sonar Channel - SonarAudioConfiguration currentConfig = sonarManager.GetSelectedAudioConfiguration(Channel.MEDIA); // Return the currently used config of a Sonar Channel + List allConfigs = sonarManager.Configurations.GetAllAudioConfigurations().ToList(); // Return all configs (A SonarAudioConfiguration contains an Id, a Name and an AssociatedChannel) + List mediaConfigs = sonarManager.Configurations.GetAudioConfigurations(Channel.MEDIA).ToList(); // Return all configs of a Sonar Channel + SonarAudioConfiguration currentConfig = sonarManager.Configurations.GetSelectedAudioConfiguration(Channel.MEDIA); // Return the currently used config of a Sonar Channel // Set the config of a Sonar Channel - sonarManager.SetConfig(Channel.MEDIA, "Podcast"); // Using its name - sonarManager.SetConfig(currentConfig.Id); // Using its id (no need to precise which Sonar Channel, one id goes to one Sonar Channel) + sonarManager.Configurations.SetConfigByName(Channel.MEDIA, "Podcast"); // Using its name + sonarManager.Configurations.SetConfig(currentConfig.Id); // Using its id (no need to precise which Sonar Channel, one id goes to one Sonar Channel) + sonarManager.Configurations.SetConfig(currentConfig); // Or you can just directly give the config // Get ChatMix info double chatMixBalance = sonarManager.GetChatMixBalance(); // The ChatMix value between -1 and 1 @@ -62,16 +63,16 @@ static void Main(string[] args) sonarManager.SetChatMixBalance(0.5); // 0.5 is halfway to Chat // Get playback devices (Windows devices) - List inputDevices = sonarManager.GetPlaybackDevices(DataFlow.INPUT).ToList(); // Input devices (Mics...) - sonarManager.GetPlaybackDevices(DataFlow.OUTPUT); // Output devices (headset, speakers...) - sonarManager.GetPlaybackDeviceFromId("{0.0.0.00000000}.{192b4f5b-9cc1-4eb2-b752-c5e15b99d548}"); // Get a redirection channel from its id - PlaybackDevice gameRDevice = sonarManager.GetClassicPlaybackDevice(Channel.GAME); // Give currently used Redirection Channel for classic mode - sonarManager.GetStreamPlaybackDevice(Mix.MONITORING); // Give currently used Redirection Channel for Streamer mode - sonarManager.GetStreamPlaybackDevice(Channel.MIC); // Give currently used Redirection Channel for Mic in streamer mode + List inputDevices = sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.INPUT).ToList(); // Input devices (Mics...) + sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.OUTPUT); // Output devices (headset, speakers...) + sonarManager.PlaybackDevices.GetPlaybackDevice("{0.0.0.00000000}.{192b4f5b-9cc1-4eb2-b752-c5e15b99d548}"); // Get a redirection channel from its id + PlaybackDevice gameRDevice = sonarManager.PlaybackDevices.GetClassicPlaybackDevice(Channel.GAME); // Give currently used Redirection Channel for classic mode + sonarManager.PlaybackDevices.GetStreamerPlaybackDevice(Mix.MONITORING); // Give currently used Redirection Channel for Streamer mode + sonarManager.PlaybackDevices.GetStreamerPlaybackDevice(Channel.MIC); // Give currently used Redirection Channel for Mic in streamer mode // Change playback devices using their id - sonarManager.SetClassicPlaybackDevice(gameRDevice.Id, Channel.GAME); - sonarManager.SetStreamPlaybackDevice(gameRDevice.Id, Mix.MONITORING); - sonarManager.SetStreamPlaybackDevice(inputDevices[0].Id, Channel.MIC); + sonarManager.PlaybackDevices.SetClassicPlaybackDevice(gameRDevice.Id, Channel.GAME); + sonarManager.PlaybackDevices.SetStreamerPlaybackDevice(gameRDevice.Id, Mix.MONITORING); + sonarManager.PlaybackDevices.SetStreamerPlaybackDevice(inputDevices[0].Id, Channel.MIC); // Get the redirections states sonarManager.GetRedirectionState(Channel.MEDIA, Mix.MONITORING); diff --git a/SteelSeriesAPI.Tests/Program.cs b/SteelSeriesAPI.Tests/Program.cs index f91bab5..608deb2 100644 --- a/SteelSeriesAPI.Tests/Program.cs +++ b/SteelSeriesAPI.Tests/Program.cs @@ -18,14 +18,14 @@ static void Main(string[] args) // Thread.Sleep(1000); // sonarManager.StopListener(); - sonarManager.EventManager.OnSonarModeChange += OnModeChangeHandler; - sonarManager.EventManager.OnSonarVolumeChange += OnVolumeChangeHandler; - sonarManager.EventManager.OnSonarMuteChange += OnMuteChangeHandler; - sonarManager.EventManager.OnSonarConfigChange += OnConfigChangeHandler; - sonarManager.EventManager.OnSonarChatMixChange += OnChatMixChangeHandler; - sonarManager.EventManager.OnSonarRedirectionDeviceChange += OnRedirectionDeviceChangeHandler; - sonarManager.EventManager.OnSonarRedirectionStateChange += OnRedirectionStateChangeHandler; - sonarManager.EventManager.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; + sonarManager.Event.OnSonarModeChange += OnModeChangeHandler; + sonarManager.Event.OnSonarVolumeChange += OnVolumeChangeHandler; + sonarManager.Event.OnSonarMuteChange += OnMuteChangeHandler; + sonarManager.Event.OnSonarConfigChange += OnConfigChangeHandler; + sonarManager.Event.OnSonarChatMixChange += OnChatMixChangeHandler; + sonarManager.Event.OnSonarRedirectionDeviceChange += OnRedirectionDeviceChangeHandler; + sonarManager.Event.OnSonarRedirectionStateChange += OnRedirectionStateChangeHandler; + sonarManager.Event.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; // new Program().GetTest(sonarManager); // new Program().SetTest(sonarManager); @@ -38,28 +38,28 @@ void TestMaster(SonarBridge sonarManager) // Classic sonarManager.SetMode(Mode.CLASSIC); Console.WriteLine("------ Classic Master Test ------"); - Console.WriteLine(sonarManager.GetVolume(Channel.MASTER)); - Console.WriteLine(sonarManager.GetMute(Channel.MASTER)); - sonarManager.SetVolume(0.25f, Channel.MASTER); - sonarManager.SetVolume(1, Channel.MASTER); - sonarManager.SetMute(true, Channel.MASTER); - sonarManager.SetMute(false, Channel.MASTER); + Console.WriteLine(sonarManager.VolumeSettings.GetVolume(Channel.MASTER)); + Console.WriteLine(sonarManager.VolumeSettings.GetMute(Channel.MASTER)); + sonarManager.VolumeSettings.SetVolume(0.25f, Channel.MASTER); + sonarManager.VolumeSettings.SetVolume(1, Channel.MASTER); + sonarManager.VolumeSettings.SetMute(true, Channel.MASTER); + sonarManager.VolumeSettings.SetMute(false, Channel.MASTER); // Streamer sonarManager.SetMode(Mode.STREAMER); Console.WriteLine("------ Streamer Master Test ------"); - Console.WriteLine(sonarManager.GetVolume(Channel.MASTER, Mix.MONITORING)); - Console.WriteLine(sonarManager.GetVolume(Channel.MASTER, Mix.STREAM)); - Console.WriteLine(sonarManager.GetMute(Channel.MASTER, Mix.MONITORING)); - Console.WriteLine(sonarManager.GetMute(Channel.MASTER, Mix.STREAM)); - sonarManager.SetVolume(0.25f, Channel.MASTER, Mix.MONITORING); - sonarManager.SetVolume(0.25f, Channel.MASTER, Mix.STREAM); - sonarManager.SetVolume(1, Channel.MASTER, Mix.MONITORING); - sonarManager.SetVolume(1, Channel.MASTER, Mix.STREAM); - sonarManager.SetMute(true, Channel.MASTER, Mix.MONITORING); - sonarManager.SetMute(true, Channel.MASTER, Mix.STREAM); - sonarManager.SetMute(false, Channel.MASTER, Mix.MONITORING); - sonarManager.SetMute(false, Channel.MASTER, Mix.STREAM); + Console.WriteLine(sonarManager.VolumeSettings.GetVolume(Channel.MASTER, Mix.MONITORING)); + Console.WriteLine(sonarManager.VolumeSettings.GetVolume(Channel.MASTER, Mix.STREAM)); + Console.WriteLine(sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.MONITORING)); + Console.WriteLine(sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.STREAM)); + sonarManager.VolumeSettings.SetVolume(0.25f, Channel.MASTER, Mix.MONITORING); + sonarManager.VolumeSettings.SetVolume(0.25f, Channel.MASTER, Mix.STREAM); + sonarManager.VolumeSettings.SetVolume(1, Channel.MASTER, Mix.MONITORING); + sonarManager.VolumeSettings.SetVolume(1, Channel.MASTER, Mix.STREAM); + sonarManager.VolumeSettings.SetMute(true, Channel.MASTER, Mix.MONITORING); + sonarManager.VolumeSettings.SetMute(true, Channel.MASTER, Mix.STREAM); + sonarManager.VolumeSettings.SetMute(false, Channel.MASTER, Mix.MONITORING); + sonarManager.VolumeSettings.SetMute(false, Channel.MASTER, Mix.STREAM); sonarManager.SetMode(Mode.CLASSIC); } @@ -68,105 +68,105 @@ void GetTest(SonarBridge sonarManager) { Console.WriteLine(sonarManager.GetMode()); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MASTER) + " " + sonarManager.GetMute(Channel.MASTER)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.GAME) + " " + sonarManager.GetMute(Channel.GAME)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.CHAT) + " " + sonarManager.GetMute(Channel.CHAT)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MEDIA) + " " + sonarManager.GetMute(Channel.MEDIA)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.AUX) + " " + sonarManager.GetMute(Channel.AUX)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MIC) + " " + sonarManager.GetMute(Channel.MIC)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MASTER) + " " + sonarManager.VolumeSettings.GetMute(Channel.MASTER)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.GAME) + " " + sonarManager.VolumeSettings.GetMute(Channel.GAME)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.CHAT) + " " + sonarManager.VolumeSettings.GetMute(Channel.CHAT)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MEDIA) + " " + sonarManager.VolumeSettings.GetMute(Channel.MEDIA)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.AUX) + " " + sonarManager.VolumeSettings.GetMute(Channel.AUX)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MIC) + " " + sonarManager.VolumeSettings.GetMute(Channel.MIC)); Console.WriteLine("-----------------Streamer-Monitoring-------------"); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MASTER, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.MASTER, Mix.MONITORING)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.GAME, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.GAME, Mix.MONITORING)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.CHAT, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.CHAT, Mix.MONITORING)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MEDIA, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.MEDIA, Mix.MONITORING)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.AUX, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.AUX, Mix.MONITORING)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MIC, Mix.MONITORING) + " " + sonarManager.GetMute(Channel.MIC, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MASTER, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.GAME, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.GAME, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.CHAT, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.CHAT, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MEDIA, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.MEDIA, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.AUX, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.AUX, Mix.MONITORING)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MIC, Mix.MONITORING) + " " + sonarManager.VolumeSettings.GetMute(Channel.MIC, Mix.MONITORING)); Console.WriteLine("-----------------Streamer-Stream-------------"); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MASTER, Mix.STREAM) + " " + sonarManager.GetMute(Channel.MASTER, Mix.STREAM)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.GAME, Mix.STREAM) + " " + sonarManager.GetMute(Channel.GAME, Mix.STREAM)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.CHAT, Mix.STREAM) + " " + sonarManager.GetMute(Channel.CHAT, Mix.STREAM)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MEDIA, Mix.STREAM) + " " + sonarManager.GetMute(Channel.MEDIA, Mix.STREAM)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.AUX, Mix.STREAM) + " " + sonarManager.GetMute(Channel.AUX, Mix.STREAM)); - Console.WriteLine("" + sonarManager.GetVolume(Channel.MIC, Mix.STREAM) + " " + sonarManager.GetMute(Channel.MIC, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MASTER, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.GAME, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.GAME, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.CHAT, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.CHAT, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MEDIA, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.MEDIA, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.AUX, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.AUX, Mix.STREAM)); + Console.WriteLine("" + sonarManager.VolumeSettings.GetVolume(Channel.MIC, Mix.STREAM) + " " + sonarManager.VolumeSettings.GetMute(Channel.MIC, Mix.STREAM)); Console.WriteLine("----AudioConfigs----------"); - foreach (var config in sonarManager.GetAllAudioConfigurations()) + foreach (var config in sonarManager.Configurations.GetAllAudioConfigurations()) { Console.WriteLine(config.Id + ", " + config.Name + ", " + config.AssociatedChannel); } Console.WriteLine("----Media-Configs----------"); - foreach (var config in sonarManager.GetAudioConfigurations(Channel.MEDIA)) + foreach (var config in sonarManager.Configurations.GetAudioConfigurations(Channel.MEDIA)) { Console.WriteLine(config.Id + ", " + config.Name); } Console.WriteLine("----Mic-Configs----------"); - foreach (var config in sonarManager.GetAudioConfigurations(Channel.MIC)) + foreach (var config in sonarManager.Configurations.GetAudioConfigurations(Channel.MIC)) { Console.WriteLine(config.Id + ", " + config.Name); } Console.WriteLine("----Current Media Config----------"); - Console.WriteLine(sonarManager.GetSelectedAudioConfiguration(Channel.MEDIA).Name); + Console.WriteLine(sonarManager.Configurations.GetSelectedAudioConfiguration(Channel.MEDIA).Name); Console.WriteLine("----Channel from config ID----------"); - Console.WriteLine(sonarManager.GetAudioConfiguration("29ae2c02-792b-4487-863c-dc3e11a7a469").AssociatedChannel); + Console.WriteLine(sonarManager.Configurations.GetAudioConfiguration("29ae2c02-792b-4487-863c-dc3e11a7a469").AssociatedChannel); Console.WriteLine("--------ChatMix---------"); Console.WriteLine(sonarManager.GetChatMixBalance()); Console.WriteLine(sonarManager.GetChatMixState()); Console.WriteLine("-----Redirection Devices-----------"); Console.WriteLine("---Output---"); - foreach (var rDevice in sonarManager.GetPlaybackDevices(DataFlow.OUTPUT)) + foreach (var rDevice in sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.OUTPUT)) { Console.WriteLine(rDevice.Id + ", " + rDevice.Name); - foreach (var device in rDevice.AssociatedClassicDevices) + foreach (var device in rDevice.AssociatedClassicChannels) { Console.WriteLine("...." + device); } - foreach (var channel in rDevice.AssociatedStreamDevices) + foreach (var channel in rDevice.AssociatedStreamChannels) { Console.WriteLine("...." + channel); } } Console.WriteLine("---Input---"); - foreach (var rDevice in sonarManager.GetPlaybackDevices(DataFlow.INPUT)) + foreach (var rDevice in sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.INPUT)) { Console.WriteLine(rDevice.Id + ", " + rDevice.Name); - foreach (var device in rDevice.AssociatedClassicDevices) + foreach (var device in rDevice.AssociatedClassicChannels) { Console.WriteLine("...." + device); } - foreach (var channel in rDevice.AssociatedStreamDevices) + foreach (var channel in rDevice.AssociatedStreamChannels) { Console.WriteLine("...." + channel); } } - Console.WriteLine("-----Classic Redirection Devices------------"); - PlaybackDevice reDevice = sonarManager.GetClassicPlaybackDevice(Channel.GAME); + Console.WriteLine("-----Classic Playback Devices------------"); + PlaybackDevice reDevice = sonarManager.PlaybackDevices.GetClassicPlaybackDevice(Channel.GAME); Console.WriteLine(reDevice.Id + ", " + reDevice.Name); - foreach (var device in reDevice.AssociatedClassicDevices) + foreach (var device in reDevice.AssociatedClassicChannels) { Console.WriteLine("...." + device); } - foreach (var channel in reDevice.AssociatedStreamDevices) + foreach (var channel in reDevice.AssociatedStreamChannels) { Console.WriteLine("...." + channel); } - Console.WriteLine("-----Stream Redirection Devices------------"); - PlaybackDevice reDeviceS = sonarManager.GetStreamPlaybackDevice(Channel.MIC); // sonarManager.GetStreamPlaybackDevice(Mix.MONITORING); + Console.WriteLine("-----Stream Playback Devices------------"); + PlaybackDevice reDeviceS = sonarManager.PlaybackDevices.GetStreamerPlaybackDevice(Channel.MIC); // sonarManager.GetStreamPlaybackDevice(Mix.MONITORING); Console.WriteLine(reDeviceS.Id + ", " + reDeviceS.Name); - foreach (var device in reDeviceS.AssociatedClassicDevices) + foreach (var device in reDeviceS.AssociatedClassicChannels) { Console.WriteLine("...." + device); } - foreach (var channel in reDeviceS.AssociatedStreamDevices) + foreach (var channel in reDeviceS.AssociatedStreamChannels) { Console.WriteLine("...." + channel); } @@ -174,12 +174,12 @@ void GetTest(SonarBridge sonarManager) Console.WriteLine("-----Redirection Channel From Id"); // PlaybackDevice someDevice = sonarManager.GetPlaybackDeviceFromId("{0.0.0.00000000}.{453f6e2f-375e-4b36-97b2-2aa55691ab3c}"); // Console.WriteLine(someDevice.Id + ", " + someDevice.Name + ", " + someDevice.DataFlow); - // foreach (var associatedClassicDevice in someDevice.AssociatedClassicDevices) + // foreach (var associatedClassicDevice in someDevice.AssociatedClassicChannels) // { // Console.WriteLine("...." + associatedClassicDevice); // } // - // foreach (var associatedStreamDevice in someDevice.AssociatedStreamDevices) + // foreach (var associatedStreamDevice in someDevice.AssociatedStreamChannels) // { // Console.WriteLine("...." + associatedStreamDevice); // } @@ -217,17 +217,17 @@ void GetTest(SonarBridge sonarManager) void SetTest(SonarBridge sonarManager){ sonarManager.SetMode(Mode.CLASSIC); - sonarManager.SetVolume(0.4, Channel.MEDIA); - sonarManager.SetMute(false, Channel.MEDIA); - string configId = sonarManager.GetAudioConfigurations(Channel.MEDIA).FirstOrDefault(config => config.Name == "Default")?.Id; - sonarManager.SetConfig(configId); - sonarManager.SetConfig(Channel.MEDIA, "Default"); + sonarManager.VolumeSettings.SetVolume(0.4, Channel.MEDIA); + sonarManager.VolumeSettings.SetMute(false, Channel.MEDIA); + string configId = sonarManager.Configurations.GetAudioConfigurations(Channel.MEDIA).FirstOrDefault(config => config.Name == "Default")?.Id; + sonarManager.Configurations.SetConfig(configId); + sonarManager.Configurations.SetConfigByName(Channel.MEDIA, "Default"); sonarManager.SetChatMixBalance(0.5); - var redirectionDevices = sonarManager.GetPlaybackDevices(DataFlow.INPUT); + var redirectionDevices = sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.INPUT); redirectionDevices.GetEnumerator().MoveNext(); - sonarManager.SetClassicPlaybackDevice(redirectionDevices.GetEnumerator().Current.Id, Channel.MIC); - sonarManager.SetStreamPlaybackDevice(redirectionDevices.GetEnumerator().Current.Id, Channel.MIC); + sonarManager.PlaybackDevices.SetClassicPlaybackDevice(redirectionDevices.GetEnumerator().Current.Id, Channel.MIC); + sonarManager.PlaybackDevices.SetStreamerPlaybackDevice(redirectionDevices.GetEnumerator().Current.Id, Channel.MIC); sonarManager.SetRedirectionState(true, Channel.MEDIA, Mix.STREAM); sonarManager.SetAudienceMonitoringState(false); diff --git a/SteelSeriesAPI/Sonar/Http/SonarHttpCommand.cs b/SteelSeriesAPI/Sonar/Http/SonarHttpCommand.cs index 9b76680..d51b368 100644 --- a/SteelSeriesAPI/Sonar/Http/SonarHttpCommand.cs +++ b/SteelSeriesAPI/Sonar/Http/SonarHttpCommand.cs @@ -20,48 +20,6 @@ public void SetMode(Mode mode) Thread.Sleep(100); // Prevent bugs/freezes/crashes } - public void SetVolume(double vol, Channel channel) - { - string _vol = vol.ToString("0.00", CultureInfo.InvariantCulture); - new HttpPut("volumeSettings/classic/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/Volume/" + _vol); - } - - public void SetVolume(double vol, Channel channel, Mix mix) - { - string _vol = vol.ToString("0.00", CultureInfo.InvariantCulture); - new HttpPut("volumeSettings/streamer/" + mix.ToDictKey() + "/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/volume/" + _vol); - } - - public void SetMute(bool mute, Channel channel) - { - new HttpPut("volumeSettings/classic/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/Mute/" + mute); - } - - public void SetMute(bool mute, Channel channel, Mix mix) - { - new HttpPut("volumeSettings/streamer/" + mix.ToDictKey() + "/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/isMuted/" + mute); - } - - public void SetConfig(string configId) - { - if (string.IsNullOrEmpty(configId)) throw new Exception("Couldn't retrieve config id"); - - new HttpPut("configs/" + configId + "/select"); - } - - public void SetConfig(Channel channel, string name) - { - var configs = _sonarBridge.GetAudioConfigurations(channel).ToList(); - foreach (var config in configs) - { - if (config.Name == name) - { - SetConfig(config.Id); - break; - } - } - } - public void SetChatMixBalance(double balance) { if (!_sonarBridge.GetChatMixState()) @@ -77,26 +35,6 @@ public void SetChatMixBalance(double balance) new HttpPut("chatMix?balance=" + balance.ToString("0.00", CultureInfo.InvariantCulture)); } - public void SetClassicPlaybackDevice(string deviceId, Channel channel) - { - new HttpPut("classicRedirections/" + channel.ToDictKey(ChannelMapChoice.ChannelDict) +"/deviceId/" + deviceId); - } - - public void SetStreamPlaybackDevice(string deviceId, Mix mix) - { - new HttpPut("streamRedirections/" + mix.ToDictKey() +"/deviceId/" + deviceId); - } - - public void SetStreamPlaybackDevice(string deviceId, Channel channel) - { - if (channel != Channel.MIC) - { - throw new Exception("Can only change stream redirection channel for Mic"); - } - - new HttpPut("streamRedirections/" + channel.ToDictKey(ChannelMapChoice.ChannelDict) +"/deviceId/" + deviceId); - } - public void SetRedirectionState(bool newState, Channel channel, Mix mix) { new HttpPut("streamRedirections/" + mix.ToDictKey() + "/redirections/" + channel.ToDictKey() + diff --git a/SteelSeriesAPI/Sonar/Http/SonarHttpProvider.cs b/SteelSeriesAPI/Sonar/Http/SonarHttpProvider.cs index effd04d..2314f55 100644 --- a/SteelSeriesAPI/Sonar/Http/SonarHttpProvider.cs +++ b/SteelSeriesAPI/Sonar/Http/SonarHttpProvider.cs @@ -8,13 +8,6 @@ namespace SteelSeriesAPI.Sonar.Http; public class SonarHttpProvider : ISonarDataProvider { - private readonly ISonarBridge _sonarBridge; - - public SonarHttpProvider(SonarBridge sonarBridge) - { - _sonarBridge = sonarBridge; - } - public Mode GetMode() { string mode = new HttpProvider("mode").Provide().RootElement.ToString(); @@ -22,124 +15,6 @@ public Mode GetMode() return (Mode)ModeExtensions.FromDictKey(mode, ModeMapChoice.StreamDict); } - public double GetVolume(Channel channel) - { - JsonDocument volumeSettings = new HttpProvider("volumeSettings/classic/").Provide(); - - if (channel == Channel.MASTER) - return volumeSettings.RootElement.GetProperty("masters").GetProperty("classic").GetProperty("volume").GetDouble(); - return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("classic").GetProperty("volume").GetDouble(); - } - - public double GetVolume(Channel channel, Mix mix) - { - JsonDocument volumeSettings = new HttpProvider("volumeSettings/streamer/").Provide(); - - if (channel == Channel.MASTER) - return volumeSettings.RootElement.GetProperty("masters").GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("volume").GetDouble(); - return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("volume").GetDouble(); - } - - public bool GetMute(Channel channel) - { - JsonDocument volumeSettings = new HttpProvider("volumeSettings/classic/").Provide(); - - if (channel == Channel.MASTER) - return volumeSettings.RootElement.GetProperty("masters").GetProperty("classic").GetProperty("muted").GetBoolean(); - return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("classic").GetProperty("muted").GetBoolean(); - } - - public bool GetMute(Channel channel, Mix mix) - { - JsonDocument volumeSettings = new HttpProvider("volumeSettings/streamer/").Provide(); - - if (channel == Channel.MASTER) - return volumeSettings.RootElement.GetProperty("masters").GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("muted").GetBoolean(); - return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("muted").GetBoolean(); - } - - #region AudioConfigs - - public IEnumerable GetAllAudioConfigurations() - { - JsonDocument configs = new HttpProvider("configs").Provide(); - - foreach (var element in configs.RootElement.EnumerateArray()) - { - string vDevice = element.GetProperty("virtualAudioDevice").GetString(); - string id = element.GetProperty("id").GetString(); - string name = element.GetProperty("name").GetString(); - - yield return new SonarAudioConfiguration(id, name, (Channel)ChannelExtensions.FromDictKey(vDevice)); - } - } - - public SonarAudioConfiguration GetAudioConfiguration(string configId) - { - IEnumerable configs = GetAllAudioConfigurations(); - SonarAudioConfiguration sonarConfig = null; - - foreach (var config in configs) - { - if (config.Id == configId) - { - sonarConfig = config; - break; - } - } - - return sonarConfig; - } - - public IEnumerable GetAudioConfigurations(Channel channel) - { - if (channel == Channel.MASTER) - { - throw new Exception("Can't get audio configurations for master"); - } - - IEnumerable configs = GetAllAudioConfigurations(); - List deviceConfigs = new List(); - - foreach (var config in configs) - { - if (config.AssociatedChannel == channel) - { - deviceConfigs.Add(config); - } - } - - return deviceConfigs.OrderBy(s => s.Name); - } - - public SonarAudioConfiguration GetSelectedAudioConfiguration(Channel channel) - { - if (channel == Channel.MASTER) - { - throw new Exception("Can't get audio configuration for master"); - } - - JsonDocument selectedConfigs = new HttpProvider("configs/selected").Provide(); - JsonElement sConfig = default; - - foreach (var config in selectedConfigs.RootElement.EnumerateArray()) - { - if (config.GetProperty("virtualAudioDevice").GetString() == channel.ToDictKey()) - { - sConfig = config; - break; - } - } - - string id = sConfig.GetProperty("id").GetString(); - string name = sConfig.GetProperty("name").GetString(); - string vDevice = sConfig.GetProperty("virtualAudioDevice").GetString(); - - return new SonarAudioConfiguration(id, name, (Channel)ChannelExtensions.FromDictKey(vDevice)); - } - - #endregion - #region ChatMix public double GetChatMixBalance() @@ -167,179 +42,6 @@ public bool GetChatMixState() #endregion - public IEnumerable GetPlaybackDevices(DataFlow _dataFlow) - { - JsonDocument audioDevices = new HttpProvider("audioDevices").Provide(); - JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); - JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); - - foreach (var element in audioDevices.RootElement.EnumerateArray()) - { - if (element.GetProperty("role").GetString() != "none") - { - continue; - } - - string id = element.GetProperty("id").GetString(); - string name = element.GetProperty("friendlyName").GetString(); - string dataFlow = element.GetProperty("dataFlow").GetString(); - List associatedClassicDevices = new List(); - ArrayList associatedStreamDevices = new ArrayList(); - - GetAssociatedDevices(id, associatedClassicDevices, associatedStreamDevices); - - if (dataFlow == _dataFlow.ToDictKey()) - { - yield return new PlaybackDevice(id, name, (DataFlow)DataFlowExtensions.FromDictKey(dataFlow), associatedClassicDevices, associatedStreamDevices); - } - } - } - - public PlaybackDevice GetClassicPlaybackDevice(Channel channel) - { - if (channel == Channel.MASTER) - { - throw new Exception("Can't get redirection channel for master"); - } - - JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); - JsonElement cRedirections = default; - - foreach (var element in classicRedirections.RootElement.EnumerateArray()) - { - if (element.GetProperty("id").GetString() == channel.ToDictKey(ChannelMapChoice.ChannelDict)) - { - cRedirections = element; - break; - } - } - - string deviceId = cRedirections.GetProperty("deviceId").GetString(); - List associatedClassicDevices = new List(); - ArrayList associatedStreamDevices = new ArrayList(); - - GetAssociatedDevices(deviceId, associatedClassicDevices, associatedStreamDevices); - - JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); - - string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); - DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); - - return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicDevices, associatedStreamDevices); - } - - public PlaybackDevice GetStreamPlaybackDevice(Mix mix) - { - JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); - JsonElement sRedirections = default; - - foreach (var element in streamRedirections.RootElement.EnumerateArray()) - { - if (element.GetProperty("streamRedirectionId").GetString() == mix.ToDictKey()) - { - sRedirections = element; - break; - } - } - - string deviceId = sRedirections.GetProperty("deviceId").GetString(); - List associatedClassicDevices = new List();ArrayList associatedStreamDevices = new ArrayList(); - - GetAssociatedDevices(deviceId, associatedClassicDevices, associatedStreamDevices); - - JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); - - string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); - DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); - - return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicDevices, associatedStreamDevices); - } - - public PlaybackDevice GetStreamPlaybackDevice(Channel channel) - { - if (channel != Channel.MIC) - { - throw new Exception("Can only get stream redirection channel for Mic"); - } - - JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); - JsonElement sRedirections = default; - - foreach (var element in streamRedirections.RootElement.EnumerateArray()) - { - if (element.GetProperty("streamRedirectionId").GetString() == channel.ToDictKey(ChannelMapChoice.ChannelDict)) - { - sRedirections = element; - break; - } - } - - string deviceId = sRedirections.GetProperty("deviceId").GetString(); - List associatedClassicDevices = new List(); - ArrayList associatedStreamDevices = new ArrayList(); - - GetAssociatedDevices(deviceId, associatedClassicDevices, associatedStreamDevices); - - JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); - - string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); - DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); - - return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicDevices, associatedStreamDevices); - } - - public PlaybackDevice GetPlaybackDeviceFromId(string deviceId) - { - try - { - JsonElement device = new HttpProvider("audioDevices/" + deviceId).Provide().RootElement; - - string id = device.GetProperty("id").GetString(); - string name = device.GetProperty("friendlyName").GetString(); - string dataFlow = device.GetProperty("dataFlow").GetString(); - List associatedClassicDevices = new List(); - ArrayList associatedStreamDevices = new ArrayList(); - - GetAssociatedDevices(deviceId, associatedClassicDevices, associatedStreamDevices); - - return new PlaybackDevice(id, name, (DataFlow)DataFlowExtensions.FromDictKey(dataFlow), associatedClassicDevices, associatedStreamDevices); - } - catch (Exception e) - { - Console.WriteLine(e); - throw new Exception("Can't get any channel from this Id, maybe the channel doesn't exist or its Id changed."); - } - } - - private void GetAssociatedDevices(string deviceId, List associatedClassicDevices, ArrayList associatedStreamDevices) - { - JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); - JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); - - foreach (var element in classicRedirections.RootElement.EnumerateArray()) - { - if (element.GetProperty("deviceId").GetString() == deviceId) - { - associatedClassicDevices.Add((Channel)ChannelExtensions.FromDictKey(element.GetProperty("id").GetString(), ChannelMapChoice.ChannelDict)); - } - } - - foreach (var element in streamRedirections.RootElement.EnumerateArray()) - { - if (element.GetProperty("deviceId").GetString() == deviceId) - { - if (element.GetProperty("streamRedirectionId").GetString() == "mic") - { - associatedStreamDevices.Add((Channel)ChannelExtensions.FromDictKey(element.GetProperty("streamRedirectionId").GetString(), ChannelMapChoice.ChannelDict)); - } - else - { - associatedStreamDevices.Add((Mix)MixExtensions.FromDictKey(element.GetProperty("streamRedirectionId").GetString())); - } - } - } - } - public bool GetRedirectionState(Channel channel, Mix mix) { if (channel == Channel.MASTER) diff --git a/SteelSeriesAPI/Sonar/Interfaces/ISonarCommandHandler.cs b/SteelSeriesAPI/Sonar/Interfaces/ISonarCommandHandler.cs index ed732c6..69f47c9 100644 --- a/SteelSeriesAPI/Sonar/Interfaces/ISonarCommandHandler.cs +++ b/SteelSeriesAPI/Sonar/Interfaces/ISonarCommandHandler.cs @@ -9,51 +9,6 @@ public interface ISonarCommandHandler /// /// The you want to set void SetMode(Mode mode); - - /// - /// Set the volume of a Sonar - /// - /// The volume you want to set, between 1 and 0 - /// The you want to change the volume - void SetVolume(double vol, Channel channel); - - /// - /// Set the volume of a Streamer mode Sonar - /// - /// The volume you want to set, between 1 and 0 - /// The you want to change the volume - /// The you want to change the volume - void SetVolume(double vol, Channel channel, Mix mix); - - /// - /// Mute or unmute a Sonar - /// - /// The new muted state - /// The you want to un/mute - void SetMute(bool mute, Channel channel); - - /// - /// Mute or unmute a Streamer mode Sonar - /// - /// The new muted state - /// The you want to un/mute - /// The you want to un/mute - void SetMute(bool mute, Channel channel, Mix mix); - - /// - /// Set the config of a Sonar by giving its id - /// - /// For more explanation, go on the GitHub wiki - /// The id of the config - void SetConfig(string configId); - - /// - /// Set the config of a Sonar by giving its name - /// - /// For more explanation, go on the GitHub wiki - /// The you want to change the config - /// The name of the config - void SetConfig(Channel channel, string name); /// /// Set the balance of the ChatMix @@ -62,28 +17,6 @@ public interface ISonarCommandHandler /// A between -1 and 1 void SetChatMixBalance(double balance); - /// - /// Set the Redirection Channel of a Sonar using its ID - /// - /// The id of the new Redirection Channel - /// The Sonar you want to change the Redirection Channel - void SetClassicPlaybackDevice(string deviceId, Channel channel); - - /// - /// Set the Redirection Channel of a Streamer mode Sonar using its ID - /// - /// The id of the new Redirection Channel - /// The Sonar you want to change the Redirection Channel - void SetStreamPlaybackDevice(string deviceId, Mix mix); - - /// - /// Set the Redirection Channel of the Streamer mode Sonar using its ID - /// - /// The id of the new Redirection Channel - /// The Sonar you want to change the redirection channel - /// should be set to for it to work - void SetStreamPlaybackDevice(string deviceId, Channel channel = Channel.MIC); - /// /// Enable or disable the Redirection of the chosen Sonar of the chosen Sonar /// diff --git a/SteelSeriesAPI/Sonar/Interfaces/ISonarDataProvider.cs b/SteelSeriesAPI/Sonar/Interfaces/ISonarDataProvider.cs index b909867..01d296e 100644 --- a/SteelSeriesAPI/Sonar/Interfaces/ISonarDataProvider.cs +++ b/SteelSeriesAPI/Sonar/Interfaces/ISonarDataProvider.cs @@ -11,63 +11,6 @@ public interface ISonarDataProvider /// A , either Classic or Streamer Mode GetMode(); - /// - /// Get the volume of a Sonar - /// - /// The Sonar you want the volume - /// The volume of the mix in double, value between 0 and 1 - double GetVolume(Channel channel); - - /// - /// Get the volume of a Steamer mode Sonar - /// - /// The Sonar you want the volume - /// The Sonar you want the volume - /// The volume of the mix in double, value between 0 and 1 - double GetVolume(Channel channel, Mix mix); - - /// - /// Get the mute state of a Sonar - /// - /// The Sonar you want the mute state - /// The mute state, a boolean - bool GetMute(Channel channel); - - /// - /// Get the mute state of a Streamer mode Sonar - /// - /// The Sonar you want the mute state - /// The Sonar you want the mute state - /// The mute state, a boolean - bool GetMute(Channel channel, Mix mix); - - /// - /// Get all audio configurations from Sonar - /// - /// An IEnumerable of - IEnumerable GetAllAudioConfigurations(); - - /// - /// Get a specific audio configuration from Sonar - /// - /// The id of the config - /// A - SonarAudioConfiguration GetAudioConfiguration(string configId); - - /// - /// Get all audio configurations of a from Sonar - /// - /// The channel you want the configs - /// An IEnumerable of ordered alphabetically - IEnumerable GetAudioConfigurations(Channel channel); - - /// - /// Get the current audio configuration of a chosen - /// - /// The channel you want the current config - /// A - SonarAudioConfiguration GetSelectedAudioConfiguration(Channel channel); - /// /// Get the actual ChatMix balance value /// @@ -80,42 +23,6 @@ public interface ISonarDataProvider /// True if ChatMix is enabled
False if ChatMix is disabled
bool GetChatMixState(); - /// - /// Get all the in/output Redirection Devices (Windows devices) - /// - /// The DataFlow of the channel (In/Output) - /// A list of - IEnumerable GetPlaybackDevices(DataFlow dataFlow); - - /// - /// Get the current Redirection Channel of a Sonar - /// - /// The Sonar you want the redirection channel - /// - PlaybackDevice GetClassicPlaybackDevice(Channel channel); - - /// - /// Get the current Redirection Channel of a Streamer mode Sonar - /// - /// The Sonar you want the redirection channel - /// A - PlaybackDevice GetStreamPlaybackDevice(Mix mix); - - /// - /// Get the current Redirection Channel of the Streamer mode Sonar - /// - /// The Sonar you want to change the redirection channel - /// - /// should be set to for it to work - PlaybackDevice GetStreamPlaybackDevice(Channel channel = Channel.MIC); - - /// - /// Get a Redirection Channel using its ID - /// - /// The ID of the Redirection Channel - /// - PlaybackDevice GetPlaybackDeviceFromId(string deviceId); - /// /// Get the mute state of the Redirection of the chosen Sonar of the chosen Sonar /// diff --git a/SteelSeriesAPI/Sonar/Interfaces/Managers/IConfigurationManager.cs b/SteelSeriesAPI/Sonar/Interfaces/Managers/IConfigurationManager.cs new file mode 100644 index 0000000..1db642a --- /dev/null +++ b/SteelSeriesAPI/Sonar/Interfaces/Managers/IConfigurationManager.cs @@ -0,0 +1,57 @@ +using SteelSeriesAPI.Sonar.Enums; +using SteelSeriesAPI.Sonar.Models; + +namespace SteelSeriesAPI.Sonar.Interfaces.Managers; + +public interface IConfigurationManager +{ + + /// + /// Get all audio configurations from Sonar + /// + /// An IEnumerable of + IEnumerable GetAllAudioConfigurations(); + + /// + /// Get all audio configurations of a from Sonar + /// + /// The channel you want the configs + /// An IEnumerable of ordered alphabetically + IEnumerable GetAudioConfigurations(Channel channel); + + /// + /// Get a specific audio configuration from Sonar + /// + /// The id of the config + /// A + SonarAudioConfiguration GetAudioConfiguration(string configId); + + /// + /// Get the current audio configuration of a chosen + /// + /// The channel you want the current config + /// A + SonarAudioConfiguration GetSelectedAudioConfiguration(Channel channel); + + /// + /// Set the config of a Sonar by giving its id + /// + /// For more explanation, go on the GitHub wiki + /// The id of the config + void SetConfig(string configId); + + /// + /// Set the config of a Sonar by giving a + /// + /// For more explanation, go on the GitHub wiki + /// The id + void SetConfig(SonarAudioConfiguration config); + + /// + /// Set the config of a Sonar by giving its name + /// + /// For more explanation, go on the GitHub wiki + /// The you want to change the config + /// The name of the config + void SetConfigByName(Channel channel, string name); +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Interfaces/Managers/IPlaybackDeviceManager.cs b/SteelSeriesAPI/Sonar/Interfaces/Managers/IPlaybackDeviceManager.cs new file mode 100644 index 0000000..1fc84e2 --- /dev/null +++ b/SteelSeriesAPI/Sonar/Interfaces/Managers/IPlaybackDeviceManager.cs @@ -0,0 +1,68 @@ +using SteelSeriesAPI.Sonar.Enums; +using SteelSeriesAPI.Sonar.Models; + +namespace SteelSeriesAPI.Sonar.Interfaces.Managers; + +public interface IPlaybackDeviceManager +{ + /// + /// Get all the in/output Redirection Devices (Windows devices) + /// + /// The DataFlow of the channel (In/Output) + /// A list of + IEnumerable GetPlaybackDevices(DataFlow _dataFlow); + + /// + /// Get a Redirection Channel using its ID + /// + /// The ID of the Redirection Channel + /// + PlaybackDevice GetPlaybackDevice(string deviceId); + + /// + /// Get the current Redirection Channel of a Sonar + /// + /// The Sonar you want the redirection channel + /// + PlaybackDevice GetClassicPlaybackDevice(Channel channel); + + /// + /// Get the current Redirection Channel of a Streamer mode Sonar + /// + /// The Sonar you want the redirection channel + /// A + PlaybackDevice GetStreamerPlaybackDevice(Mix mix); + + /// + /// Get the current Redirection Channel of the Streamer mode Sonar + /// + /// The Sonar you want to change the redirection channel + /// + /// should be set to for it to work + PlaybackDevice GetStreamerPlaybackDevice(Channel channel = Channel.MIC); + + /// + /// Set the Redirection Channel of a Sonar using its ID + /// + /// The id of the new Redirection Channel + /// The Sonar you want to change the Redirection Channel + void SetClassicPlaybackDevice(string deviceId, Channel channel); + + /// + /// Set the Redirection Channel of a Streamer mode Sonar using its ID + /// + /// The id of the new Redirection Channel + /// The Sonar you want to change the Redirection Channel + void SetStreamerPlaybackDevice(string deviceId, Mix mix); + + /// + /// Set the Redirection Channel of the Streamer mode Sonar using its ID + /// + /// The id of the new Redirection Channel + /// The Sonar you want to change the redirection channel + /// should be set to for it to work + void SetStreamerPlaybackDevice(string deviceId, Channel channel = Channel.MIC); + void SetClassicPlaybackDevice(PlaybackDevice playbackDevice, Channel channel); + void SetStreamerPlaybackDevice(PlaybackDevice playbackDevice, Mix mix); + void SetStreamerPlaybackDevice(PlaybackDevice playbackDevice, Channel channel = Channel.MIC); +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Interfaces/Managers/IVolumeSettingsManager.cs b/SteelSeriesAPI/Sonar/Interfaces/Managers/IVolumeSettingsManager.cs new file mode 100644 index 0000000..e23f041 --- /dev/null +++ b/SteelSeriesAPI/Sonar/Interfaces/Managers/IVolumeSettingsManager.cs @@ -0,0 +1,66 @@ +using SteelSeriesAPI.Sonar.Enums; + +namespace SteelSeriesAPI.Sonar.Interfaces.Managers; + +internal interface IVolumeSettingsManager +{ + /// + /// Get the volume of a Sonar + /// + /// The Sonar you want the volume + /// The volume of the channel in double, value between 0 and 1 + double GetVolume(Channel channel); + + /// + /// Get the volume of a Steamer mode Sonar + /// + /// The Sonar you want the volume + /// The Sonar you want the volume + /// The volume of the mix in double, value between 0 and 1 + double GetVolume(Channel channel, Mix mix); + + /// + /// Get the mute state of a Sonar + /// + /// The Sonar you want the mute state + /// The mute state, a boolean + bool GetMute(Channel channel); + + /// + /// Get the mute state of a Streamer mode Sonar + /// + /// The Sonar you want the mute state + /// The Sonar you want the mute state + /// The mute state, a boolean + bool GetMute(Channel channel, Mix mix); + + /// + /// Set the volume of a Sonar + /// + /// The volume you want to set, between 1 and 0 + /// The you want to change the volume + void SetVolume(double vol, Channel channel); + + /// + /// Set the volume of a Streamer mode Sonar + /// + /// The volume you want to set, between 1 and 0 + /// The you want to change the volume + /// The you want to change the volume + void SetVolume(double vol, Channel channel, Mix mix); + + /// + /// Mute or unmute a Sonar + /// + /// The new muted state + /// The you want to un/mute + void SetMute(bool mute, Channel channel); + + /// + /// Mute or unmute a Streamer mode Sonar + /// + /// The new muted state + /// The you want to un/mute + /// The you want to un/mute + void SetMute(bool mute, Channel channel, Mix mix); +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Managers/ConfigurationManager.cs b/SteelSeriesAPI/Sonar/Managers/ConfigurationManager.cs new file mode 100644 index 0000000..9a417fb --- /dev/null +++ b/SteelSeriesAPI/Sonar/Managers/ConfigurationManager.cs @@ -0,0 +1,114 @@ +using SteelSeriesAPI.Sonar.Interfaces.Managers; +using SteelSeriesAPI.Sonar.Enums; +using SteelSeriesAPI.Sonar.Http; +using SteelSeriesAPI.Sonar.Models; + +using System.Text.Json; + +namespace SteelSeriesAPI.Sonar.Managers; + +public class ConfigurationManager : IConfigurationManager +{ + public IEnumerable GetAllAudioConfigurations() + { + JsonDocument configs = new HttpProvider("configs").Provide(); + + foreach (var element in configs.RootElement.EnumerateArray()) + { + string vDevice = element.GetProperty("virtualAudioDevice").GetString(); + string id = element.GetProperty("id").GetString(); + string name = element.GetProperty("name").GetString(); + + yield return new SonarAudioConfiguration(id, name, (Channel)ChannelExtensions.FromDictKey(vDevice)); + } + } + + public IEnumerable GetAudioConfigurations(Channel channel) + { + if (channel == Channel.MASTER) + { + throw new Exception("Can't get audio configurations for master"); + } + + IEnumerable configs = GetAllAudioConfigurations(); + List channelConfigs = new List(); + + foreach (var config in configs) + { + if (config.AssociatedChannel == channel) + { + channelConfigs.Add(config); + } + } + + return channelConfigs.OrderBy(s => s.Name); + } + + public SonarAudioConfiguration GetAudioConfiguration(string configId) + { + IEnumerable configs = GetAllAudioConfigurations(); + SonarAudioConfiguration sonarConfig = null; + + foreach (var config in configs) + { + if (config.Id == configId) + { + sonarConfig = config; + break; + } + } + + return sonarConfig; + } + + public SonarAudioConfiguration GetSelectedAudioConfiguration(Channel channel) + { + if (channel == Channel.MASTER) + { + throw new Exception("Can't get audio configuration for master"); + } + + JsonDocument selectedConfigs = new HttpProvider("configs/selected").Provide(); + JsonElement sConfig = default; + + foreach (var config in selectedConfigs.RootElement.EnumerateArray()) + { + if (config.GetProperty("virtualAudioDevice").GetString() == channel.ToDictKey()) + { + sConfig = config; + break; + } + } + + string id = sConfig.GetProperty("id").GetString(); + string name = sConfig.GetProperty("name").GetString(); + string vDevice = sConfig.GetProperty("virtualAudioDevice").GetString(); + + return new SonarAudioConfiguration(id, name, (Channel)ChannelExtensions.FromDictKey(vDevice)); + } + + public void SetConfig(string configId) + { + if (string.IsNullOrEmpty(configId)) throw new Exception("Couldn't retrieve config id"); + + new HttpPut("configs/" + configId + "/select"); + } + + public void SetConfig(SonarAudioConfiguration config) + { + SetConfig(config.Id); + } + + public void SetConfigByName(Channel channel, string name) + { + var configs = GetAudioConfigurations(channel).ToList(); + foreach (var config in configs) + { + if (config.Name == name) + { + SetConfig(config.Id); + break; + } + } + } +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Managers/PlaybackDeviceManager.cs b/SteelSeriesAPI/Sonar/Managers/PlaybackDeviceManager.cs new file mode 100644 index 0000000..a84cb90 --- /dev/null +++ b/SteelSeriesAPI/Sonar/Managers/PlaybackDeviceManager.cs @@ -0,0 +1,221 @@ +using System.Collections; +using SteelSeriesAPI.Sonar.Interfaces.Managers; +using SteelSeriesAPI.Sonar.Enums; +using SteelSeriesAPI.Sonar.Http; +using SteelSeriesAPI.Sonar.Models; + +using System.Text.Json; + +namespace SteelSeriesAPI.Sonar.Managers; + +public class PlaybackDeviceManager : IPlaybackDeviceManager +{ + public IEnumerable GetPlaybackDevices(DataFlow _dataFlow) + { + JsonDocument audioDevices = new HttpProvider("audioDevices").Provide(); + // JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); + // JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); + + foreach (var element in audioDevices.RootElement.EnumerateArray()) + { + if (element.GetProperty("role").GetString() != "none") + { + continue; + } + + string id = element.GetProperty("id").GetString(); + string name = element.GetProperty("friendlyName").GetString(); + string dataFlow = element.GetProperty("dataFlow").GetString(); + List associatedClassicChannels = new List(); + ArrayList associatedStreamChannels = new ArrayList(); + + GetAssociatedChannels(id, associatedClassicChannels, associatedStreamChannels); + + if (dataFlow == _dataFlow.ToDictKey()) + { + yield return new PlaybackDevice(id, name, (DataFlow)DataFlowExtensions.FromDictKey(dataFlow), associatedClassicChannels, associatedStreamChannels); + } + } + } + + public PlaybackDevice GetPlaybackDevice(string deviceId) + { + try + { + JsonElement device = new HttpProvider("audioDevices/" + deviceId).Provide().RootElement; + + string id = device.GetProperty("id").GetString(); + string name = device.GetProperty("friendlyName").GetString(); + string dataFlow = device.GetProperty("dataFlow").GetString(); + List associatedClassicChannels = new List(); + ArrayList associatedStreamChannels = new ArrayList(); + + GetAssociatedChannels(deviceId, associatedClassicChannels, associatedStreamChannels); + + return new PlaybackDevice(id, name, (DataFlow)DataFlowExtensions.FromDictKey(dataFlow), associatedClassicChannels, associatedStreamChannels); + } + catch (Exception e) + { + Console.WriteLine(e); + throw new Exception("Can't get any channel from this Id, maybe the channel doesn't exist or its Id changed."); + } + } + + public PlaybackDevice GetClassicPlaybackDevice(Channel channel) + { + if (channel == Channel.MASTER) + { + throw new Exception("Can't get redirection channel for master"); + } + + JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); + JsonElement cRedirections = default; + + foreach (var element in classicRedirections.RootElement.EnumerateArray()) + { + if (element.GetProperty("id").GetString() == channel.ToDictKey(ChannelMapChoice.ChannelDict)) + { + cRedirections = element; + break; + } + } + + string deviceId = cRedirections.GetProperty("deviceId").GetString(); + List associatedClassicChannels = new List(); + ArrayList associatedStreamChannels = new ArrayList(); + + GetAssociatedChannels(deviceId, associatedClassicChannels, associatedStreamChannels); + + JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); + + string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); + DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); + + return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicChannels, associatedStreamChannels); + } + + public PlaybackDevice GetStreamerPlaybackDevice(Mix mix) + { + JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); + JsonElement sRedirections = default; + + foreach (var element in streamRedirections.RootElement.EnumerateArray()) + { + if (element.GetProperty("streamRedirectionId").GetString() == mix.ToDictKey()) + { + sRedirections = element; + break; + } + } + + string deviceId = sRedirections.GetProperty("deviceId").GetString(); + List associatedClassicChannels = new List(); + ArrayList associatedStreamChannels = new ArrayList(); + + GetAssociatedChannels(deviceId, associatedClassicChannels, associatedStreamChannels); + + JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); + + string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); + DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); + + return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicChannels, associatedStreamChannels); + } + + public PlaybackDevice GetStreamerPlaybackDevice(Channel channel = Channel.MIC) + { + if (channel != Channel.MIC) + { + throw new Exception("Can only get stream redirection channel for Mic"); + } + + JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); + JsonElement sRedirections = default; + + foreach (var element in streamRedirections.RootElement.EnumerateArray()) + { + if (element.GetProperty("streamRedirectionId").GetString() == channel.ToDictKey(ChannelMapChoice.ChannelDict)) + { + sRedirections = element; + break; + } + } + + string deviceId = sRedirections.GetProperty("deviceId").GetString(); + List associatedClassicChannels = new List(); + ArrayList associatedStreamChannels = new ArrayList(); + + GetAssociatedChannels(deviceId, associatedClassicChannels, associatedStreamChannels); + + JsonDocument audioDevice = new HttpProvider("audioDevices/" + deviceId).Provide(); + + string name = audioDevice.RootElement.GetProperty("friendlyName").GetString(); + DataFlow dataFlow = (DataFlow)DataFlowExtensions.FromDictKey(audioDevice.RootElement.GetProperty("dataFlow").GetString()); + + return new PlaybackDevice(deviceId, name, dataFlow, associatedClassicChannels, associatedStreamChannels); + } + + private void GetAssociatedChannels(string deviceId, List associatedClassicDevices, ArrayList associatedStreamDevices) + { + JsonDocument classicRedirections = new HttpProvider("classicRedirections").Provide(); + JsonDocument streamRedirections = new HttpProvider("streamRedirections").Provide(); + + foreach (var element in classicRedirections.RootElement.EnumerateArray()) + { + if (element.GetProperty("deviceId").GetString() == deviceId) + { + associatedClassicDevices.Add((Channel)ChannelExtensions.FromDictKey(element.GetProperty("id").GetString(), ChannelMapChoice.ChannelDict)); + } + } + + foreach (var element in streamRedirections.RootElement.EnumerateArray()) + { + if (element.GetProperty("deviceId").GetString() == deviceId) + { + if (element.GetProperty("streamRedirectionId").GetString() == "mic") + { + associatedStreamDevices.Add((Channel)ChannelExtensions.FromDictKey(element.GetProperty("streamRedirectionId").GetString(), ChannelMapChoice.ChannelDict)); + } + else + { + associatedStreamDevices.Add((Mix)MixExtensions.FromDictKey(element.GetProperty("streamRedirectionId").GetString())); + } + } + } + } + + public void SetClassicPlaybackDevice(string deviceId, Channel channel) + { + new HttpPut("classicRedirections/" + channel.ToDictKey(ChannelMapChoice.ChannelDict) +"/deviceId/" + deviceId); + } + + public void SetStreamerPlaybackDevice(string deviceId, Mix mix) + { + new HttpPut("streamRedirections/" + mix.ToDictKey() +"/deviceId/" + deviceId); + } + + public void SetStreamerPlaybackDevice(string deviceId, Channel channel = Channel.MIC) + { + if (channel != Channel.MIC) + { + throw new Exception("Can only change stream redirection channel for Mic"); + } + + new HttpPut("streamRedirections/" + channel.ToDictKey(ChannelMapChoice.ChannelDict) +"/deviceId/" + deviceId); + } + + public void SetClassicPlaybackDevice(PlaybackDevice playbackDevice, Channel channel) + { + SetClassicPlaybackDevice(playbackDevice.Id, channel); + } + + public void SetStreamerPlaybackDevice(PlaybackDevice playbackDevice, Mix mix) + { + SetStreamerPlaybackDevice(playbackDevice.Id, mix); + } + + public void SetStreamerPlaybackDevice(PlaybackDevice playbackDevice, Channel channel = Channel.MIC) + { + SetStreamerPlaybackDevice(playbackDevice.Id, channel); + } +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Managers/VolumeSettingsManager.cs b/SteelSeriesAPI/Sonar/Managers/VolumeSettingsManager.cs new file mode 100644 index 0000000..52caedb --- /dev/null +++ b/SteelSeriesAPI/Sonar/Managers/VolumeSettingsManager.cs @@ -0,0 +1,70 @@ +using SteelSeriesAPI.Sonar.Interfaces.Managers; +using SteelSeriesAPI.Sonar.Enums; +using SteelSeriesAPI.Sonar.Http; + +using System.Globalization; +using System.Text.Json; + +namespace SteelSeriesAPI.Sonar.Managers; + +public class VolumeSettingsManager : IVolumeSettingsManager +{ + // volume = 0,00000000 <-- 8 decimal max + public double GetVolume(Channel channel) + { + JsonDocument volumeSettings = new HttpProvider("volumeSettings/classic/").Provide(); + + if (channel == Channel.MASTER) + return volumeSettings.RootElement.GetProperty("masters").GetProperty("classic").GetProperty("volume").GetDouble(); + return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("classic").GetProperty("volume").GetDouble(); + } + + public double GetVolume(Channel channel, Mix mix) + { + JsonDocument volumeSettings = new HttpProvider("volumeSettings/streamer/").Provide(); + + if (channel == Channel.MASTER) + return volumeSettings.RootElement.GetProperty("masters").GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("volume").GetDouble(); + return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("volume").GetDouble(); + } + + public bool GetMute(Channel channel) + { + JsonDocument volumeSettings = new HttpProvider("volumeSettings/classic/").Provide(); + + if (channel == Channel.MASTER) + return volumeSettings.RootElement.GetProperty("masters").GetProperty("classic").GetProperty("muted").GetBoolean(); + return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("classic").GetProperty("muted").GetBoolean(); + } + + public bool GetMute(Channel channel, Mix mix) + { + JsonDocument volumeSettings = new HttpProvider("volumeSettings/streamer/").Provide(); + + if (channel == Channel.MASTER) + return volumeSettings.RootElement.GetProperty("masters").GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("muted").GetBoolean(); + return volumeSettings.RootElement.GetProperty("devices").GetProperty(channel.ToDictKey()).GetProperty("stream").GetProperty(mix.ToDictKey()).GetProperty("muted").GetBoolean(); + } + + public void SetVolume(double vol, Channel channel) + { + string _vol = vol.ToString("0.00", CultureInfo.InvariantCulture); + new HttpPut("volumeSettings/classic/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/Volume/" + _vol); + } + + public void SetVolume(double vol, Channel channel, Mix mix) + { + string _vol = vol.ToString("0.00", CultureInfo.InvariantCulture); + new HttpPut("volumeSettings/streamer/" + mix.ToDictKey() + "/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/volume/" + _vol); + } + + public void SetMute(bool mute, Channel channel) + { + new HttpPut("volumeSettings/classic/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/Mute/" + mute); + } + + public void SetMute(bool mute, Channel channel, Mix mix) + { + new HttpPut("volumeSettings/streamer/" + mix.ToDictKey() + "/" + channel.ToDictKey(ChannelMapChoice.HttpDict) + "/isMuted/" + mute); + } +} \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/Models/PlaybackDevice.cs b/SteelSeriesAPI/Sonar/Models/PlaybackDevice.cs index 9e568b6..6ff6ed3 100644 --- a/SteelSeriesAPI/Sonar/Models/PlaybackDevice.cs +++ b/SteelSeriesAPI/Sonar/Models/PlaybackDevice.cs @@ -3,4 +3,4 @@ namespace SteelSeriesAPI.Sonar.Models; -public record PlaybackDevice(string Id, string Name, DataFlow DataFlow, List? AssociatedClassicDevices, ArrayList? AssociatedStreamDevices); \ No newline at end of file +public record PlaybackDevice(string Id, string Name, DataFlow DataFlow, List? AssociatedClassicChannels, ArrayList? AssociatedStreamChannels); \ No newline at end of file diff --git a/SteelSeriesAPI/Sonar/SonarBridge.cs b/SteelSeriesAPI/Sonar/SonarBridge.cs index 3b9e71c..b04f58a 100644 --- a/SteelSeriesAPI/Sonar/SonarBridge.cs +++ b/SteelSeriesAPI/Sonar/SonarBridge.cs @@ -19,7 +19,11 @@ public class SonarBridge : ISonarBridge private readonly ISonarCommandHandler _sonarCommand; private readonly ISonarDataProvider _sonarProvider; private readonly ISonarSocket _sonarSocket; - public readonly EventManager EventManager; + + public readonly VolumeSettingsManager VolumeSettings; + public readonly ConfigurationManager Configurations; + public readonly PlaybackDeviceManager PlaybackDevices; + public readonly EventManager Event; private string _sonarWebServerAddress; @@ -28,10 +32,13 @@ public SonarBridge() _sonarRetriever = SonarRetriever.Instance; WaitUntilSonarStarted(); _sonarWebServerAddress = _sonarRetriever.WebServerAddress(); - EventManager = new EventManager(); - _sonarSocket = new SonarSocket(_sonarWebServerAddress, EventManager); + _sonarSocket = new SonarSocket(_sonarWebServerAddress, Event); _sonarCommand = new SonarHttpCommand(this); - _sonarProvider = new SonarHttpProvider(this); + _sonarProvider = new SonarHttpProvider(); + VolumeSettings = new VolumeSettingsManager(); + Configurations = new ConfigurationManager(); + PlaybackDevices = new PlaybackDeviceManager(); + Event = new EventManager(); } #region Listener @@ -93,47 +100,6 @@ public Mode GetMode() return _sonarProvider.GetMode(); } - // volume = 0,00000000 <-- 8 decimal max - public double GetVolume(Channel channel) - { - return _sonarProvider.GetVolume(channel); - } - - public double GetVolume(Channel channel, Mix mix) - { - return _sonarProvider.GetVolume(channel, mix); - } - - public bool GetMute(Channel channel) - { - return _sonarProvider.GetMute(channel); - } - - public bool GetMute(Channel channel, Mix mix) - { - return _sonarProvider.GetMute(channel, mix); - } - - public IEnumerable GetAllAudioConfigurations() - { - return _sonarProvider.GetAllAudioConfigurations(); - } - - public SonarAudioConfiguration GetAudioConfiguration(string configId) - { - return _sonarProvider.GetAudioConfiguration(configId); - } - - public IEnumerable GetAudioConfigurations(Channel channel) - { - return _sonarProvider.GetAudioConfigurations(channel); - } - - public SonarAudioConfiguration GetSelectedAudioConfiguration(Channel channel) - { - return _sonarProvider.GetSelectedAudioConfiguration(channel); - } - public double GetChatMixBalance() { return _sonarProvider.GetChatMixBalance(); @@ -144,31 +110,6 @@ public bool GetChatMixState() return _sonarProvider.GetChatMixState(); } - public IEnumerable GetPlaybackDevices(DataFlow dataFlow) - { - return _sonarProvider.GetPlaybackDevices(dataFlow); - } - - public PlaybackDevice GetClassicPlaybackDevice(Channel channel) - { - return _sonarProvider.GetClassicPlaybackDevice(channel); - } - - public PlaybackDevice GetStreamPlaybackDevice(Mix mix) - { - return _sonarProvider.GetStreamPlaybackDevice(mix); - } - - public PlaybackDevice GetStreamPlaybackDevice(Channel channel = Channel.MIC) - { - return _sonarProvider.GetStreamPlaybackDevice(channel); - } - - public PlaybackDevice GetPlaybackDeviceFromId(string deviceId) - { - return _sonarProvider.GetPlaybackDeviceFromId(deviceId); - } - public bool GetRedirectionState(Channel channel, Mix mix) { return _sonarProvider.GetRedirectionState(channel, mix); @@ -193,55 +134,10 @@ public void SetMode(Mode mode) _sonarCommand.SetMode(mode); } - public void SetVolume(double vol, Channel channel) - { - _sonarCommand.SetVolume(vol, channel); - } - - public void SetVolume(double vol, Channel channel, Mix mix) - { - _sonarCommand.SetVolume(vol, channel, mix); - } - - public void SetMute(bool mute, Channel channel) - { - _sonarCommand.SetMute(mute, channel); - } - - public void SetMute(bool mute, Channel channel, Mix mix) - { - _sonarCommand.SetMute(mute, channel, mix); - } - - public void SetConfig(string configId) - { - _sonarCommand.SetConfig(configId); - } - - public void SetConfig(Channel channel, string name) - { - _sonarCommand.SetConfig(channel, name); - } - public void SetChatMixBalance(double balance) { _sonarCommand.SetChatMixBalance(balance); } - - public void SetClassicPlaybackDevice(string deviceId, Channel channel) - { - _sonarCommand.SetClassicPlaybackDevice(deviceId, channel); - } - - public void SetStreamPlaybackDevice(string deviceId, Mix mix) - { - _sonarCommand.SetStreamPlaybackDevice(deviceId, mix); - } - - public void SetStreamPlaybackDevice(string deviceId, Channel channel = Channel.MIC) - { - _sonarCommand.SetStreamPlaybackDevice(deviceId, channel); - } public void SetRedirectionState(bool newState, Channel channel, Mix mix) {