From d5f608ffaf37e5b8a1ed5d9b7ce5f544b0a42447 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 14:36:46 +0200 Subject: [PATCH 01/10] Run qmake2cmake command Command used: qmake2cmake_all . --min-qt-version 5.15 --- CMakeLists.txt | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3a6d9e6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,102 @@ +cmake_minimum_required(VERSION 3.16) +project(samplebrain VERSION 1.0 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Set up AUTOMOC and some sensible defaults for runtime execution +# When using Qt 6.3, you can replace the code block below with +# qt_standard_project_setup() +set(CMAKE_AUTOMOC ON) +include(GNUInstallDirs) +set(CMAKE_AUTOUIC ON) + +find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui Widgets) + +qt_add_executable(samplebrain WIN32 MACOSX_BUNDLE + app/MainWindow.cpp app/MainWindow.h + app/audio_thread.cpp + app/feedback.cpp + app/process_thread.cpp + app/qtmain.cpp + app/sound_items.cpp + brain/src/aquila/filter/MelFilter.cpp + brain/src/aquila/filter/MelFilterBank.cpp + brain/src/aquila/transform/Dct.cpp + brain/src/block.cpp + brain/src/block_stream.cpp + brain/src/brain.cpp + brain/src/fft.cpp + brain/src/mfcc.cpp + brain/src/renderer.cpp + brain/src/search_params.cpp + brain/src/spiralcore/OSC_server.cpp + brain/src/spiralcore/allocator.cpp + brain/src/spiralcore/audio.cpp + brain/src/spiralcore/command_ring_buffer.cpp + brain/src/spiralcore/portaudio_client.cpp + brain/src/spiralcore/ring_buffer.cpp + brain/src/spiralcore/sample.cpp + brain/src/spiralcore/stream.cpp + brain/src/status.cpp + brain/src/window.cpp + gui/samplebrain.ui +) +target_include_directories(samplebrain PRIVATE + . + /opt/homebrew/include + /usr/local/include + 2 + brain/src +) + +target_link_libraries(samplebrain PRIVATE + # Remove: L.. + # Remove: L/opt/homebrew/lib + # Remove: L/usr/local/lib + Qt::Core + Qt::Gui + Qt::Widgets + dl + fftw3 + lo + m + portaudio + pthread + sndfile +) + +target_compile_options(samplebrain + -O3 + -Wall + -Wno-unused + -std=c++11 +) + + +# Resources: +set(samplebrain_resource_files + "app/images/at.png" + "app/images/pause.png" + "app/images/play.png" + "app/images/record.png" + "app/images/stop.png" +) + +qt_add_resources(samplebrain "samplebrain" + PREFIX + "/images" + BASE + "app" + FILES + ${samplebrain_resource_files} +) + +install(TARGETS samplebrain + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +# Consider using qt_generate_deploy_app_script() for app deployment if +# the project can use Qt 6.3. In that case rerun qmake2cmake with +# --min-qt-version=6.3. From c188cb744ce6148ab0ff7496dfd31a76f1fb163d Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 14:38:31 +0200 Subject: [PATCH 02/10] Fix CMakeLists syntax target_compile_options requires the PUBLIC/PRIVATE keyword. I don't know why the qmake2cmake script doesn't provide the correct syntax here... --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a6d9e6..fc99009 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ target_link_libraries(samplebrain PRIVATE sndfile ) -target_compile_options(samplebrain +target_compile_options(samplebrain PUBLIC -O3 -Wall -Wno-unused From 24088c4904a4e1200abf9323bafd7ebbbdf5e54c Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 14:40:34 +0200 Subject: [PATCH 03/10] Ignore build folder This should cover all files generated by the build system... --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b7e2626..378eac2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -*.*~ -*.o - +build From 5453d8694d6009ed1dff8c4b78afa397db493e8f Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 15:50:50 +0200 Subject: [PATCH 04/10] Fix path to .ui file --- app/MainWindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/MainWindow.h b/app/MainWindow.h index 90abd9d..c83e39a 100644 --- a/app/MainWindow.h +++ b/app/MainWindow.h @@ -18,7 +18,7 @@ #include #include #include -#include "ui_samplebrain.h" +#include "../gui/ui_samplebrain.h" #include #include From 2ce3fed1e15a80b4d8ffaa61de6d253e722c9b36 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 15:57:14 +0200 Subject: [PATCH 05/10] Add fftw3 dependency --- CMakeLists.txt | 2 ++ Dependencies.cmake | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Dependencies.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fc99009..79d767e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(samplebrain VERSION 1.0 LANGUAGES CXX) +include(Dependencies.cmake) + set(CMAKE_INCLUDE_CURRENT_DIR ON) # Set up AUTOMOC and some sensible defaults for runtime execution diff --git a/Dependencies.cmake b/Dependencies.cmake new file mode 100644 index 0000000..0b6a94f --- /dev/null +++ b/Dependencies.cmake @@ -0,0 +1,17 @@ +################################################################################ +# FetchContent +################################################################################ + +include(FetchContent) + +################################################################################ +# fftw3 +################################################################################ + +FetchContent_Declare( + fftw3 + URL http://fftw.org/fftw-3.3.10.tar.gz + URL_HASH MD5=8ccbf6a5ea78a16dbc3e1306e234cc5c) +FetchContent_MakeAvailable(fftw3) + +include_directories(${fftw3_SOURCE_DIR}/api) From 3234bd155713ef528d3731f3e8192a180e9ac4a7 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 15:58:36 +0200 Subject: [PATCH 06/10] Add liblo dependency --- CMakeLists.txt | 2 +- Dependencies.cmake | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d767e..90e9ece 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(samplebrain PRIVATE Qt::Widgets dl fftw3 - lo + lo_shared m portaudio pthread diff --git a/Dependencies.cmake b/Dependencies.cmake index 0b6a94f..909eac1 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -15,3 +15,15 @@ FetchContent_Declare( FetchContent_MakeAvailable(fftw3) include_directories(${fftw3_SOURCE_DIR}/api) + +################################################################################ +# liblo +################################################################################ + +FetchContent_Declare( + liblo + URL http://downloads.sourceforge.net/liblo/liblo-0.31.tar.gz + URL_HASH MD5=14378c1e74c58e777fbb4fcf33ac5315) +FetchContent_MakeAvailable(liblo) + +add_subdirectory(${liblo_SOURCE_DIR}/cmake) From 2b39aef393cc2fd295225c423815118eccc71a07 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 15:58:50 +0200 Subject: [PATCH 07/10] Add portaudio dependency --- CMakeLists.txt | 2 +- Dependencies.cmake | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90e9ece..8f42918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(samplebrain VERSION 1.0 LANGUAGES CXX) +project(samplebrain VERSION 1.0 LANGUAGES C CXX) include(Dependencies.cmake) diff --git a/Dependencies.cmake b/Dependencies.cmake index 909eac1..1fd857b 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -27,3 +27,13 @@ FetchContent_Declare( FetchContent_MakeAvailable(liblo) add_subdirectory(${liblo_SOURCE_DIR}/cmake) + +################################################################################ +# PortAudio +################################################################################ + +FetchContent_Declare( + portaudio + URL http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz + URL_HASH MD5=ad319249932c6794b551d954b8844402) +FetchContent_MakeAvailable(portaudio) From ba5989539d8b73f96f288744beceb3678277d736 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 16:05:25 +0200 Subject: [PATCH 08/10] Add libsndfile dependency --- Dependencies.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Dependencies.cmake b/Dependencies.cmake index 1fd857b..848c56a 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -37,3 +37,13 @@ FetchContent_Declare( URL http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz URL_HASH MD5=ad319249932c6794b551d954b8844402) FetchContent_MakeAvailable(portaudio) + +################################################################################ +# libsndfile +################################################################################ + +FetchContent_Declare( + libsndfile + GIT_REPOSITORY https://github.com/libsndfile/libsndfile + GIT_TAG 1.1.0) +FetchContent_MakeAvailable(libsndfile) From 4f6178db712964d839c766a9ae3cd352a8cf857f Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 16:08:50 +0200 Subject: [PATCH 09/10] Update README - Add info about installing cmake - Change build instructions from qmake to cmake - Remove info about installing deps in README We don't need to do this anymore. CMake will do it automatically at configure-time! --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e2ea65d..749f63a 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,9 @@ If you'd like the right font, optionally: # Building from source ## Linux (Ubuntu) -Install libraries for the sample engine (use brew on mac, MinGW on win): +Install cmake: - $ sudo apt install libsndfile1-dev portaudio19-dev liblo-dev libfftw3-dev + $ sudo apt install cmake Install dependencies for the interface: @@ -101,9 +101,9 @@ Build & run it: $ samplebrain ## Mac -Install libraries for sample engine: +Install cmake: - $ brew install fftw portaudio liblo libsndfile + $ brew install cmake Install dependencies for the interface: @@ -114,8 +114,8 @@ Build & run it: $ mkdir build $ cd build - $ qmake .. - $ make + $ cmake .. + $ cmake --build . `samplebrain.app` should then be in the app folder for you to run. From 2a9073daa0e64e29481b88335bb7a68d0a2f2918 Mon Sep 17 00:00:00 2001 From: fshstk Date: Fri, 30 Sep 2022 16:09:25 +0200 Subject: [PATCH 10/10] Remove Qt .pro file CMakeLists.txt now does everything we need --- samplebrain.pro | 68 ------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 samplebrain.pro diff --git a/samplebrain.pro b/samplebrain.pro deleted file mode 100644 index 22799fb..0000000 --- a/samplebrain.pro +++ /dev/null @@ -1,68 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Sun Jul 5 17:49:45 2015 -###################################################################### - -TEMPLATE = app -TARGET = samplebrain -DEPENDPATH += . 2 -INCLUDEPATH += . 2 - -QT += core gui widgets - -# Input -HEADERS += app/MainWindow.h - -FORMS += gui/samplebrain.ui - -SOURCES += app/MainWindow.cpp \ - app/sound_items.cpp \ - app/audio_thread.cpp \ - app/process_thread.cpp \ - app/feedback.cpp \ - app/qtmain.cpp \ - brain/src/block.cpp \ - brain/src/brain.cpp \ - brain/src/fft.cpp \ - brain/src/mfcc.cpp \ - brain/src/renderer.cpp \ - brain/src/search_params.cpp \ - brain/src/status.cpp \ - brain/src/window.cpp \ - brain/src/block_stream.cpp \ - brain/src/aquila/filter/MelFilterBank.cpp \ - brain/src/aquila/filter/MelFilter.cpp \ - brain/src/aquila/transform/Dct.cpp \ - brain/src/spiralcore/sample.cpp \ - brain/src/spiralcore/ring_buffer.cpp \ - brain/src/spiralcore/command_ring_buffer.cpp \ - brain/src/spiralcore/portaudio_client.cpp \ - brain/src/spiralcore/audio.cpp \ - brain/src/spiralcore/OSC_server.cpp \ - brain/src/spiralcore/allocator.cpp \ - brain/src/spiralcore/stream.cpp - -INCLUDEPATH += brain/src -INCLUDEPATH += /usr/local/include -INCLUDEPATH += /opt/homebrew/include -LIBS += -L.. -L/usr/local/lib -L/opt/homebrew/lib -lportaudio -lfftw3 -lsndfile -llo -ldl -lpthread -lm - -QMAKE_CXXFLAGS += -O3 -Wall -Wno-unused -std=c++11 - -# assets -RESOURCES = app/samplebrain.qrc -ICON = desktop/samplebrain.icns - -PREFIX = $$(PREFIX) -isEmpty(PREFIX) { - PREFIX = /usr -} - -unix:desktopfile.path = $$PREFIX/share/applications/ -unix:desktopfile.files = desktop/samplebrain.desktop -unix:iconfile.path = $$PREFIX/share/icons/hicolor/scalable/apps -unix:iconfile.files = desktop/samplebrain.svg -unix:metainfofile.path = $$PREFIX/share/metainfo -unix:metainfofile.files = desktop/org.thentrythis.Samplebrain.metainfo.xml - -target.path = $$PREFIX/bin -INSTALLS += target desktopfile iconfile metainfofile