| @@ -55,10 +55,12 @@ set_property(TARGET sPlugins PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/. | |||
| add_library(sRack STATIC IMPORTED) | |||
| set_property(TARGET sRack PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../src/rack.a") | |||
| #ifeq ($(WINDOWS),true) | |||
| #RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libarchive_static.a | |||
| add_library(libarchive STATIC IMPORTED) | |||
| if (WIN32) | |||
| set_property(TARGET libarchive PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../src/Rack/dep/lib/libarchive_static.a") | |||
| else (WIN32) | |||
| set_property(TARGET libarchive PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../src/Rack/dep/lib/libarchive.a") | |||
| endif (WIN32) | |||
| add_library(libjansson STATIC IMPORTED) | |||
| set_property(TARGET libjansson PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../src/Rack/dep/lib/libjansson.a") | |||
| @@ -75,9 +77,29 @@ set_property(TARGET libspeexdsp PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR | |||
| add_library(libzstd STATIC IMPORTED) | |||
| set_property(TARGET libzstd PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../src/Rack/dep/lib/libzstd.a") | |||
| #find_package(Dbus) | |||
| find_package(OpenGL) | |||
| find_package(X11) | |||
| # dependencies | |||
| find_package(PkgConfig REQUIRED) | |||
| pkg_check_modules(LIBLO REQUIRED liblo) | |||
| pkg_check_modules(SNDFILE REQUIRED sndfile) | |||
| if (NOT APPLE OR WIN32) | |||
| pkg_check_modules(X11 REQUIRED x11) | |||
| pkg_check_modules(XCURSOR REQUIRED Xcursor) | |||
| pkg_check_modules(XEXT REQUIRED Xext) | |||
| pkg_check_modules(XRANDR REQUIRED Xrandr) | |||
| pkg_check_modules(DBUS REQUIRED dbus-1) | |||
| set(EXTRA_LIBS "-lrt") | |||
| endif (NOT APPLE OR WIN32) | |||
| if (APPLE) | |||
| set(EXTRA_LIBS "-lz") | |||
| set(GL_LIBRARIES "-framework OpenGL") | |||
| else (APPLE) | |||
| pkg_check_modules(GL REQUIRED gl) | |||
| set(STATIC_LIBS_START "-Wl,--whole-archive") | |||
| set(STATIC_LIBS_END "-Wl,--no-whole-archive") | |||
| endif (APPLE) | |||
| # FX variant | |||
| @@ -89,7 +111,7 @@ juce_add_plugin(CardinalFX | |||
| EDITOR_WANTS_KEYBOARD_FOCUS TRUE | |||
| PLUGIN_MANUFACTURER_CODE Dstr | |||
| PLUGIN_CODE dCnF | |||
| FORMATS Standalone AU | |||
| FORMATS Standalone VST3 AU | |||
| PRODUCT_NAME "CardinalFX") | |||
| target_sources(CardinalFX | |||
| @@ -98,23 +120,20 @@ target_sources(CardinalFX | |||
| target_include_directories(CardinalFX | |||
| PRIVATE | |||
| . | |||
| ../dpf/distrho) | |||
| ../dpf/distrho | |||
| ../src/CardinalFX) | |||
| target_compile_definitions(CardinalFX | |||
| PUBLIC | |||
| JUCE_DISPLAY_SPLASH_SCREEN=0 | |||
| JUCE_USE_CURL=0 | |||
| JUCE_VST3_CAN_REPLACE_VST2=0 | |||
| JUCE_WEB_BROWSER=0) | |||
| target_link_directories(CardinalFX | |||
| PUBLIC | |||
| /opt/kxstudio/lib) | |||
| target_link_libraries(CardinalFX | |||
| PRIVATE | |||
| juce::juce_audio_utils | |||
| -Wl,--whole-archive | |||
| ${STATIC_LIBS_START} | |||
| sCardinalFX | |||
| sPlugins | |||
| sRack | |||
| @@ -136,19 +155,18 @@ target_link_libraries(CardinalFX | |||
| libsamplerate | |||
| libspeexdsp | |||
| libzstd | |||
| -Wl,--no-whole-archive | |||
| GLX | |||
| OpenGL | |||
| X11 | |||
| Xcursor | |||
| Xext | |||
| Xrandr | |||
| PUBLIC | |||
| -ldbus-1 | |||
| -llo | |||
| ${STATIC_LIBS_END} | |||
| ${GL_LIBRARIES} | |||
| ${DBUS_LIBRARIES} | |||
| ${LIBLO_LIBRARIES} | |||
| ${SNDFILE_LIBRARIES} | |||
| ${X11_LIBRARIES} | |||
| ${XCURSOR_LIBRARIES} | |||
| ${XEXT_LIBRARIES} | |||
| ${XRANDR_LIBRARIES} | |||
| ${EXTRA_LIBS} | |||
| -lmagic | |||
| -lsndfile -lFLAC -lvorbisenc -lvorbis -logg | |||
| -lrt | |||
| PUBLIC | |||
| juce::juce_recommended_config_flags | |||
| juce::juce_recommended_lto_flags | |||
| juce::juce_recommended_warning_flags) | |||
| @@ -77,6 +77,7 @@ class CardinalWrapperProcessor : public juce::AudioProcessor | |||
| friend class CardinalWrapperEditor; | |||
| PluginExporter plugin; | |||
| TimePosition timePosition; | |||
| static bool writeMidi(void* ptr, const MidiEvent& midiEvent) | |||
| { | |||
| @@ -137,7 +138,55 @@ public: | |||
| void processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages) override | |||
| { | |||
| midiMessages.clear(); | |||
| // AudioPlayHead* getPlayHead() | |||
| juce::AudioPlayHead* const playhead = getPlayHead(); | |||
| juce::AudioPlayHead::CurrentPositionInfo posInfo; | |||
| if (playhead != nullptr && playhead->getCurrentPosition(posInfo)) | |||
| { | |||
| timePosition.playing = posInfo.isPlaying; | |||
| timePosition.bbt.valid = true; | |||
| // ticksPerBeat is not possible with JUCE | |||
| timePosition.bbt.ticksPerBeat = 1920.0; | |||
| if (posInfo.timeInSamples >= 0) | |||
| timePosition.frame = posInfo.timeInSamples; | |||
| else | |||
| timePosition.frame = 0; | |||
| timePosition.bbt.beatsPerMinute = posInfo.bpm; | |||
| const double ppqPos = std::abs(posInfo.ppqPosition); | |||
| const int ppqPerBar = posInfo.timeSigNumerator * 4 / posInfo.timeSigDenominator; | |||
| const double barBeats = (std::fmod(ppqPos, ppqPerBar) / ppqPerBar) * posInfo.timeSigNumerator; | |||
| const double rest = std::fmod(barBeats, 1.0); | |||
| timePosition.bbt.bar = static_cast<int32_t>(ppqPos) / ppqPerBar + 1; | |||
| timePosition.bbt.beat = static_cast<int32_t>(barBeats - rest + 0.5) + 1; | |||
| timePosition.bbt.tick = rest * timePosition.bbt.ticksPerBeat; | |||
| timePosition.bbt.beatsPerBar = posInfo.timeSigNumerator; | |||
| timePosition.bbt.beatType = posInfo.timeSigDenominator; | |||
| if (posInfo.ppqPosition < 0.0) | |||
| { | |||
| --timePosition.bbt.bar; | |||
| timePosition.bbt.beat = posInfo.timeSigNumerator - timePosition.bbt.beat + 1; | |||
| timePosition.bbt.tick = timePosition.bbt.ticksPerBeat - timePosition.bbt.tick - 1; | |||
| } | |||
| timePosition.bbt.barStartTick = timePosition.bbt.ticksPerBeat* | |||
| timePosition.bbt.beatsPerBar* | |||
| (timePosition.bbt.bar-1); | |||
| } | |||
| else | |||
| { | |||
| timePosition.frame = 0; | |||
| timePosition.playing = false; | |||
| timePosition.bbt.valid = false; | |||
| } | |||
| plugin.setTimePosition(timePosition); | |||
| const int numSamples = buffer.getNumSamples(); | |||
| DISTRHO_SAFE_ASSERT_INT_RETURN(numSamples > 0, numSamples,); | |||
| @@ -222,7 +271,19 @@ class CardinalWrapperEditor : public juce::AudioProcessorEditor | |||
| static void setSizeFunc(void* ptr, uint width, uint height) | |||
| { | |||
| static_cast<CardinalWrapperEditor*>(ptr)->setSize(width, height); | |||
| CardinalWrapperEditor* const editor = static_cast<CardinalWrapperEditor*>(ptr); | |||
| DISTRHO_SAFE_ASSERT_RETURN(editor != nullptr,); | |||
| #ifdef DISTRHO_OS_MAC | |||
| UIExporter* const ui = editor->ui; | |||
| DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); | |||
| const double scaleFactor = ui->getScaleFactor(); | |||
| width /= scaleFactor; | |||
| height /= scaleFactor; | |||
| #endif | |||
| editor->setSize(width, height); | |||
| } | |||
| static bool fileRequestFunc(void* ptr, const char* key) { return false; } | |||