Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions SteelSeriesAPI.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ static void Main(string[] args)
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
bool chatMixState = sonarManager.GetChatMixState(); // If ChatMix is usable or not
double chatMixBalance = sonarManager.ChatMix.GetBalance(); // The ChatMix value between -1 and 1
bool chatMixState = sonarManager.ChatMix.GetState(); // If ChatMix is usable or not
// Change ChatMix value
sonarManager.SetChatMixBalance(0.5); // 0.5 is halfway to Chat
sonarManager.ChatMix.SetBalance(0.5); // 0.5 is halfway to Chat

// Get playback devices (Windows devices)
List<PlaybackDevice> inputDevices = sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.INPUT).ToList(); // Input devices (Mics...)
Expand Down
10 changes: 5 additions & 5 deletions SteelSeriesAPI.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void GetTest(SonarBridge sonarManager)
Console.WriteLine("----Channel from config ID----------");
Console.WriteLine(sonarManager.Configurations.GetAudioConfiguration("29ae2c02-792b-4487-863c-dc3e11a7a469").AssociatedChannel);
Console.WriteLine("--------ChatMix---------");
Console.WriteLine(sonarManager.GetChatMixBalance());
Console.WriteLine(sonarManager.GetChatMixState());
Console.WriteLine(sonarManager.ChatMix.GetBalance());
Console.WriteLine(sonarManager.ChatMix.GetState());

Console.WriteLine("-----Redirection Devices-----------");
Console.WriteLine("---Output---");
Expand Down Expand Up @@ -207,7 +207,7 @@ void GetTest(SonarBridge sonarManager)
}

Console.WriteLine("-- " + device);
foreach (var routed in sonarManager.GetRoutedProcess(device))
foreach (var routed in sonarManager.RoutedProcesses.GetRoutedProcesses(device))
{
Console.WriteLine(routed.Id + ", " + routed.ProcessName + ", " + routed.PId + ", " + routed.State +
", " + routed.DisplayName);
Expand All @@ -223,7 +223,7 @@ void SetTest(SonarBridge sonarManager){
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);
sonarManager.ChatMix.SetBalance(0.5);

var redirectionDevices = sonarManager.PlaybackDevices.GetPlaybackDevices(DataFlow.INPUT);
redirectionDevices.GetEnumerator().MoveNext();
Expand All @@ -232,7 +232,7 @@ void SetTest(SonarBridge sonarManager){

sonarManager.SetRedirectionState(true, Channel.MEDIA, Mix.STREAM);
sonarManager.SetAudienceMonitoringState(false);
sonarManager.SetProcessToDeviceRouting(19152, Channel.MIC);
sonarManager.RoutedProcesses.RouteProcessToChannel(19152, Channel.MIC);
}

static void OnModeChangeHandler(object? sender, SonarModeEvent eventArgs)
Expand Down
4 changes: 2 additions & 2 deletions SteelSeriesAPI/Sonar/Events/SonarAudienceMonitoringEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace SteelSeriesAPI.Sonar.Events;

public class SonarAudienceMonitoringEvent : EventArgs
{
// /streamRedirections/isStreamMonitoringEnabled/bool
public bool AudienceMonitoringState { get; set; }
// /streamRedirections/isStreamMonitoringEnabled/true
public bool NewState { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace SteelSeriesAPI.Sonar.Events;

public class SonarRedirectionStateEvent : EventArgs
public class SonarMixEvent : EventArgs
{
// /streamRedirections/monitoring/redirections/chatRender/isEnabled/true

public bool State { get; set; }
public bool NewState { get; set; }

public Channel Channel { get; set; }

public Mix Mix { get; set; }
}
1 change: 1 addition & 0 deletions SteelSeriesAPI/Sonar/Events/SonarMuteEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class SonarMuteEvent : EventArgs
public Mode Mode { get; set; }

public Channel Channel { get; set; }

public Mix? Mix { get; set; }
}
3 changes: 2 additions & 1 deletion SteelSeriesAPI/Sonar/Events/SonarPlaybackDeviceEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ public class SonarPlaybackDeviceEvent : EventArgs
// /classicRedirections/game/deviceId/%7B0.0.0.00000000%7D.%7B1e1ebefc-2c51-4675-aebe-085a06efd255%7D
// /streamRedirections/monitoring/deviceId/%7B0.0.0.00000000%7D.%7B1e1ebefc-2c51-4675-aebe-085a06efd255%7D

public string RedirectionDeviceId { get; set; }
public string PlaybackDeviceId { get; set; }

public Mode Mode { get; set; }

public Channel? Device { get; set; }

public Mix? Channel { get; set; }
}
40 changes: 40 additions & 0 deletions SteelSeriesAPI/Sonar/Events/SonarRoutedProcessEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using SteelSeriesAPI.Sonar.Enums;
using SteelSeriesAPI.Sonar.Http;
using SteelSeriesAPI.Sonar.Exceptions;

using System.Text.Json;

namespace SteelSeriesAPI.Sonar.Events;

public class SonarRoutedProcessEvent : EventArgs
{
// /AudioDeviceRouting/render/%7B0.0.0.00000000%7D.%7Beb78557a-9882-4205-8014-ad9384173901%7D/4476
// /AudioDeviceRouting/capture/%7B0.0.1.00000000%7D.%7B989ad130-4b1f-4828-a85a-7aef7fd362b7%7D/4476

public int ProcessId { get; init; }

public Channel NewChannel { get; init; }

internal SonarRoutedProcessEvent(string deviceId)
{
NewChannel = DeviceIdToChannel(deviceId);
}

private Channel DeviceIdToChannel(string deviceId)
{
JsonElement audioDeviceRouting = new Fetcher().Provide("AudioDeviceRouting").RootElement;

foreach (JsonElement device in audioDeviceRouting.EnumerateArray())
{
if (device.GetProperty("role").GetString() != "none")
{
if (device.GetProperty("deviceId").GetString() == deviceId)
{
return (Channel)ChannelExtensions.FromDictKey(device.GetProperty("role").GetString()!)!;
}
}
}

throw new RoutedProcessNotFoundException("Event error: Could not find the channel");
}
}
1 change: 1 addition & 0 deletions SteelSeriesAPI/Sonar/Events/SonarVolumeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class SonarVolumeEvent : EventArgs
public Mode Mode { get; set; }

public Channel Channel { get; set; }

public Mix? Mix { get; set; }
}
8 changes: 8 additions & 0 deletions SteelSeriesAPI/Sonar/Exceptions/ChannelNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class ChannelNotFoundException : Exception
{
public ChannelNotFoundException() : base("Channel could not be found.") { }
public ChannelNotFoundException(string message) : base(message) { }
public ChannelNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 8 additions & 0 deletions SteelSeriesAPI/Sonar/Exceptions/ChatMixBalanceException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class ChatMixBalanceException : Exception
{
public ChatMixBalanceException() : base("ChatMix balance out of range.") { }
public ChatMixBalanceException(string message) : base(message) { }
public ChatMixBalanceException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 8 additions & 0 deletions SteelSeriesAPI/Sonar/Exceptions/ChatMixDisabledException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class ChatMixDisabledException : Exception
{
public ChatMixDisabledException() : base("ChatMix is not enabled.") { }
public ChatMixDisabledException(string message) : base(message) { }
public ChatMixDisabledException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 0 additions & 8 deletions SteelSeriesAPI/Sonar/Exceptions/ConfigNotFound.cs

This file was deleted.

8 changes: 8 additions & 0 deletions SteelSeriesAPI/Sonar/Exceptions/ConfigNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class ConfigNotFoundException : Exception
{
public ConfigNotFoundException() : base("No audio configuration found.") { }
public ConfigNotFoundException(string message) : base(message) { }
public ConfigNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 0 additions & 8 deletions SteelSeriesAPI/Sonar/Exceptions/MasterChannelNotSupported.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class MasterChannelNotSupportedException : Exception
{
public MasterChannelNotSupportedException() : base("Master Channel is not supported in this case.") { }
public MasterChannelNotSupportedException(string message) : base(message) { }
public MasterChannelNotSupportedException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 0 additions & 8 deletions SteelSeriesAPI/Sonar/Exceptions/MicChannelSupportOnly.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class MicChannelSupportOnlyException : Exception
{
public MicChannelSupportOnlyException() : base("Only the Mic Channel is supported in this case.") { }
public MicChannelSupportOnlyException(string message) : base(message) { }
public MicChannelSupportOnlyException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 8 additions & 0 deletions SteelSeriesAPI/Sonar/Exceptions/MixNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class MixNotFoundException : Exception
{
public MixNotFoundException() : base("Mix could not be found.") { }
public MixNotFoundException(string message) : base(message) { }
public MixNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class NoStreamRedirectionSetException : Exception
{
public NoStreamRedirectionSetException() : base("No redirection was set. Check the playback devices of the streamer mode") { }
public NoStreamRedirectionSetException(string message) : base("No redirection was set. Check the playback devices of the streamer mode\n" + message) { }
public NoStreamRedirectionSetException(string message, Exception innerException) : base("No redirection was set. Check the playback devices of the streamer mode\n" + message, innerException) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class RoutedProcessNotFoundException : Exception
{
public RoutedProcessNotFoundException() : base("Could not find any routed process") { }
public RoutedProcessNotFoundException(string message) : base(message) { }
public RoutedProcessNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
8 changes: 0 additions & 8 deletions SteelSeriesAPI/Sonar/Exceptions/SonarListenerNotConnected.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SteelSeriesAPI.Sonar.Exceptions;

public class SonarListenerNotConnectedException : Exception
{
public SonarListenerNotConnectedException() : base("Listener need to be connected before listening") { }
public SonarListenerNotConnectedException(string message) : base(message) { }
public SonarListenerNotConnectedException(string message, Exception innerException) : base(message, innerException) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

namespace SteelSeriesAPI.Sonar.Http;

public class HttpFetcher
public class Fetcher
{
private readonly HttpClient _httpClient;
private readonly IAppRetriever _sonarRetriever;

public HttpFetcher()
public Fetcher()
{
_sonarRetriever = SonarRetriever.Instance;

Expand Down
76 changes: 0 additions & 76 deletions SteelSeriesAPI/Sonar/Http/SonarHttpCommand.cs

This file was deleted.

Loading