Tracktion / tracktion_engine

Tracktion Engine module
Other
1.2k stars 152 forks source link

PitchAndTimeDemo cmake build broken and Rubberband on Windows has build errors (fixes included) #107

Closed meverett closed 2 years ago

meverett commented 2 years ago

These are two separate issue related to time stretching. I'm currently using the develop branch.


First, the PitchAndTimeDemo CMakeLists.txt is missing the preprocessor definitions to enable time stretching, and the demo hangs when it attempts to apply time stretching. The PIP file for the PitchAndTimeDemo, however, does have the correct preprocessor definitions.

Current cmake prepocessor definitions:

target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
    JUCE_PLUGINHOST_AU=1
    JUCE_PLUGINHOST_LADSPA=1
    JUCE_PLUGINHOST_VST3=1
    JUCE_USE_CURL=0
    JUCE_WEB_BROWSER=0
    JUCER_ENABLE_GPL_MODE=1
    JUCE_DISPLAY_SPLASH_SCREEN=0
    JUCE_REPORT_APP_USAGE=0
    JUCE_MODAL_LOOPS_PERMITTED=1
    JUCE_STRICT_REFCOUNTEDPOINTER=1)

cmake preprocessor definitions should be:

target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
    JUCE_PLUGINHOST_AU=1
    JUCE_PLUGINHOST_LADSPA=1
    JUCE_PLUGINHOST_VST3=1
    JUCE_USE_CURL=0
    JUCE_WEB_BROWSER=0
    JUCER_ENABLE_GPL_MODE=1
    JUCE_DISPLAY_SPLASH_SCREEN=0
    JUCE_REPORT_APP_USAGE=0
    JUCE_MODAL_LOOPS_PERMITTED=1
    JUCE_STRICT_REFCOUNTEDPOINTER=1
    TRACKTION_ENABLE_TIMESTRETCH_SOUNDTOUCH=1
    TRACKTION_BUILD_RUBBERBAND=1)

Second, Rubberband support does not compile on Windows using either a statically linked library or building from source because of the way Rubberband uses calls to std::min and std::max. This post describes the issue. Basically, windows.h has defined min/max macros since before C++ standardization so they collide in this case.

Here is the fix:

/**
    Avoids collisions of windows.h 'min' and 'max' macros with Rubberband's
    use of 'std::min' and 'std::max'.
*/
#if JUCE_WINDOWS
 #define NOMINMAX
#endif

Placing the above snippet at the top of tracktion_TimeStretch.h fixes the issue.

Cheers.

meverett commented 2 years ago

This was fixed here. Thanks!