Skip to content

Commit

Permalink
Merge pull request #4 from keijiro/dev-linux
Browse files Browse the repository at this point in the history
Add linux support
  • Loading branch information
keijiro authored Aug 11, 2017
2 parents eebc365 + 3c3fade commit ad3367e
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 74 deletions.
1 change: 1 addition & 0 deletions Assets/Lasp/Internal/LaspStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class LaspStream : IDisposable
{
public LaspStream()
{
PluginEntry.SetupLogger();
_driver = PluginEntry.CreateDriver();
}

Expand Down
9 changes: 9 additions & 0 deletions Assets/Lasp/Internal/Linux.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Lasp/Internal/Linux/x64.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Lasp/Internal/Linux/x64/libLasp.so
Binary file not shown.
141 changes: 141 additions & 0 deletions Assets/Lasp/Internal/Linux/x64/libLasp.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/Lasp/Internal/PluginEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public enum FilterType { Bypass, LowPass, BandPass, HighPass }

public static class PluginEntry
{
#region Plugin interface

[DllImport("Lasp", EntryPoint="LaspCreateDriver")]
public static extern IntPtr CreateDriver();

Expand All @@ -33,5 +35,33 @@ public static class PluginEntry

[DllImport("Lasp", EntryPoint="LaspRetrieveWaveform")]
public static extern int RetrieveWaveform(IntPtr driver, FilterType filter, float[] dest, int length);

#endregion

#region Debug helpers

public static void SetupLogger()
{
var del = (PrintDelegate)Log;
var ptr = Marshal.GetFunctionPointerForDelegate(del);
ReplaceLogger(ptr);
}

[DllImport("Lasp", EntryPoint="LaspReplaceLogger")]
public static extern void ReplaceLogger(IntPtr logger);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void PrintDelegate(string message);

static void Log(string message)
{
#if UNITY_EDITOR
UnityEngine.Debug.Log(message);
#else
System.Console.WriteLine(message);
#endif
}

#endregion
}
}
Binary file modified Assets/Lasp/Internal/Windows/x64/Lasp.dll
Binary file not shown.
Binary file modified Assets/Lasp/Internal/macOS/Lasp.bundle/Contents/MacOS/Lasp
Binary file not shown.
93 changes: 54 additions & 39 deletions Plugin/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF()

IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(ENABLE_DEBUG ON)
ENDIF()

SET(LASP_INCLUDES
../PortAudio/common/pa_allocation.h
../PortAudio/common/pa_converters.h
../PortAudio/common/pa_cpuload.h
../PortAudio/common/pa_debugprint.h
../PortAudio/common/pa_dither.h
../PortAudio/common/pa_endianness.h
../PortAudio/common/pa_hostapi.h
../PortAudio/common/pa_memorybarrier.h
../PortAudio/common/pa_process.h
../PortAudio/common/pa_ringbuffer.h
../PortAudio/common/pa_stream.h
../PortAudio/common/pa_trace.h
../PortAudio/common/pa_types.h
../PortAudio/common/pa_util.h
../PortAudio/include/pa_linux_alsa.h
../PortAudio/include/portaudio.h
../PortAudio/os/unix/pa_unix_util.h
../PortAudio/common/pa_allocation.h
../PortAudio/common/pa_converters.h
../PortAudio/common/pa_cpuload.h
../PortAudio/common/pa_debugprint.h
../PortAudio/common/pa_dither.h
../PortAudio/common/pa_endianness.h
../PortAudio/common/pa_hostapi.h
../PortAudio/common/pa_memorybarrier.h
../PortAudio/common/pa_process.h
../PortAudio/common/pa_ringbuffer.h
../PortAudio/common/pa_stream.h
../PortAudio/common/pa_trace.h
../PortAudio/common/pa_types.h
../PortAudio/common/pa_util.h
../PortAudio/include/pa_linux_alsa.h
../PortAudio/include/portaudio.h
../PortAudio/os/unix/pa_unix_util.h
../Source/BiquadFilter.h
../Source/Debug.h
../Source/Driver.h
../Source/IUnityInterface.h
../Source/RingBuffer.h
)

SET(LASP_SOURCES
../PortAudio/common/pa_allocation.c
../PortAudio/common/pa_converters.c
../PortAudio/common/pa_cpuload.c
../PortAudio/common/pa_debugprint.c
../PortAudio/common/pa_dither.c
../PortAudio/common/pa_front.c
../PortAudio/common/pa_process.c
../PortAudio/common/pa_ringbuffer.c
../PortAudio/common/pa_stream.c
../PortAudio/common/pa_trace.c
../PortAudio/hostapi/alsa/pa_linux_alsa.c
../PortAudio/os/unix/pa_unix_hostapis.c
../PortAudio/os/unix/pa_unix_util.c
../PortAudio/common/pa_allocation.c
../PortAudio/common/pa_converters.c
../PortAudio/common/pa_cpuload.c
../PortAudio/common/pa_debugprint.c
../PortAudio/common/pa_dither.c
../PortAudio/common/pa_front.c
../PortAudio/common/pa_process.c
../PortAudio/common/pa_ringbuffer.c
../PortAudio/common/pa_stream.c
../PortAudio/common/pa_trace.c
../PortAudio/hostapi/alsa/pa_linux_alsa.c
../PortAudio/os/unix/pa_unix_hostapis.c
../PortAudio/os/unix/pa_unix_util.c
../Source/Lasp.cpp
)

SET(LASP_INCLUDE_PATHS ../PortAudio/include ../PortAudio/common ../PortAudio/os/unix ${ALSA_INCLUDE_DIRS})

SET(CMAKE_CXX_STANDARD 11)
SET(LASP_INCLUDE_PATHS ../PortAudio/include ../PortAudio/common ../PortAudio/os/unix)
SET(LASP_COMPILE_DEFINITIONS PA_USE_ALSA)
SET(LASP_LIBRARY_DEPENDENCIES ${ALSA_LIBRARIES} m pthread)
SET(LASP_PKGCONFIG_LDFLAGS "-lasound -lm -lpthread")
SET(LASP_LIBRARY_DEPENDENCIES asound m pthread)

SET(LASP_COMPILE_DEFINITIONS ${LASP_COMPILE_DEFINITIONS} PA_ENABLE_DEBUG_OUTPUT)
IF(ENABLE_DEBUG)
SET(LASP_COMPILE_DEFINITIONS ${LASP_COMPILE_DEFINITIONS} _DEBUG PA_ENABLE_DEBUG_OUTPUT)
ENDIF()

ADD_LIBRARY(lasp SHARED ${LASP_INCLUDES} ${LASP_SOURCES})
SET_PROPERTY(TARGET lasp APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${LASP_COMPILE_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(lasp PRIVATE ${LASP_INCLUDE_PATHS})
TARGET_LINK_LIBRARIES(lasp ${LASPLIBRARY_DEPENDENCIES})
ADD_LIBRARY(Lasp SHARED ${LASP_INCLUDES} ${LASP_SOURCES})
SET_PROPERTY(TARGET Lasp APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${LASP_COMPILE_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(Lasp PRIVATE ${LASP_INCLUDE_PATHS})
TARGET_LINK_LIBRARIES(Lasp ${LASP_LIBRARY_DEPENDENCIES})
8 changes: 4 additions & 4 deletions Plugin/Source/BiquadFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Lasp

void setLowpass(float Fc, float Q)
{
auto K = std::tanf(PI_ * Fc);
auto K = tanf(PI_ * Fc);
auto norm = 1 / (1 + K / Q + K * K);
a0_ = K * K * norm;
a1_ = 2 * a0_;
Expand All @@ -27,7 +27,7 @@ namespace Lasp

void setBandpass(float Fc, float Q)
{
auto K = std::tanf(PI_ * Fc);
auto K = tanf(PI_ * Fc);
auto norm = 1 / (1 + K / Q + K * K);
a0_ = K / Q * norm;
a1_ = 0;
Expand All @@ -38,7 +38,7 @@ namespace Lasp

void setHighpass(float Fc, float Q)
{
auto K = std::tanf(PI_ * Fc);
auto K = tanf(PI_ * Fc);
auto norm = 1 / (1 + K / Q + K * K);
a0_ = norm;
a1_ = -2 * a0_;
Expand All @@ -62,4 +62,4 @@ namespace Lasp
float a0_, a1_, a2_, b1_, b2_;
float z1_, z2_;
};
}
}
Loading

0 comments on commit ad3367e

Please sign in to comment.