Skip to content

Commit

Permalink
Linux: Some work to make it compile on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmatheussen committed Sep 26, 2018
1 parent 7a9e8d0 commit d144305
Show file tree
Hide file tree
Showing 26 changed files with 214 additions and 46 deletions.
73 changes: 72 additions & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,36 @@ if (os.istarget("macosx")) then

platforms { "x64" }

elseif (os.istarget("linux")) then

flags { "StaticRuntime" }
vectorextensions "SSE2"

defines
{
"_MM_ALIGN16=__attribute__((aligned(16)))",
"__forceinline=inline",
"forceinline=inline",
"_aligned_malloc(x,a)=malloc(x)",
"_aligned_free(x)=free(x)",
"stricmp=strcasecmp",
"SSE_VERSION=3",
"__cdecl="
}

links
{
}

defines { "WINDOWS=0" }

buildoptions { "-std=c++17", "-I/home/kjetil/SDKs/VST_SDK/VST2_SDK" }
links { }
buildoptions { }
linkoptions { }

platforms { "x64" }

elseif (os.istarget("windows")) then

toolset "v141"
Expand Down Expand Up @@ -167,6 +197,47 @@ function plugincommon()
"QuartzCore.framework",
}

elseif (os.istarget("linux")) then

-- pchheader "src/common/precompiled.h" --
-- pchsource "src/common/precompiled.cpp" --

buildoptions {
"-Wno-unused-variable",
"`pkg-config gtkmm-3.0 --cflags`",
"-std=c++14"
}

files
{
"src/linux/*.mm",
"src/linux/**.cpp",
"src/linux/**.h",
-- "libs/vst/*.mm", --
VSTGUI .. "vstgui_linux.cpp",
-- VSTGUI .. "vstgui_uidescription_linux.cpp", --
}

excludes {
VSTGUI .. "winfileselector.cpp",
VSTGUI .. "vstgui_ios.mm",
VSTGUI .. "vstgui_uidescription_ios.mm",
}

includedirs
{

}

links {
"pthread",
"stdc++fs"

}

linkoptions {
"`pkg-config gtkmm-3.0 --libs`",
}
elseif (os.istarget("windows")) then

pchheader "precompiled.h"
Expand Down Expand Up @@ -400,4 +471,4 @@ if (os.istarget("macosx")) then

postbuildcommands { "./package-au.sh" }

end
end
6 changes: 3 additions & 3 deletions src/common/AbstractSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define SSE_STATE_FLAG 0x8040

#if !MAC
#if !MAC && !__linux__
#include <CpuArchitecture.h>

int SSE_VERSION;
Expand All @@ -15,7 +15,7 @@ int SSE_VERSION;

void initDllGlobals()
{
#if !MAC // intel macs always support SSE2
#if !MAC && !__linux__ // intel macs always support SSE2
unsigned int arch = determine_support();
// detect
if (arch & ca_SSE3)
Expand All @@ -39,4 +39,4 @@ void initDllGlobals()
"Surge: System requirements not met", MB_OK | MB_ICONERROR);
}
#endif
}
}
4 changes: 2 additions & 2 deletions src/common/MemoryFile.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <vt_dsp/endian.h>
#include <vt_dsp/vt_dsp_endian.h>

struct riffheader
{
Expand Down Expand Up @@ -306,7 +306,7 @@ class MemoryFile

void invalid()
{
#if !MAC
#if !MAC && !__linux__
char txt[1024];
sprintf(txt, "Invalid RIFF-structure.\n\nOffset: 0x%X", loc);
MessageBox(::GetActiveWindow(), txt, "File I/O Error", MB_OK | MB_ICONERROR);
Expand Down
4 changes: 2 additions & 2 deletions src/common/Sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//-------------------------------------------------------------------------------------------------------
#pragma once

#ifdef MAC
#if MAC || __linux__
#else
#include <windows.h>
#include <mmreg.h>
Expand Down Expand Up @@ -89,4 +89,4 @@ class Sample
unsigned int refcount;
};

#endif
#endif
2 changes: 1 addition & 1 deletion src/common/SurgePatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "effect/Effect.h"
#include <list>
#include "MemoryFile.h"
#include <vt_dsp/endian.h>
#include <vt_dsp/vt_dsp_endian.h>

const int hmargin = 6;
// const int gui_topbar = 44;
Expand Down
9 changes: 7 additions & 2 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
#include "SurgeStorage.h"
#include "DspUtilities.h"
#include <set>
#include <vt_dsp/endian.h>
#include <vt_dsp/vt_dsp_endian.h>
#if MAC
//#include <MoreFilesX.h>
//#include <MacErrorHandling.h>
#include <CoreFoundation/CFBundle.h>
#include <CoreServices/CoreServices.h>
#elif __linux__
#else
#include <windows.h>
#include <Shellapi.h>
Expand Down Expand Up @@ -128,6 +129,10 @@ SurgeStorage::SurgeStorage()

userDataPath = "~/Documents/Surge";

#elif __linux__

printf("Implement me, probably\n");

#else

PWSTR localAppData;
Expand All @@ -151,7 +156,7 @@ SurgeStorage::SurgeStorage()

if (!snapshotloader.LoadFile(snapshotmenupath.c_str())) // load snapshots (& config-stuff)
{
#if !MAC
#if !MAC && !__linux__
MessageBox(::GetActiveWindow(), "Surge is not properly installed. Please reinstall.",
"Configuration not found", MB_OK | MB_ICONERROR);
#endif
Expand Down
7 changes: 6 additions & 1 deletion src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ using namespace std;
#endif
#include <tinyxml.h>

#if __linux
#include <experimental/filesystem>
#else
#include <filesystem>
#endif

#include <fstream>
#include <iterator>

Expand Down Expand Up @@ -521,4 +526,4 @@ float db_to_linear(float);
float lookup_waveshape(int, float);
float lookup_waveshape_warp(int, float);
float envelope_rate_lpf(float);
float envelope_rate_linear(float);
float envelope_rate_linear(float);
6 changes: 3 additions & 3 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "SurgeSynthesizer.h"
#include "DspUtilities.h"
#include <time.h>
#if MAC
#if MAC || __linux__
#include <pthread.h>
#else
#include <windows.h>
Expand Down Expand Up @@ -2028,7 +2028,7 @@ float SurgeSynthesizer::valueToNormalized(long index, float value)
return 0.f;
}

#if MAC
#if MAC || __linux__
void* loadPatchInBackgroundThread(void* sy)
{
#else
Expand Down Expand Up @@ -2219,7 +2219,7 @@ void SurgeSynthesizer::process()
// spawn patch-loading thread
halt_engine = true;

#if MAC
#if MAC || __linux__
pthread_t thread;
pthread_attr_t attributes;
int ret;
Expand Down
12 changes: 9 additions & 3 deletions src/common/SurgeSynthesizerIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#include "SurgeSynthesizer.h"
#include "DspUtilities.h"
#include <time.h>
#include <vt_dsp/endian.h>
#include <vt_dsp/vt_dsp_endian.h>
#ifdef __linux__
#include <experimental/filesystem>
#else
#include <filesystem>
#endif
#include <fstream>
#include <iterator>

Expand Down Expand Up @@ -153,7 +157,7 @@ void SurgeSynthesizer::load_raw(const void* data, int size, bool preset)
refresh_editor = true;
}

#if MAC
#if MAC || __linux__
#include <sys/types.h>
#include <sys/stat.h>
#endif
Expand All @@ -164,7 +168,7 @@ string SurgeSynthesizer::getUserPatchDirectory()
}
string SurgeSynthesizer::getLegacyUserPatchDirectory()
{
#if MAC
#if MAC || __linux__
return storage.datapath + "patches_user/";
#else
return storage.datapath + "patches_user\\";
Expand All @@ -181,6 +185,8 @@ bool askIfShouldOverwrite()
CFSTR("Yes"), CFSTR("No"), 0, &responseFlags);
if ((responseFlags & 0x3) != kCFUserNotificationDefaultResponse)
return false;
#elif __linux__
printf("Implement me\n");
#else
if (MessageBox(::GetActiveWindow(), "The file already exist, do you wish to overwrite it?",
"Overwrite?", MB_YESNO | MB_ICONQUESTION) != IDYES)
Expand Down
5 changes: 4 additions & 1 deletion src/common/dsp/DspUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Copyright 2005 Claes Johanson & Vember Audio
//-------------------------------------------------------------------------------------------------------
#pragma once

#include <string.h>

#include "globals.h"
#include <vt_dsp/basic_dsp.h>
#include <vt_dsp/halfratefilter.h>
Expand Down Expand Up @@ -393,4 +396,4 @@ inline bool is_yes(const char* str)
return 1;
#endif
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/QuadFilterChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,4 @@ FBQFPtr GetFBQPointer(int config, bool A, bool WS, bool B)
return GetFBQPointer2<fb_wide>(A, WS, B);
}
return 0;
}
}
2 changes: 1 addition & 1 deletion src/common/dsp/QuadFilterChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ struct fbq_global

typedef void (*FBQFPtr)(QuadFilterChainState&, fbq_global&, float*, float*);

FBQFPtr GetFBQPointer(int config, bool A, bool WS, bool B);
FBQFPtr GetFBQPointer(int config, bool A, bool WS, bool B);
4 changes: 3 additions & 1 deletion src/common/dsp/QuadFilterUnit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "FilterCoefficientMaker.h"
#pragma once
#include "globals.h"


const int n_filter_registers = 5;

Expand All @@ -16,4 +18,4 @@ typedef __m128 (*FilterUnitQFPtr)(QuadFilterUnitState* __restrict, __m128 in);
typedef __m128 (*WaveshaperQFPtr)(__m128 in, __m128 drive);

FilterUnitQFPtr GetQFPtrFilterUnit(int type, int subtype);
WaveshaperQFPtr GetQFPtrWaveshaper(int type);
WaveshaperQFPtr GetQFPtrWaveshaper(int type);
5 changes: 4 additions & 1 deletion src/common/dsp/VectorizedSvfFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <math.h>

#include "VectorizedSvfFilter.h"


//================================================================================================

//------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -67,4 +70,4 @@ float VectorizedSvfFilter::CalcQ(float Quality)
return 1.f / Quality;
}

//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions src/common/dsp/Wavetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <assert.h>
#include "DspUtilities.h"
#include <vt_dsp/basic_dsp.h>
#include <vt_dsp/endian.h>
#include <vt_dsp/vt_dsp_endian.h>
#include "SurgeStorage.h"

#if WINDOWS
Expand Down Expand Up @@ -36,7 +36,7 @@ const int HRFilterI16[64] = {

int min_F32_tables = 3;

#if MAC
#if MAC || __linux__
bool _BitScanReverse(unsigned int* result, unsigned int bits)
{
*result = __builtin_ctz(bits);
Expand Down Expand Up @@ -305,4 +305,4 @@ void Wavetable::MipMapWT()
// knäppen kommer antagligen från att det inte är någon padding i början så att det blir ur fas
// vid mipmapbyte makes sense eftersom den skilde en hel sample vid bytet, vilket inte kan
// förklaras av halfratefiltret
}
}
Loading

0 comments on commit d144305

Please sign in to comment.