string SOUNDPAD_PATH = @"C:\Program Files (x86)\Steam\steamapps\common\Soundpad\Soundpad.exe";
// Executes a command on Soundpad using the provided command string.
void ExecuteCommand(string command)
{
var startInfo = new ProcessStartInfo
{
FileName = SOUNDPAD_PATH,
Arguments = $"-rc {command}",
UseShellExecute = false,
CreateNoWindow = true
};
using (var process = new Process { StartInfo = startInfo })
{
process.Start();
process.WaitForExit();
}
}
// Plays a sound at the given index on the specified output devices.
void PlaySound(int index, bool speakers = true, bool mic = false)
{
var command = $"DoPlaySound({index},{speakers.ToString().ToLower()},{mic.ToString().ToLower()})";
ExecuteCommand(command);
}
// Plays a sound from a specific category on the specified output devices.
void PlaySoundFromCategory(int categoryIndex, int soundIndex, bool speakers = true, bool mic = false)
{
var command = $"DoPlaySoundFromCategory({categoryIndex},{soundIndex},{speakers.ToString().ToLower()},{mic.ToString().ToLower()})";
ExecuteCommand(command);
}
.Trim(' ','\t','\n','\r')