Skip to content

Commit

Permalink
Add NuGet packages for .NET and Mono.
Browse files Browse the repository at this point in the history
  • Loading branch information
residuum committed Aug 18, 2016
1 parent e80bcae commit 64bd7ca
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ libpd.xcodeproj/xcuserdata
*.app

# csharp
samples/csharp/**/obj/*
samples/csharp/**/bin/*
csharp/obj/*
csharp/bin/*
libs/libpd.*
libs/libpdnative.*
libs/libpdcsharp.*
.vs/*
*.suo
*.csproj.user
packages/*
*.nupkg

# java
java-build/*
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,20 @@ Use the following in your CocoaPods podfile:
C#
--

### Installation from NuGet
LibPD is available as a [NuGet package](https://www.nuget.org/packages/LibPd). If your platform's native dll is not included, you have to build it yourself with `make csharplib` and copy the resulting file to the output directory. Batch scripts for compilations on Windows with MinGW64 are included.

### Building yourself
The C# library expects a file libpdcsharp.dll in its folder. Before using the project, you need to compile it.
Executing `mingw_build.bat` will compile the file and copy the dll into the correct destination.

Include `csharp/LibPdBinding.csproj` in your solution and reference the project in your application.

#### Windows
Edit `mingw32_build_csharp.bat` or `mingw63_build_csharp.bat` and execute it to create the native dll. Usually you want the 32 bit version, as it will work on 64 bit Windows as well, but Unity 5 needs the 64 bit version.

For the 64 bit version, you also must change `pthreadGC2-64.dll` to `pthreadGC2.dll` in the `libs` subfolder.

#### Linux
If you want to use the library on Linux with Mono, you need the following changes to the LibPdBinding project:

- Mono does not have client profiles. change settings of the project to use a different profile.
Expand Down
12 changes: 10 additions & 2 deletions csharp/LibPDBinding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
Expand All @@ -57,7 +63,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="app.config" />
<None Include="LibPDBinding.nuspec">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>
29 changes: 29 additions & 0 deletions csharp/LibPDBinding.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Peter Brinkmann &amp; the libpd team</authors>
<owners>Peter Brinkmann &amp; the libpd team</owners>
<licenseUrl>https://github.com/libpd/libpd/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/libpd/libpd</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Pure Data as an embeddable audio synthesis library.</description>
<releaseNotes>First release.</releaseNotes>
<copyright>Copyright 2012 - 2016</copyright>
<tags>C# .NET Mono audio sound</tags>
</metadata>
<files>
<file src="readme.txt" target="" />
<!-- Windows -->
<file src="..\libs\libpdcsharp-32.dll" target="native\UnmanagedLibraries\Windows\x86\libpdcsharp.dll" />
<file src="..\libs\pthreadGC2-64.dll" target="native\UnmanagedLibraries\Windows\x64\libpdcsharp.dll" />
<file src="..\libs\pthreadGC2-32.dll" target="native\UnmanagedLibraries\Windows\x86\pthreadGC2.dll" />
<file src="..\libs\pthreadGC2-64.dll" target="native\UnmanagedLibraries\Windows\x64\pthreadGC2.dll" />
<!-- Linux -->
<file src="..\libs\libpdcsharp.x86.so" target="native\UnmanagedLibraries\Linux\x86\libpdcsharp.so" />
<file src="..\libs\libpdcsharp.amd64.so" target="native\UnmanagedLibraries\Linux\amd64\libpdcsharp.so" />
<file src="..\libs\libpdcsharp.armv6l.so" target="native\UnmanagedLibraries\Linux\armv6l\libpdcsharp.so" />
</files>
</package>
6 changes: 4 additions & 2 deletions csharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LibPDBinding")]
[assembly: AssemblyCopyright("Copyright 2012, BSD License")]
[assembly: AssemblyCopyright("Copyright 2012-2016, BSD License")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -28,4 +28,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.1.*")]
[assembly: AssemblyInformationalVersion("0.9.1")]

26 changes: 26 additions & 0 deletions csharp/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
LibPD for .NET and Mono
-----------------------

Thank you for using the NuGet package for LibPD for .NET and Mono.

The managed DLL needs a native shared library, that you must include
in your project. Depending on your platform, choose the correct one
from the folder packages/LibPDBinding/native/UnmanagedLibraries in
your solution or project root.

Add the correct shared library to your project, for Windows add
pthreadGC2.dll as well.

Change the properties for the files after including:
- Set "Build Action" to "None", if not set to this
- Set "Copy to Output Directory" to "Copy if newer"

Currently included binaries for:
- Windows x86 and amd64
- Linux x86, amd64, armhf

If your platform is not included in the list, you must build it
yourself from source: https://github.com/libpd/libpd

Bugtracker: https://github.com/libpd/libpd/issues
Questions: http://stackoverflow.com/questions/tagged/libpd
11 changes: 6 additions & 5 deletions samples/csharp/naudio/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
* Copyright(c) 2016 Thomas Mayer<[email protected]>
*/
using System;
using System.Linq;
using JackSharp;
using NAudio.CoreAudioApi;
using NAudio.Jack;
using NAudio.Wave;

namespace LibPdBindingNaudio
{
class Program
class Program
{
static bool useJack
{
get { return true; }
}
static bool useJack;

static void Main(string[] args)
{
if (args.Any() && args.First() == "jack") {
useJack = true;
}
if (useJack) {
PlayWithJack();
} else {
Expand Down
6 changes: 6 additions & 0 deletions samples/csharp/pdtest/LibPDBindingTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<PlatformTarget>x86</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion samples/csharp/pdtest/LibPDTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public virtual void testReceive ()
}

[Test]
public unsafe virtual void testArrayAccess ()
public virtual unsafe void testArrayAccess ()
{
int n = 128;
Assert.AreEqual (n, LibPD.ArraySize ("array1"));
Expand Down

0 comments on commit 64bd7ca

Please sign in to comment.