Get Ildaeil to do some useful things

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-11-05 23:07:18 +00:00
parent d1916efe99
commit 072f9ee3ca
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
12 changed files with 1253 additions and 29 deletions

3
.gitmodules vendored
View file

@ -64,3 +64,6 @@
[submodule "plugins/DrumKit"]
path = plugins/DrumKit
url = https://github.com/SVModular/DrumKit.git
[submodule "carla"]
path = carla
url = https://github.com/falkTX/Carla.git

View file

@ -6,7 +6,7 @@
include dpf/Makefile.base.mk
all: cardinal deps dgl plugins gen resources
all: cardinal carla deps dgl plugins gen resources
# --------------------------------------------------------------
# Build config
@ -62,6 +62,11 @@ endif
cardinal: deps dgl plugins
$(MAKE) all -C src
carla:
$(MAKE) -C carla plugin \
CAN_GENERATE_LV2_TTL=false \
STATIC_PLUGIN_TARGET=true
deps:
ifneq ($(SYSDEPS),true)
$(MAKE) all -C deps
@ -116,4 +121,4 @@ install:
# --------------------------------------------------------------
.PHONY: deps plugins
.PHONY: carla deps plugins

1
carla Submodule

@ -0,0 +1 @@
Subproject commit 14e9ec85fa2866c423e8a7c36490272ec49fb924

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,6 @@
# include "../../../dpf/dgl/src/Resources.hpp"
#endif
#include "DearImGui/imgui.h"
#include "DearImGui/imgui_impl_opengl2.h"
struct ImGuiWidget::PrivateData {
@ -115,13 +114,10 @@ void ImGuiWidget::drawFramebuffer()
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
ImGui::SetCurrentContext(imData->context);
ImGui_ImplOpenGL2_NewFrame();
ImGui::NewFrame();
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(box.size.x, box.size.y));
ImGui::ShowDemoWindow();
drawImGui();
ImGui::Render();
@ -140,8 +136,30 @@ void ImGuiWidget::onHover(const HoverEvent& e)
ImGui::SetCurrentContext(imData->context);
ImGuiIO& io(ImGui::GetIO());
io.MousePos.x = e.pos.x;
io.MousePos.y = e.pos.y;
io.MousePos.x = e.pos.x + e.mouseDelta.x;
io.MousePos.y = e.pos.y + e.mouseDelta.y;
}
void ImGuiWidget::onDragHover(const DragHoverEvent& e)
{
ImGui::SetCurrentContext(imData->context);
ImGuiIO& io(ImGui::GetIO());
io.MousePos.x = e.pos.x + e.mouseDelta.x;
io.MousePos.y = e.pos.y + e.mouseDelta.y;
}
void ImGuiWidget::onHoverScroll(const HoverScrollEvent& e)
{
ImGui::SetCurrentContext(imData->context);
ImGuiIO& io(ImGui::GetIO());
io.MouseWheel += e.scrollDelta.y * 0.01f;
io.MouseWheelH += e.scrollDelta.x * 0.01f;
if (io.WantCaptureMouse)
e.consume(this);
}
void ImGuiWidget::onButton(const ButtonEvent& e)
@ -153,13 +171,75 @@ void ImGuiWidget::onButton(const ButtonEvent& e)
switch (e.button)
{
case GLFW_MOUSE_BUTTON_LEFT:
io.MouseDown[0] = e.action;
io.MouseDown[0] = e.action == GLFW_PRESS;
break;
case GLFW_MOUSE_BUTTON_MIDDLE:
io.MouseDown[1] = e.action;
io.MouseDown[1] = e.action == GLFW_PRESS;
break;
case GLFW_MOUSE_BUTTON_RIGHT:
io.MouseDown[2] = e.action;
io.MouseDown[2] = e.action == GLFW_PRESS;
break;
}
io.KeyCtrl = e.mods & GLFW_MOD_CTRL;
io.KeyShift = e.mods & GLFW_MOD_SHIFT;
io.KeyAlt = e.mods & GLFW_MOD_ALT;
io.KeySuper = e.mods & GLFW_MOD_SUPER;
if (io.WantCaptureMouse)
e.consume(this);
}
void ImGuiWidget::onSelectKey(const SelectKeyEvent& e)
{
ImGui::SetCurrentContext(imData->context);
ImGuiIO& io(ImGui::GetIO());
io.KeyCtrl = e.mods & GLFW_MOD_CTRL;
io.KeyShift = e.mods & GLFW_MOD_SHIFT;
io.KeyAlt = e.mods & GLFW_MOD_ALT;
io.KeySuper = e.mods & GLFW_MOD_SUPER;
printf("onSelectKey %i %i\n", e.key, e.scancode);
// d_stdout("onKeyboard %u %u", event.key, event.keycode);
/*
if (event.key <= kKeyDelete)
io.KeysDown[event.key] = event.press;
else if (event.key >= kKeyF1 && event.key <= kKeyPause)
io.KeysDown[0xff + event.key - kKeyF1] = event.press;
*/
if (io.WantCaptureKeyboard)
e.consume(this);
}
void ImGuiWidget::onSelectText(const SelectTextEvent& e)
{
ImGui::SetCurrentContext(imData->context);
ImGuiIO& io(ImGui::GetIO());
switch (e.codepoint)
{
/*
case kKeyBackspace:
case kKeyEscape:
case kKeyDelete:
*/
case '\n':
case '\r':
case '\t':
break;
default:
// d_stdout("input %u %u %lu '%s'", event.keycode, event.character, std::strlen(event.string), event.string);
char character[2] = { (char)e.codepoint, 0 };
io.AddInputCharactersUTF8(character);
break;
}
if (io.WantCaptureKeyboard)
e.consume(this);
}

View file

@ -18,6 +18,7 @@
#pragma once
#include "plugin.hpp"
#include "DearImGui/imgui.h"
struct ImGuiWidget : OpenGlWidget {
struct PrivateData;
@ -25,8 +26,20 @@ struct ImGuiWidget : OpenGlWidget {
ImGuiWidget(float width, float height);
~ImGuiWidget() override;
void drawFramebuffer() override;
virtual void drawImGui()
{
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(box.size.x, box.size.y));
ImGui::ShowDemoWindow();
}
private:
void drawFramebuffer() override;
void onHover(const HoverEvent& e) override;
void onDragHover(const DragHoverEvent& e) override;
void onHoverScroll(const HoverScrollEvent& e) override;
void onButton(const ButtonEvent& e) override;
void onSelectKey(const SelectKeyEvent& e) override;
void onSelectText(const SelectTextEvent& e) override;
};

View file

@ -36,6 +36,7 @@ struct CardinalPluginContext : rack::Context {
bool playing, reset;
int32_t bar, beat, beatsPerBar;
double tick, tickClock, ticksPerBeat, ticksPerClock, ticksPerFrame;
uintptr_t nativeWindowId;
Plugin* const plugin;
CardinalPluginContext(Plugin* const p);
};

View file

@ -676,7 +676,13 @@ $(BUILD_DIR)/Cardinal/%.cpp.o: Cardinal/%.cpp
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ \
-DpluginInstance=pluginInstance__Cardinal
-DpluginInstance=pluginInstance__Cardinal \
-DREAL_BUILD \
-DSTATIC_PLUGIN_TARGET \
-I../carla/source/backend \
-I../carla/source/includes \
-I../carla/source/modules \
-I../carla/source/utils
$(BUILD_DIR)/AmalgamatedHarmonics/%.cpp.o: AmalgamatedHarmonics/%.cpp
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"

View file

@ -98,6 +98,8 @@ public:
fContext(getRackContextFromPlugin(getPluginInstancePointer())),
fResizeHandle(this)
{
fContext->nativeWindowId = getWindow().getNativeWindowHandle();
if (isResizable())
fResizeHandle.hide();

View file

@ -13,6 +13,58 @@ PREFIX ?= /usr/local
DESTDIR ?=
SYSDEPS ?= false
# --------------------------------------------------------------
# Carla stuff
CWD = ../../carla/source
include $(CWD)/Makefile.deps.mk
CARLA_BUILD_DIR = ../../carla/build
ifeq ($(DEBUG),true)
CARLA_BUILD_TYPE = Debug
else
CARLA_BUILD_TYPE = Release
endif
CARLA_EXTRA_LIBS = $(CARLA_BUILD_DIR)/plugin/$(CARLA_BUILD_TYPE)/carla-host-plugin.cpp.o
# ifneq ($(MACOS),true)
# CARLA_EXTRA_LIBS += -Wl,--start-group -Wl,--whole-archive
# endif
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_engine_plugin.a
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
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jackbridge.min.a
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
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/water.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/zita-resampler.a
# CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/eel2.a
# CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jsusfx.a
ifeq ($(USING_JUCE),true)
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_audio_basics.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_audio_processors.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_core.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_data_structures.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_events.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_graphics.a
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_gui_basics.a
ifeq ($(USING_JUCE_GUI_EXTRA),true)
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/juce_gui_extra.a
endif
endif
# ifneq ($(MACOS),true)
# CARLA_EXTRA_LIBS += -Wl,--no-whole-archive -Wl,--end-group
# endif
# FIXME patch fluidsynth package
ifeq ($(WINDOWS),true)
STATIC_CARLA_PLUGIN_LIBS += -ldsound -lwinmm
endif
CARLA_EXTRA_LIBS += $(STATIC_CARLA_PLUGIN_LIBS)
# --------------------------------------------------------------
# Import base definitions
@ -37,22 +89,25 @@ endif
# --------------------------------------------------------------
# Extra libraries to link against
EXTRA_LIBS = ../../plugins/plugins.a
EXTRA_LIBS += ../rack.a
RACK_EXTRA_LIBS = ../../plugins/plugins.a
RACK_EXTRA_LIBS += ../rack.a
ifneq ($(SYSDEPS),true)
EXTRA_LIBS += ../Rack/dep/lib/libjansson.a
EXTRA_LIBS += ../Rack/dep/lib/libsamplerate.a
EXTRA_LIBS += ../Rack/dep/lib/libspeexdsp.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libjansson.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libsamplerate.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libspeexdsp.a
ifeq ($(WINDOWS),true)
EXTRA_LIBS += ../Rack/dep/lib/libarchive_static.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libarchive_static.a
else
EXTRA_LIBS += ../Rack/dep/lib/libarchive.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libarchive.a
endif
EXTRA_LIBS += ../Rack/dep/lib/libzstd.a
RACK_EXTRA_LIBS += ../Rack/dep/lib/libzstd.a
endif
EXTRA_DEPENDENCIES = $(EXTRA_LIBS)
# --------------------------------------------------------------
EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS)
EXTRA_LIBS = $(CARLA_EXTRA_LIBS) $(RACK_EXTRA_LIBS)
# --------------------------------------------------------------
# Do some magic

View file

@ -43,6 +43,7 @@ struct CardinalPluginContext : rack::Context {
bool playing, reset;
int32_t bar, beat, beatsPerBar;
double tick, tickClock, ticksPerBeat, ticksPerClock, ticksPerFrame;
uintptr_t nativeWindowId;
Plugin* const plugin;
CardinalPluginContext(Plugin* const p)
@ -58,6 +59,7 @@ struct CardinalPluginContext : rack::Context {
ticksPerBeat(0.0),
ticksPerClock(0.0),
ticksPerFrame(0.0),
nativeWindowId(0),
plugin(p)
{
std::memset(parameters, 0, sizeof(parameters));

View file

@ -82,6 +82,7 @@
"version": "2.0",
"params": [],
"leftModuleId": 3,
"rightModuleId": 5,
"pos": [
21,
0
@ -94,10 +95,23 @@
"version": "2.0",
"params": [],
"leftModuleId": 4,
"rightModuleId": 6,
"pos": [
30,
0
]
},
{
"id": 6,
"plugin": "Cardinal",
"model": "Ildaeil",
"version": "2.0",
"params": [],
"leftModuleId": 4,
"pos": [
38,
0
]
}
],
"cables": [],