Git Product home page Git Product logo

soundpad-connector's Introduction

Logo SoundpadConnector .NET

SoundpadConnector provides an .NET API to programmatically interact with a local Soundpad instance.

Table of contents

Requirements

This library is build on .NET Standard 2.0. Following plattforms are supported:

  • .NET Core 2.0 or higher
  • .NET Framework 4.6.1 or higher

Installation

Get the NuGet package SoundpadConnector or install via NuGet console:

PM> Install-Package SoundpadConnector

QuickStart

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);              
            }
        }
    }
}

Documentation

Api docs

Read the Docs online. This is still work-in-progress!

Build the docs

  1. Install Chocolatey
  2. Install Docfx via Chocolatey choco install docfx -y
  3. Run docfx docfx/docfx.json in project root
  4. Browse the output in /docs

Examples

Browse the Examples.

Limitations

  • SoundpadConnector does not work with Soundpad's Demo version 3 and below.
  • UWP is not supported/tested. The sandbox refuses pipe connections. Users reported that it works from Windows 10 version 2004 and above.

Troubleshooting

Unexpected result when performing multiple calls?

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;
    }
}

Contributing

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.

License

MIT - Nikodem Jaworski - 2018

Special thanks

  • Leppsoft - The Company behind Soundpad

soundpad-connector's People

Contributors

medokin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

soundpad-connector's Issues

Support GetSoundlist() for a specific category

Soundpad supports adding sounds to categories. It would be cool if I could get all the songs in a specific category OR when I get ALL the sounds, know which Category they belong to.

LoadSoundlist does not work if path has a space

Describe the bug
When calling LoadSoundlist it will fail if there is a space in the path.

To Reproduce
Create a new folder with a space (you can just leave the default naming of "New Folder") and put an spl file there.
Then call LoadSoundlist

Expected behavior
Soundpad loads the new spl file

GetSoundlist fails if it has too many entries

The method Send in Soundpad.cs only reads _pipe.OutBufferSize. If a client has many sounds and GetSoundlist is called, then the response surpasses the fixed buffer size of 262144 bytes resulting in an incomplete xml response and parsing fails.

The method should read from the pipe until the read bytes are below that buffer size.

So instead of this code part:

var responseBuffer = new byte[_pipe.OutBufferSize];
await _pipe.ReadAsync(responseBuffer, 0, responseBuffer.Length);

it should be be something like that:

var tmpBuffer = new byte[_pipe.InBufferSize]; // use InBufferSize as we are reading, although they are of same size
var responseBuffer = new byte[0];

int bytesRead = 0;
do
{
    bytesRead = _pipe.Read(tmpBuffer, 0, tmpBuffer.Length);
    int previousLength = responseBuffer.Length;
    Array.Resize(ref responseBuffer, previousLength + bytesRead);
    Array.Copy(tmpBuffer, 0, responseBuffer, previousLength, bytesRead);
} while (bytesRead == _pipe.InBufferSize);

There's probably a more efficient way than resizing the response array, but I'm not too familiar with C#.

Support loading a soundlist

Currently, there is a SaveSoundlist() function that allows to save a Soundlist.

Could we also add a LoadSoundList(string fileName) which will load a *.spl file?

UWP is supported

Just wanted to request for docs update.

UWP is now supported for some time, i did contact the Soundpad creator and the changes was made months ago.

The requirements for ipc to work with UWP apps is to have best at least windows 10 2004, then it is possible to connect from the connector without any workarounds, it could also work before 2004, one or two releases, but it needed to use only specific winapi functions and with 2004 it works out of the box from any code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.