SoundpadConnector provides an .NET API to programmatically interact with a local Soundpad instance.
This library is build on .NET Standard 2.0. Following plattforms are supported:
Get the NuGet package SoundpadConnector or install via NuGet console:
PM> Install-Package SoundpadConnector
using System;
using SoundpadConnector;
namespace Examples {
class Program {
public static Soundpad Soundpad;
static void Main(string[] args)
{
Soundpad = new Soundpad();
Soundpad.StatusChanged += SoundpadOnStatusChanged;
// Note that the API is asynchronous. Make sure that Soundpad is connected before executing commands.
Soundpad.ConnectAsync();
Console.ReadLine();
}
private static void SoundpadOnStatusChanged(object sender, EventArgs e)
{
Console.WriteLine(Soundpad.ConnectionStatus);
if (Soundpad.ConnectionStatus == ConnectionStatus.Connected)
{
Soundpad.PlaySound(1);
}
}
}
}
Read the Docs online. This is still work-in-progress!
choco install docfx -y
docfx docfx/docfx.json
in project root/docs
Browse the Examples.
Soundpad calls are not transactional. You may get a response before the action happens in Soundpad. For example:
var countResult = await soundpad.GetSoundFileCount();
Console.WriteLine(countResult.Value); // 9
await soundpad.AddSound(newSoundPath);
var newCountResult = await soundpad.GetSoundFileCount();
Console.WriteLine(newCountResult.Value); // 9 again, but we're expecting 10, right?
You can wait a certain amount of time between the calls, but that won't be safe either and makes your app slow. Another way is to loop until the value changes:
var countResult = await soundpad.GetSoundFileCount();
Console.WriteLine(countResult.Value); // 9
await soundpad.AddSound(newSoundPath);
while(true) {
var newCountResult = await soundpad.GetSoundFileCount();
if(newCountResult.Value == countResult.Value) {
Console.WriteLine(newCountResult.Value); // 10
break;
}
}
You may contribute in several ways like creating new features, fixing bugs, improving documentation and examples or translating any document here to your language. Read our Code of Conduct.
MIT - Nikodem Jaworski - 2018