Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Oct 25, 2020
2 parents a6bb8d6 + 6cd2b71 commit 1ebed26
Show file tree
Hide file tree
Showing 33 changed files with 429 additions and 377 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
script: .travis/script_test.sh

- name: "Linux arm64 tests"
arch: arm64
arch: arm64-graviton2
group: edge
virt: lxd
addons:
apt:
packages:
Expand All @@ -54,7 +56,7 @@ jobs:
env:
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
script: .travis/script_osx.sh
after_success: .travis/prepare_osx.sh
after_success: .travis/prepare_tarball.sh

- name: "MOD devices arm"
env:
Expand Down Expand Up @@ -100,7 +102,9 @@ jobs:
after_success: .travis/prepare_tarball.sh

- name: "Linux arm64 library"
arch: arm64
arch: arm64-graviton2
group: edge
virt: lxd
env:
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
addons:
Expand All @@ -113,7 +117,9 @@ jobs:
after_success: .travis/prepare_tarball.sh

- name: "Linux arm64 static plugins"
arch: arm64
arch: arm64-graviton2
group: edge
virt: lxd
env:
- INSTALL_DIR="sfizz-plugins-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
- ENABLE_VST_PLUGIN=OFF
Expand Down
34 changes: 0 additions & 34 deletions .travis/before_install.sh

This file was deleted.

40 changes: 0 additions & 40 deletions .travis/prepare_osx.sh

This file was deleted.

5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else()
endif()
endif()

project (sfizz VERSION 0.5.0 LANGUAGES CXX C)
project (sfizz VERSION 0.5.1 LANGUAGES CXX C)
set (PROJECT_DESCRIPTION "A library to load SFZ description files and use them to render music.")

# External configuration CMake scripts
Expand Down Expand Up @@ -38,6 +38,9 @@ include (SfizzConfig)
# Don't use IPO in non Release builds
include (CheckIPO)

# Dylib bunder for macOS
include (BundleDylibs)

# Add Abseil
add_subdirectory (external/abseil-cpp EXCLUDE_FROM_ALL)

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install:
- cmd: vcpkg install libsndfile:%VCPKG_TRIPLET%

before_build:
- cmd: git submodule update --init
- cmd: git submodule update --init --recursive
- cmd: mkdir CMakeBuild
- cmd: cd CMakeBuild
- cmd: cmake .. -G"Visual Studio 16 2019" -A"%platform%" -DSFIZZ_JACK=OFF -DSFIZZ_BENCHMARKS=OFF -DSFIZZ_TESTS=OFF -DSFIZZ_LV2=ON -DSFIZZ_VST=ON -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
Expand Down
32 changes: 32 additions & 0 deletions cmake/BundleDylibs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dylib bundler for macOS
# Requires the external program "dylibbundler"

if(APPLE)
find_program(DYLIBBUNDLER_PROGRAM "dylibbundler")
if(NOT DYLIBBUNDLER_PROGRAM)
message(WARNING "The installation helper \"dylibbundler\" is not available.")
endif()
endif()

function(bundle_dylibs NAME PATH)
if(NOT APPLE OR NOT DYLIBBUNDLER_PROGRAM)
return()
endif()

set(_relative_libdir "../libs")

get_filename_component(_dir "${PATH}" DIRECTORY)
set(_dir "${_dir}/${_relative_libdir}")

set(_script "${CMAKE_CURRENT_BINARY_DIR}/_bundle-dylibs.${NAME}.cmake")

file(WRITE "${_script}"
"execute_process(COMMAND \"${DYLIBBUNDLER_PROGRAM}\"
\"-cd\" \"-of\" \"-b\"
\"-x\" \"\$ENV{DESTDIR}${PATH}\"
\"-d\" \"\$ENV{DESTDIR}${_dir}\"
\"-p\" \"@loader_path/${_relative_libdir}/\")
")

install(SCRIPT "${_script}" ${ARGN})
endfunction()
9 changes: 6 additions & 3 deletions cmake/LV2Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ else()
set(LV2_UI_TYPE "X11UI")
endif()

if (MSVC)
if (APPLE)
set (LV2PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2" CACHE STRING
"Install destination for LV2 bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/LV2]")
elseif (MSVC)
set (LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lv2" CACHE STRING
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lv2}]")
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lv2]")
else()
set (LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2}]")
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]")
endif()
11 changes: 8 additions & 3 deletions cmake/VSTConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ set (VSTPLUGIN_VENDOR "Paul Ferrand")
set (VSTPLUGIN_URL "http://sfztools.github.io/sfizz")
set (VSTPLUGIN_EMAIL "paul@ferrand.cc")

if (MSVC)
if (APPLE)
set (VSTPLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3" CACHE STRING
"Install destination for VST bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/VST3]")
set (AUPLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Components" CACHE STRING
"Install destination for AudioUnit bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/Components]")
elseif (MSVC)
set (VSTPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/vst3" CACHE STRING
"Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/vst3}]")
"Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/vst3]")
else()
set (VSTPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/vst3" CACHE STRING
"Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/vst3}]")
"Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/vst3]")
endif()

if (NOT VST3_SYSTEM_PROCESSOR)
Expand Down
8 changes: 6 additions & 2 deletions editor/cmake/Vstgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,22 @@ else()
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
target_compile_definitions(sfizz-vstgui PRIVATE "DEVELOPMENT")
target_compile_definitions(sfizz-vstgui PUBLIC "DEVELOPMENT")
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Release")
target_compile_definitions(sfizz-vstgui PRIVATE "RELEASE")
target_compile_definitions(sfizz-vstgui PUBLIC "RELEASE")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# higher C++ requirement on Windows
set_property(TARGET sfizz-vstgui PROPERTY CXX_STANDARD 14)
# Windows 10 RS2 DDI for custom fonts
target_compile_definitions(sfizz-vstgui PRIVATE "NTDDI_VERSION=0x0A000003")
# disable custom fonts while dwrite3 API is unavailable in MinGW
if(MINGW)
target_compile_definitions(sfizz-vstgui PRIVATE "VSTGUI_WIN32_CUSTOMFONT_SUPPORT=0")
endif()
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
Expand Down
20 changes: 10 additions & 10 deletions editor/src/editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void Editor::Impl::createFrameContents()
box->setBackgroundColor(theme->boxBackground);
box->setTitleFontColor(theme->titleBoxText);
box->setTitleBackgroundColor(theme->titleBoxBackground);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
box->setTitleFont(font);
return box;
};
Expand All @@ -436,7 +436,7 @@ void Editor::Impl::createFrameContents()
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(theme->text);
lbl->setHoriAlign(align);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFont(font);
return lbl;
};
Expand All @@ -463,7 +463,7 @@ void Editor::Impl::createFrameContents()
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(theme->text);
lbl->setHoriAlign(align);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFont(font);
return lbl;
};
Expand All @@ -476,15 +476,15 @@ void Editor::Impl::createFrameContents()
#if 0
auto createButton = [this](const CRect& bounds, int tag, const char* label, CHoriTxtAlign align, int fontsize) {
CTextButton* button = new CTextButton(bounds, this, tag, label);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
button->setFont(font);
button->setTextAlignment(align);
return button;
};
#endif
auto createClickableLabel = [this, &theme](const CRect& bounds, int tag, const char* label, CHoriTxtAlign align, int fontsize) {
STextButton* button = new STextButton(bounds, this, tag, label);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
button->setFont(font);
button->setTextAlignment(align);
button->setTextColor(theme->text);
Expand All @@ -499,7 +499,7 @@ void Editor::Impl::createFrameContents()
};
auto createValueButton = [this, &theme](const CRect& bounds, int tag, const char* label, CHoriTxtAlign align, int fontsize) {
STextButton* button = new STextButton(bounds, this, tag, label);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
button->setFont(font);
button->setTextAlignment(align);
button->setTextColor(theme->valueText);
Expand All @@ -515,7 +515,7 @@ void Editor::Impl::createFrameContents()
auto createValueMenu = [this, &theme](const CRect& bounds, int tag, const char*, CHoriTxtAlign align, int fontsize) {
SValueMenu* vm = new SValueMenu(bounds, this, tag);
vm->setHoriAlign(align);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
vm->setFont(font);
vm->setFontColor(theme->valueText);
vm->setBackColor(theme->valueBackground);
Expand All @@ -526,7 +526,7 @@ void Editor::Impl::createFrameContents()
};
auto createGlyphButton = [this, &theme](UTF8StringPtr glyph, const CRect& bounds, int tag, int fontsize) {
STextButton* btn = new STextButton(bounds, this, tag, glyph);
btn->setFont(new CFontDesc("Sfizz Fluent System R20", fontsize));
btn->setFont(makeOwned<CFontDesc>("Sfizz Fluent System R20", fontsize));
btn->setTextColor(theme->icon);
btn->setHoverColor(theme->iconHighlight);
btn->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
Expand Down Expand Up @@ -559,14 +559,14 @@ void Editor::Impl::createFrameContents()
};
auto createPiano = [](const CRect& bounds, int, const char*, CHoriTxtAlign, int fontsize) {
SPiano* piano = new SPiano(bounds);
auto font = owned(new CFontDesc("Roboto", fontsize));
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
piano->setFont(font);
return piano;
};
auto createChevronDropDown = [this, &theme](const CRect& bounds, int, const char*, CHoriTxtAlign, int fontsize) {
SActionMenu* menu = new SActionMenu(bounds, this);
menu->setTitle(u8"\ue0d7");
menu->setFont(new CFontDesc("Sfizz Fluent System R20", fontsize));
menu->setFont(makeOwned<CFontDesc>("Sfizz Fluent System R20", fontsize));
menu->setFontColor(theme->icon);
menu->setHoverColor(theme->iconHighlight);
menu->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
Expand Down
2 changes: 1 addition & 1 deletion editor/src/editor/GUIPiano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void SPiano::draw(CDrawContext* dc)
CRect textRect(
rect.left, dim.labelBounds.top,
rect.right, dim.labelBounds.bottom);
dc->setFont(font_);
dc->setFont(font);
dc->setFontColor(labelStroke_);
std::string text = std::to_string(static_cast<int>(o) - 1);
dc->drawString(text.c_str(), textRect, kCenterText);
Expand Down
8 changes: 7 additions & 1 deletion lv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ endif()

# Installation
if (NOT MSVC)
install (DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR}
install(DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR}
COMPONENT "lv2")
bundle_dylibs(lv2
"${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2/Contents/Binary/sfizz.so"
COMPONENT "lv2")
bundle_dylibs(lv2-ui
"${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2/Contents/Binary/sfizz_ui.so"
COMPONENT "lv2")
endif()
30 changes: 29 additions & 1 deletion lv2/sfizz_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ struct sfizz_ui_t : EditorController, VSTGUIEditorInterface {
void uiTouch(EditId id, bool t);
};

#if defined(_WIN32)
static bool fixBundlePath(std::string& path)
{
// go up some directories until reaching the *.lv2 directory
bool valid = false;
while (!valid && !path.empty()) {
if (path.back() == '\\' || path.back() == '/')
path.pop_back();
else if (path.size() > 4 && !memcmp(".lv2", path.data() + path.size() - 4, 4))
valid = true;
else {
path.pop_back();
while (!path.empty() && path.back() != '\\' && path.back() != '/')
path.pop_back();
}
}
return valid;
}
#endif

static LV2UI_Handle
instantiate(const LV2UI_Descriptor *descriptor,
const char *plugin_uri,
Expand Down Expand Up @@ -178,8 +198,16 @@ instantiate(const LV2UI_Descriptor *descriptor,
// name, and appending "Contents/Resources" (not overridable)
// * on Windows, the folder is set programmatically
// * on macOS, resource files are looked up using CFBundle APIs

#if defined(_WIN32)
IWin32PlatformFrame::setResourceBasePath((std::string(bundle_path) + "\\Contents\\Resources\\").c_str());
// some hosts give us the DLL path instead of the bundle path,
// so we have to work around that.
std::string realBundlePath { bundle_path };
if (!fixBundlePath(realBundlePath))
return nullptr;

std::string resourcePath = realBundlePath + "\\Contents\\Resources\\";
IWin32PlatformFrame::setResourceBasePath(resourcePath.c_str());
#endif

// makes labels refresh correctly
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1ebed26

Please sign in to comment.