Signed-off-by: falkTX <falktx@falktx.com>tags/22.07
| @@ -64,7 +64,6 @@ DGL_EXTRA_ARGS = \ | |||
| NVG_DISABLE_SKIPPING_WHITESPACE=true \ | |||
| NVG_FONT_TEXTURE_FLAGS=NVG_IMAGE_NEAREST \ | |||
| USE_NANOVG_FBO=true \ | |||
| WASM_EXCEPTIONS=true \ | |||
| WINDOWS_ICON_ID=401 | |||
| # -------------------------------------------------------------- | |||
| @@ -1 +1 @@ | |||
| Subproject commit b8fa8f2faa42f69f6093a03fafb86b374ed46145 | |||
| Subproject commit 7a9b7ba35e261f519b4ab38b7f506e2745998e90 | |||
| @@ -1 +1 @@ | |||
| Subproject commit b9e654c3d331933dbeae0413246be8dc2bd64a58 | |||
| Subproject commit 02216aba747685fe3d8c1e7b95d7fc008249fee2 | |||
| @@ -30,16 +30,19 @@ | |||
| #include_next "common.hpp" | |||
| // Workaround for wrong file permissions from zstd extraction | |||
| // Workaround for wrong file permissions from zstd extraction and system usage | |||
| #ifdef __EMSCRIPTEN__ | |||
| #define fopen fopen_wasm | |||
| #define system system_wasm | |||
| extern "C" { | |||
| FILE* fopen_wasm(const char* filename, const char* mode); | |||
| inline int system_wasm(const char*) { return 0; } | |||
| } | |||
| namespace std { | |||
| using ::fopen_wasm; | |||
| using ::system_wasm; | |||
| } | |||
| #endif | |||
| @@ -17,16 +17,13 @@ | |||
| #pragma once | |||
| #ifdef __HAIKU__ | |||
| // these are missing from HaikuOS | |||
| #define pthread_setname_np(...) | |||
| static int pthread_getcpuclockid(pthread_t, clockid_t* const clock_id) | |||
| int pthread_getcpuclockid(pthread_t, clockid_t* const clock_id) | |||
| { | |||
| *clock_id = CLOCK_REALTIME; | |||
| return 0; | |||
| } | |||
| #endif | |||
| static int backtrace(void**, int) | |||
| { | |||
| @@ -515,7 +515,7 @@ PLUGIN_FILES += $(filter-out Bidoo/src/plugin.cpp Bidoo/src/ANTN.cpp,$(wildcard | |||
| PLUGIN_FILES += $(wildcard Bidoo/src/dep/*.cpp) | |||
| PLUGIN_FILES += $(wildcard Bidoo/src/dep/filters/*.cpp) | |||
| PLUGIN_FILES += $(wildcard Bidoo/src/dep/freeverb/*.cpp) | |||
| PLUGIN_FILES += $(wildcard Bidoo/src/dep/lodepng/*.cpp) | |||
| PLUGIN_FILES += $(filter-out Bidoo/src/dep/lodepng/pngdetail.cpp,$(wildcard Bidoo/src/dep/lodepng/*.cpp)) | |||
| PLUGIN_FILES += $(filter-out Bidoo/src/dep/resampler/main.cpp,$(wildcard Bidoo/src/dep/resampler/*.cpp)) | |||
| PLUGIN_FILES += BidooDark/plugin.cpp | |||
| @@ -1024,6 +1024,10 @@ BASE_FLAGS += -I../src/Rack/dep/pffft | |||
| ifeq ($(DEBUG),true) | |||
| BASE_FLAGS += -UDEBUG | |||
| ifeq ($(WASM),true) | |||
| # SSE must always be enabled on wasm, even in debug builds | |||
| BASE_FLAGS += -msse -msse2 -msse3 -msimd128 | |||
| endif | |||
| endif | |||
| ifeq ($(HEADLESS),true) | |||
| @@ -1098,6 +1102,23 @@ ifeq ($(MACOS),true) | |||
| BASE_FLAGS += -Wno-unknown-warning-option | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Carla and friends build flags | |||
| CARLA_FLAGS = \ | |||
| -DCARLA_BACKEND_NAMESPACE=Cardinal \ | |||
| -DREAL_BUILD \ | |||
| -DSTATIC_PLUGIN_TARGET \ | |||
| -I../deps/aubio/src \ | |||
| -I../carla/source/backend \ | |||
| -I../carla/source/includes \ | |||
| -I../carla/source/modules \ | |||
| -I../carla/source/utils | |||
| ifeq ($(WASM),true) | |||
| CARLA_FLAGS += -DDISTRHO_RUNNER_INDIRECT_WASM_CALLS | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Build targets | |||
| @@ -1314,14 +1335,7 @@ $(BUILD_DIR)/Cardinal/%.cpp.o: Cardinal/%.cpp | |||
| -Dstbtt_fontinfo=stbtt_fontinfo_cardinal \ | |||
| -Dstbrp_node=stbrp_node_cardinal \ | |||
| -Dstbrp_rect=stbrp_rect_cardinal \ | |||
| -DCARLA_BACKEND_NAMESPACE=Cardinal \ | |||
| -DREAL_BUILD \ | |||
| -DSTATIC_PLUGIN_TARGET \ | |||
| -I../deps/aubio/src \ | |||
| -I../carla/source/backend \ | |||
| -I../carla/source/includes \ | |||
| -I../carla/source/modules \ | |||
| -I../carla/source/utils | |||
| $(CARLA_FLAGS) | |||
| $(BUILD_DIR)/21kHz/%.cpp.o: 21kHz/%.cpp | |||
| -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" | |||
| @@ -284,7 +284,7 @@ void openBrowser(const std::string& url) | |||
| window.open(UTF8ToString($0), '_blank'); | |||
| }, url.c_str()); | |||
| #else | |||
| patchUtils::openBrowser(url); | |||
| system::openBrowser(url); | |||
| #endif | |||
| } | |||
| @@ -104,16 +104,18 @@ bool d_isDiffHigherThanLimit(const T& v1, const T& v2, const T& limit) | |||
| // ----------------------------------------------------------------------------------------------------------- | |||
| #ifdef DISTRHO_OS_WASM | |||
| EM_JS(char*, getPatchStorageSlug, (), { | |||
| var searchParams = new URLSearchParams(window.location.search); | |||
| var patch = searchParams.get('patchstorage'); | |||
| if (!patch) | |||
| return null; | |||
| var length = lengthBytesUTF8(patch) + 1; | |||
| var str = _malloc(length); | |||
| stringToUTF8(patch, str, length); | |||
| return str; | |||
| }); | |||
| static char* getPatchStorageSlug() { | |||
| return static_cast<char*>(EM_ASM_PTR({ | |||
| var searchParams = new URLSearchParams(window.location.search); | |||
| var patch = searchParams.get('patchstorage'); | |||
| if (!patch) | |||
| return null; | |||
| var length = lengthBytesUTF8(patch) + 1; | |||
| var str = _malloc(length); | |||
| stringToUTF8(patch, str, length); | |||
| return str; | |||
| })); | |||
| }; | |||
| #endif | |||
| // ----------------------------------------------------------------------------------------------------------- | |||
| @@ -388,20 +388,9 @@ public: | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (rack::patchStorageSlug != nullptr) | |||
| { | |||
| std::string url("/patchstorage.php?slug="); | |||
| url += rack::patchStorageSlug; | |||
| std::free(rack::patchStorageSlug); | |||
| rack::patchStorageSlug = nullptr; | |||
| psDialog = new WasmPatchStorageLoadingDialog(); | |||
| emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(), | |||
| downloadPatchStorageSucceeded, downloadPatchStorageFailed); | |||
| } | |||
| else | |||
| { | |||
| new WasmWelcomeDialog(); | |||
| } | |||
| #endif | |||
| context->window->step(); | |||
| @@ -443,6 +432,19 @@ public: | |||
| { | |||
| counterForSelfFocus = -1; | |||
| getWindow().focus(); | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (rack::patchStorageSlug != nullptr) | |||
| { | |||
| std::string url("/patchstorage.php?slug="); | |||
| url += rack::patchStorageSlug; | |||
| std::free(rack::patchStorageSlug); | |||
| rack::patchStorageSlug = nullptr; | |||
| emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(), | |||
| downloadPatchStorageSucceeded, downloadPatchStorageFailed); | |||
| } | |||
| #endif | |||
| } | |||
| if (filebrowserhandle != nullptr && fileBrowserIdle(filebrowserhandle)) | |||
| @@ -64,6 +64,10 @@ BASE_FLAGS += -IRack/dep/pffft | |||
| ifeq ($(DEBUG),true) | |||
| BASE_FLAGS += -UDEBUG | |||
| ifeq ($(WASM),true) | |||
| # SSE must always be enabled on wasm, even in debug builds | |||
| BASE_FLAGS += -msse -msse2 -msse3 -msimd128 | |||
| endif | |||
| endif | |||
| ifeq ($(HAVE_LIBLO),true) | |||
| @@ -168,6 +172,10 @@ RACK_FILES += $(wildcard Rack/src/*/*.c) | |||
| RACK_FILES += $(filter-out $(IGNORED_FILES),$(wildcard Rack/src/*.cpp)) | |||
| RACK_FILES += $(filter-out $(IGNORED_FILES), $(wildcard Rack/src/*/*.cpp)) | |||
| ifeq ($(WASM),true) | |||
| RACK_FILES += emscripten/WasmUtils.cpp | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # lots of warnings from VCV side | |||
| @@ -194,6 +202,8 @@ all: $(TARGET) | |||
| ifeq ($(MOD_BUILD),true) | |||
| $(MAKE) -C Cardinal lv2 | |||
| $(MAKE) -C CardinalFX lv2 | |||
| else ifeq ($(WASM),true) | |||
| $(MAKE) -C CardinalSynth jack | |||
| else | |||
| $(MAKE) -C Cardinal | |||
| $(MAKE) -C CardinalFX $(CARDINAL_FX_ARGS) | |||
| @@ -244,6 +254,8 @@ $(BUILD_DIR)/%.cpp.o: %.cpp | |||
| @echo "Compiling $<" | |||
| $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
| $(BUILD_DIR)/emscripten/WasmUtils.cpp.o: BUILD_CXX_FLAGS += -fno-exceptions | |||
| # -------------------------------------------------------------- | |||
| -include $(RACK_OBJS:%.o=%.d) | |||
| @@ -20,7 +20,6 @@ endif | |||
| ifneq ($(STATIC_BUILD),true) | |||
| CWD = ../../carla/source | |||
| STATIC_PLUGIN_TARGET = true | |||
| include $(CWD)/Makefile.deps.mk | |||
| CARLA_BUILD_DIR = ../../carla/build | |||
| @@ -35,7 +34,9 @@ CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_engine_ | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_plugin.a | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/native-plugins.a | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/audio_decoder.a | |||
| ifneq ($(WASM),true) | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jackbridge.min.a | |||
| endif | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/lilv.a | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/rtmempool.a | |||
| CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/sfzero.a | |||
| @@ -114,6 +115,11 @@ endif | |||
| # -------------------------------------------------------------- | |||
| # FIXME | |||
| ifeq ($(WASM),true) | |||
| STATIC_CARLA_PLUGIN_LIBS = -lsndfile -lopus -lFLAC -lvorbisenc -lvorbis -logg -lm | |||
| endif | |||
| EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) | |||
| EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS) | |||
| @@ -206,6 +212,7 @@ BASE_FLAGS += -Wno-unused-variable | |||
| ifeq ($(WASM),true) | |||
| LINK_FLAGS += --preload-file=./jsfx | |||
| LINK_FLAGS += --preload-file=./lv2 | |||
| LINK_FLAGS += --preload-file=./resources | |||
| LINK_FLAGS += -sALLOW_MEMORY_GROWTH | |||
| LINK_FLAGS += -sINITIAL_MEMORY=64Mb | |||
| @@ -0,0 +1,36 @@ | |||
| /* | |||
| * DISTRHO Cardinal Plugin | |||
| * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 3 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the LICENSE file. | |||
| */ | |||
| #include <emscripten/html5.h> | |||
| // ----------------------------------------------------------------------------------------------------------- | |||
| namespace CardinalDISTRHO { | |||
| long d_emscripten_set_interval(void (*cb)(void* userData), double intervalMsecs, void* userData) | |||
| { | |||
| return emscripten_set_interval(cb, intervalMsecs, userData); | |||
| } | |||
| void d_emscripten_clear_interval(long setIntervalId) | |||
| { | |||
| emscripten_clear_interval(setIntervalId); | |||
| } | |||
| } | |||
| // ----------------------------------------------------------------------------------------------------------- | |||