diff --git a/CMakeLists.txt b/CMakeLists.txt index de6bdf03..5f693c7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,28 +54,34 @@ cmake_print_variables(CMAKE_PREFIX_PATH) set(CMAKE_CXX_STANDARD 11) set(CMAKE_MACOSX_RPATH 1) -#------------------------------------------------------------------------------- -# Shared compiler flags. -#------------------------------------------------------------------------------- -if (NOT MSVC) +if (MSVC) + #------------------------------------------------------------------------------- + # Windows Visual C: Enable parallelisation + #------------------------------------------------------------------------------- + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") +else() + #------------------------------------------------------------------------------- + # GCC/Clang: Enable strict compiler warnings + #------------------------------------------------------------------------------- add_compile_options( -pedantic -fPIC -Wall ) -endif() -#------------------------------------------------------------------------------- -# Hide superfluous compiler warnings on macOS -#------------------------------------------------------------------------------- -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - add_compile_options( - -Wno-gnu-zero-variadic-macro-arguments - -Wno-vla-extension - ) + #------------------------------------------------------------------------------- + # Hide superfluous compiler warnings on macOS + #------------------------------------------------------------------------------- + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_compile_options( + -Wno-gnu-zero-variadic-macro-arguments + -Wno-vla-extension + ) + endif() endif() + include_directories( /usr/local/include /opt/homebrew/include @@ -86,13 +92,25 @@ include_directories( if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") message("Building in debug mode") - add_compile_options(-ggdb3 -O0 -DDEBUG) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + add_compile_options(-O1) + else() + add_compile_options(-ggdb3 -O0 -DDEBUG) + endif() elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release") message("Building in release mode") - add_compile_options(-O3 -funroll-loops) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + add_compile_options(-O2) + else() + add_compile_options(-O3 -funroll-loops) + endif() else() message("Building in dev mode") - add_compile_options(-O0) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + add_compile_options(-O1) + else() + add_compile_options(-O0) + endif() endif() #------------------------------------------------------------------------------- @@ -129,34 +147,31 @@ add_library(signalflow SHARED ${SRC}) #------------------------------------------------------------------------------- add_compile_definitions(SIGNALFLOW_VERSION="${SIGNALFLOW_VERSION}") -set(SNDFILE_BUILD_DIR "" CACHE PATH "Path to build sndfile library (will use find_library if blank)") - -if (SNDFILE_BUILD_DIR) - set(SNDFILE_INCLUDE_DIR "${SNDFILE_BUILD_DIR}/../include" CACHE PATH "Path to sndfile include directory (ignored if SNDFILE_BUILD_DIR is blank") +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(SNDFILE_BINARY_DIR "${PROJECT_SOURCE_DIR}/../libsndfile-1.2.2-win64" CACHE PATH "For Windows, path to downloaded sndfile directory") add_definitions(-DHAVE_SNDFILE) - target_link_libraries(signalflow "${SNDFILE_BUILD_DIR}/sndfile") - include_directories(signalflow "${SNDFILE_BUILD_DIR}/include/") - include_directories(signalflow "${SNDFILE_INCLUDE_DIR}/") + target_link_libraries(signalflow "${SNDFILE_BINARY_DIR}/lib/sndfile.lib") + include_directories(signalflow "${SNDFILE_BINARY_DIR}/include/") else() find_library(SNDFILE sndfile) if (SNDFILE) message("Found sndfile") add_definitions(-DHAVE_SNDFILE) target_link_libraries(signalflow ${SNDFILE}) - else() - message(SEND_ERROR "Couldn't find libsndfile") + else() + message(FATAL_ERROR "Couldn't find libsndfile") endif() endif() if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(FFTW_BUILD_DIR "" CACHE PATH "Path to prebuilt FFTW library (will use find_library if blank)") + set(FFTW_BUILD_DIR "${PROJECT_SOURCE_DIR}/../fftw-3.3.5-dll64" CACHE PATH "Path to prebuilt FFTW library (will use find_library if blank)") if (FFTW_BUILD_DIR) include_directories("${FFTW_BUILD_DIR}") add_definitions(-DFFT_FFTW) target_link_libraries(signalflow - "${FFTW_BUILD_DIR}/libfftw3-3" - "${FFTW_BUILD_DIR}/libfftw3f-3" - "${FFTW_BUILD_DIR}/libfftw3l-3" + "${FFTW_BUILD_DIR}/libfftw3-3.lib" + "${FFTW_BUILD_DIR}/libfftw3f-3.lib" + "${FFTW_BUILD_DIR}/libfftw3l-3.lib" ) else() find_library(FFTW3F fftw3f) @@ -201,4 +216,4 @@ endif() # Install shared lib and all includes #------------------------------------------------------------------------------- install(TARGETS signalflow DESTINATION lib) -install(DIRECTORY source/include/signalflow DESTINATION include) +install(DIRECTORY source/include/signalflow DESTINATION include) \ No newline at end of file diff --git a/examples/euclidean-rhythm-example.py b/examples/euclidean-rhythm-example.py index 4cc182ed..48a302af 100755 --- a/examples/euclidean-rhythm-example.py +++ b/examples/euclidean-rhythm-example.py @@ -68,7 +68,7 @@ def __init__(self, input=0, delay_time=1/8, feedback=0.7, wet=0.3): pingpong = PingPongDelayPatch(mix) pingpong.play() - graph.wait() + graph.wait(20) if __name__ == "__main__": diff --git a/examples/hello-world-example.py b/examples/hello-world-example.py index 33702f64..1412ffb4 100755 --- a/examples/hello-world-example.py +++ b/examples/hello-world-example.py @@ -24,7 +24,7 @@ def main(): # Play the #------------------------------------------------------------------------ graph.play(stereo) - graph.wait() + graph.wait(2) if __name__ == "__main__": main() \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index b845b0e4..7712808a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,13 +23,6 @@ install_requires = numpy package_dir = = auxiliary/libs -packages = - signalflow-stubs - signalflow_midi - signalflow_cli - signalflow_examples - signalflow_visualisation - signalflow_analysis include_package_data = true [options.extras_require] diff --git a/setup.py b/setup.py index cf15e948..9a90f222 100644 --- a/setup.py +++ b/setup.py @@ -69,6 +69,7 @@ def build_extension(self, ext): signalflow_package_data = ['*.pyd'] setup( + packages=signalflow_packages, ext_modules=[CMakeExtension('signalflow')], cmdclass=dict(build_ext=CMakeBuild), ) diff --git a/source/include/signalflow/node/io/output/miniaudio.h b/source/include/signalflow/node/io/output/miniaudio.h index c2e03096..460b37ec 100644 --- a/source/include/signalflow/node/io/output/miniaudio.h +++ b/source/include/signalflow/node/io/output/miniaudio.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include "abstract.h" diff --git a/source/src/core/graph.cpp b/source/src/core/graph.cpp index 0182159a..728b3eb1 100644 --- a/source/src/core/graph.cpp +++ b/source/src/core/graph.cpp @@ -16,7 +16,7 @@ #include #include -#include +//#include namespace signalflow { @@ -169,6 +169,7 @@ void AudioGraph::start() std::string recording_filename = recordings_dir + "/signalflow-" + timestamp_str + ".wav"; // TODO: This is all very POSIX-specific and won't work on Windows + /* struct stat st; if (stat(SIGNALFLOW_USER_DIR.c_str(), &st) == -1) { @@ -186,6 +187,7 @@ void AudioGraph::start() throw std::runtime_error("AudioGraph: Failed creating recordings directory for auto_record (" + recordings_dir + ")"); } } + */ this->start_recording(recording_filename, this->output->get_num_input_channels()); } } diff --git a/source/src/python/graph.cpp b/source/src/python/graph.cpp index e1ff39c1..678ae356 100644 --- a/source/src/python/graph.cpp +++ b/source/src/python/graph.cpp @@ -119,27 +119,27 @@ void init_python_graph(py::module &m) .def("wait", [](AudioGraph &graph) { /*-------------------------------------------------------------------------------- - * Interruptible wait - * https://pybind11.readthedocs.io/en/stable/faq.html#how-can-i-properly-handle-ctrl-c-in-long-running-functions - *-------------------------------------------------------------------------------*/ + * Interruptible wait + * https://pybind11.readthedocs.io/en/stable/faq.html#how-can-i-properly-handle-ctrl-c-in-long-running-functions + *-------------------------------------------------------------------------------*/ for (;;) { if (PyErr_CheckSignals() != 0) throw py::error_already_set(); /*-------------------------------------------------------------------------------- - * Release the GIL so that other threads can do processing. - *-------------------------------------------------------------------------------*/ + * Release the GIL so that other threads can do processing. + *-------------------------------------------------------------------------------*/ py::gil_scoped_release release; + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + if (graph.has_raised_audio_thread_error()) break; } }) .def( "wait", [](AudioGraph &graph, float timeout_seconds) { - timeval tv; - gettimeofday(&tv, NULL); - double t0 = tv.tv_sec + tv.tv_usec / 1000000.0; + double t0 = signalflow_timestamp(); for (;;) { @@ -148,8 +148,7 @@ void init_python_graph(py::module &m) if (timeout_seconds) { - gettimeofday(&tv, NULL); - double t1 = tv.tv_sec + tv.tv_usec / 1000000.0; + double t1 = signalflow_timestamp(); if (t1 - t0 > timeout_seconds) { break; @@ -161,6 +160,8 @@ void init_python_graph(py::module &m) *-------------------------------------------------------------------------------*/ py::gil_scoped_release release; + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + if (graph.has_raised_audio_thread_error()) break; }