commit 9be6a49c42c8308001cbbd2f0f47cae25d547d9c
parent 19cb24186bb25e9e17586e2055eaee0e6d71b3f9
Author: falkTX <falktx@falktx.com>
Date: Mon, 26 Feb 2024 10:28:32 +0100
AU related fixups
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
5 files changed, 27 insertions(+), 46 deletions(-)
diff --git a/Makefile.plugins.mk b/Makefile.plugins.mk
@@ -693,9 +693,9 @@ $(au): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_AU.cpp.o
endif
-@mkdir -p $(shell dirname $@)
@echo "Creating AU component for $(NAME)"
- $(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_DSP_LIBS) $(EXTRA_UI_LIBS) $(DGL_LIBS) -framework AudioToolbox $(SHARED) $(SYMBOLS_AU) -o $@
+ $(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_DSP_LIBS) $(EXTRA_UI_LIBS) $(DGL_LIBS) -framework AudioToolbox -framework CoreFoundation $(SHARED) $(SYMBOLS_AU) -o $@
-# -framework AudioUnit -framework Foundation
+# -framework AudioUnit
# ---------------------------------------------------------------------------------------------------------------------
# Export
diff --git a/cmake/DPF-plugin.cmake b/cmake/DPF-plugin.cmake
@@ -561,8 +561,13 @@ function(dpf__build_au NAME HAS_UI)
dpf__add_ui_main("${NAME}-au" "au" "${HAS_UI}")
dpf__set_module_export_list("${NAME}-au" "au")
find_library(APPLE_AUDIOTOOLBOX_FRAMEWORK "AudioToolbox")
+ find_library(APPLE_COREFOUNDATION_FRAMEWORK "CoreFoundation")
target_compile_options("${NAME}-au" PRIVATE "-ObjC++")
- target_link_libraries("${NAME}-au" PRIVATE "${NAME}-dsp" "${NAME}-ui" "${APPLE_AUDIOTOOLBOX_FRAMEWORK}")
+ target_link_libraries("${NAME}-au" PRIVATE
+ "${NAME}-dsp"
+ "${NAME}-ui"
+ "${APPLE_AUDIOTOOLBOX_FRAMEWORK}"
+ "${APPLE_COREFOUNDATION_FRAMEWORK}")
set_target_properties("${NAME}-au" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NAME}.component/Contents/MacOS/$<0:>"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/obj/au/$<0:>"
diff --git a/distrho/src/DistrhoPluginAU.cpp b/distrho/src/DistrhoPluginAU.cpp
@@ -22,7 +22,7 @@
#include "DistrhoPluginInternal.hpp"
#include "../DistrhoPluginUtils.hpp"
-#if DISTRHO_PLUGIN_HAS_UI
+#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# include "../extra/RingBuffer.hpp"
#endif
@@ -239,6 +239,9 @@ static constexpr const requestParameterValueChangeFunc requestParameterValueChan
#if ! DISTRHO_PLUGIN_WANT_STATE
static constexpr const updateStateValueFunc updateStateValueCallback = nullptr;
#endif
+#if DISTRHO_PLUGIN_WANT_TIMEPOS
+static constexpr const double kDefaultTicksPerBeat = 1920.0;
+#endif
typedef std::map<const String, String> StringMap;
@@ -352,9 +355,7 @@ public:
#if DISTRHO_PLUGIN_WANT_TIMEPOS
std::memset(&fHostCallbackInfo, 0, sizeof(fHostCallbackInfo));
-
- // ticksPerBeat is not possible with AU
- fTimePosition.bbt.ticksPerBeat = 1920.0;
+ fTimePosition.bbt.ticksPerBeat = kDefaultTicksPerBeat;
#endif
}
@@ -384,6 +385,7 @@ public:
#endif
#if DISTRHO_PLUGIN_WANT_TIMEPOS
fTimePosition.clear();
+ fTimePosition.bbt.ticksPerBeat = kDefaultTicksPerBeat;
#endif
return noErr;
}
@@ -1578,6 +1580,7 @@ public:
#endif
#if DISTRHO_PLUGIN_WANT_TIMEPOS
fTimePosition.clear();
+ fTimePosition.bbt.ticksPerBeat = kDefaultTicksPerBeat;
#endif
return noErr;
}
@@ -1936,12 +1939,13 @@ private:
Float32 f1 = 4.f; // initial value for beats per bar
Float64 g1 = 0.0;
Float64 g2 = 0.0;
- UInt32 u1 = 0.0;
+ UInt32 u1 = 0;
if (fHostCallbackInfo.musicalTimeLocationProc != nullptr
&& fHostCallbackInfo.musicalTimeLocationProc(fHostCallbackInfo.hostUserData,
nullptr, &f1, &u1, nullptr) == noErr)
{
+ f1 /= u1;
fTimePosition.bbt.beatsPerBar = f1;
fTimePosition.bbt.beatType = u1;
}
@@ -1984,7 +1988,7 @@ private:
fTimePosition.frame = 0;
}
- fTimePosition.bbt.barStartTick = fTimePosition.bbt.ticksPerBeat *
+ fTimePosition.bbt.barStartTick = kDefaultTicksPerBeat *
fTimePosition.bbt.beatsPerBar *
(fTimePosition.bbt.bar - 1);
diff --git a/distrho/src/DistrhoUIAU.mm b/distrho/src/DistrhoUIAU.mm
@@ -155,20 +155,12 @@ public:
void postSetup()
{
- if (fUI.isResizable())
- {
- // [view setAutoresizingMask:NSViewNotSizable];
- [fParentView setAutoresizesSubviews:YES];
- }
- else
- {
- [fParentView setAutoresizingMask:NSViewNotSizable];
- [fParentView setAutoresizesSubviews:NO];
- }
-
- // NSView* const uiView = reinterpret_cast<NSView*>(fUI.getNativeWindowHandle());
+ const NSSize size = NSMakeSize(fUI.getWidth(), fUI.getHeight());
+ NSView* const uiView = reinterpret_cast<NSView*>(fUI.getNativeWindowHandle());
- [fParentView setFrameSize:NSMakeSize(fUI.getWidth(), fUI.getHeight())];
+ [fParentView setAutoresizesSubviews:fUI.isResizable()];
+ [fParentView setFrameSize:size];
+ [uiView setFrameSize:size];
}
private:
diff --git a/examples/Meters/ExampleUIMeters.cpp b/examples/Meters/ExampleUIMeters.cpp
@@ -41,9 +41,7 @@ public:
fColorValue(0),
// init meter values to 0
fOutLeft(0.0f),
- fOutRight(0.0f),
- // FIXME
- fNeedsRepaint(false)
+ fOutRight(0.0f)
{
setGeometryConstraints(32, 128, false);
}
@@ -73,9 +71,7 @@ protected:
if (fOutLeft != value)
{
fOutLeft = value;
- // FIXME
- // repaint();
- fNeedsRepaint = true;
+ repaint();
}
break;
@@ -88,9 +84,7 @@ protected:
if (fOutRight != value)
{
fOutRight = value;
- // FIXME
- // repaint();
- fNeedsRepaint = true;
+ repaint();
}
break;
}
@@ -204,15 +198,6 @@ protected:
return true;
}
- void uiIdle() override
- {
- if (fNeedsRepaint)
- {
- fNeedsRepaint = false;
- repaint();
- }
- }
-
// -------------------------------------------------------------------------------------------------------
private:
@@ -228,9 +213,6 @@ private:
*/
float fOutLeft, fOutRight;
- // FIXME this shouldnt be needed!
- bool fNeedsRepaint;
-
/**
Update color if needed.
*/
@@ -251,9 +233,7 @@ private:
break;
}
- // FIXME
- // repaint();
- fNeedsRepaint = true;
+ repaint();
}
/**