Skip to content

Commit

Permalink
Merge pull request sonic-pi-net#2214 from cmaughan/feature/aubio_build
Browse files Browse the repository at this point in the history
Fixing Onset by building Aubio
  • Loading branch information
samaaron authored Feb 2, 2020
2 parents 72cd597 + b69256d commit 79f2eb4
Show file tree
Hide file tree
Showing 2,302 changed files with 527,471 additions and 14 deletions.
15 changes: 6 additions & 9 deletions INSTALL-WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/samaaron/sonic-pi.git c:/dev/sonic-pi

## Build the UI

1) Install Qt. Qt is not something you want to try building on windows; it is much better to install - be sure to pick the 5.12.6 checkbox to get the installed libraries, and pick the 64 bit or 32 bit or both options for msvc. Note that this not on by default!
1) Install Qt. Qt is not something you want to try building on windows; it is much better to install - be sure to pick the 5.14.1 checkbox to get the installed libraries, and pick the 64 bit or 32 bit or both options for msvc. Note that this not on by default!
After install, setup an environment variable to point to the install location. I like to use Rapid Environment Editor to setup these variables permanently (https://www.rapidee.com/en/about). Otherwise the setx command can make global variables, but the command line needs to be restarted afterwards. The current recommended version is 5.14.1, but other recent versions should work.
The 32 bit variant of the variable is only needed for 32 bit builds
```
Expand All @@ -24,8 +24,8 @@ setx QT_INSTALL_LOCATION32 C:\Qt\Qt5.14.1\5.14.1\msvc2017 (restart command promp

2) Install the latest CMake http://www.cmake.org/download. This is a build tool that is required

3) Some ruby is needed to run the translations and generate the help headers before the main build; so install the gems and do the one-time patch to aubio, which is required on windows.
Install Ruby from http://rubyinstaller.org/downloads. Get the version with the devkit, 64 or 32 bit, depending on your platform:
3) Some ruby is needed to run the translations and generate the help headers before the main build; so install the gems.
Install Ruby from http://rubyinstaller.org/downloads. Get the version with the devkit, 64 or 32 bit, depending on your platform. You should update aubio to 3.3 if you have an older version.
```
https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-devkit-2.6.5-1-x64.exe
gem install win32-process
Expand All @@ -37,15 +37,11 @@ Run a console as administrator. Add a link to Ruby:
cd c:\dev\sonic-pi\app\server\native
mklink /d ruby c:\Ruby25-x64
```
Download aubio from https://aubio.org/download (choose the aubio-0.x.x-win64.zip or the win32 variant), copy the DLLs into a folder on your machine and set an environment variable to point to it:
```
setx AUBIO_LIB c:\path_to_aubio_dll\libaubio-5.dll (restart your command prompt)
```

4) Build the Application by running the prebuild first, then config. These tools are in the app/gui/qt folder.
4) Build the Application by running the prebuild first, then config. These tools are in the app/gui/qt folder. Note: If you have previously installed libaubio5-dll, or set the AUBIO_LIB environment variable, now is the time to remove the dll and remove the variable; the prebuild on windows will make and install the correct library for you.
```
cd app/gui/qt
prebuild.bat OR prebuild32.bat (to make the translations from ruby)
prebuild.bat OR prebuild32.bat (to make the external components and translations from ruby)
config.bat OR config32.bat (to make a project file)
cd build OR build32
EITHER:
Expand Down Expand Up @@ -79,5 +75,6 @@ Run C:\dev\sonic-pi\app\gui\qt\build\Release\sonic-pi.exe or build32\Release\son
- Error logs are written to %USERPROFILE%/.sonic-pi/logs, and are useful to diagnose any startup problems.
- If a rebuild errors at the final stage of copying files, or you are otherwise having trouble starting sonic pi, there is killprocess.bat to remove sonic pi from memory. This will also kill supercollider if it has been left running.- 32bit and 64bit don't mix. Build the one you want in a clean tree. Make sure you also install all the right 32/64 bit components to match your build. 64 bit is recommended on modern machines.
- `cd %QT_INSTALL_LOCATION%` will take you to the directory you have set for that environment variable - a good way to check you have set it up correctly
- You should find a libaubio-5.dll in your native/ruby/bin folder, if the prebuild has worked correctly. This is required for the onset feature.


7 changes: 4 additions & 3 deletions app/gui/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER Automoc)
find_package(Qt5 COMPONENTS Core Widgets Gui Concurrent Network OpenGL PrintSupport Xml Svg REQUIRED)
find_package(Threads REQUIRED)

add_subdirectory(external)
# We build scintilla as part of the main project to make it easy to debug/fix
add_subdirectory(external/QScintilla-2.11.4)

set(APP_NAME sonic-pi)

Expand Down Expand Up @@ -153,8 +154,8 @@ if(WIN32)
# Copy the built osmid files to the server
add_custom_command(TARGET ${APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${SONIC_PI_ROOT}/app/server/native/osmid
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/external/osmid-prefix/src/osmid-build/Release/m2o.exe ${SONIC_PI_ROOT}/app/server/native/osmid
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/external/osmid-prefix/src/osmid-build/Release/o2m.exe ${SONIC_PI_ROOT}/app/server/native/osmid)
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/external/build/osmid-prefix/src/osmid-build/Release/m2o.exe ${SONIC_PI_ROOT}/app/server/native/osmid
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/external/build/osmid-prefix/src/osmid-build/Release/o2m.exe ${SONIC_PI_ROOT}/app/server/native/osmid)
endif() # Win32

# Make convenient source groups in the IDE
Expand Down
114 changes: 112 additions & 2 deletions app/gui/qt/external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Make a release build of osmid
# This CMakeLists builds all the external libraries required for a Sonic Pi
cmake_minimum_required(VERSION 3.12)

message(STATUS " Aubio Builder")

project(AubioBuilder
LANGUAGES CXX C
VERSION 1.0.0
)

# Osmid
include(ExternalProject)
ExternalProject_Add(osmid
PREFIX osmid-prefix
Expand All @@ -7,5 +17,105 @@ ExternalProject_Add(osmid
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
)

add_subdirectory(QScintilla-2.11.4)
ExternalProject_Add(ogg
PREFIX ogg-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ogg-1.3.4

INSTALL_DIR ${CMAKE_BINARY_DIR}/ogg-package
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/ogg-package
-DBUILD_TESTING=OFF
)

ExternalProject_Add(flac
PREFIX flac-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/flac_1_3_3
DEPENDS ogg

CMAKE_ARGS -DOGG_ROOT=${CMAKE_BINARY_DIR}/ogg-package
-DBUILD_CXXLIBS=OFF
-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=OFF

INSTALL_DIR ${CMAKE_BINARY_DIR}/flac-package
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/flac-package
)

ExternalProject_Add(opus
PREFIX opus-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/opus-1.2
DEPENDS ogg

CMAKE_ARGS -DOGG_ROOT=${CMAKE_BINARY_DIR}/ogg-package
-DBUILD_PROGRAMS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF

INSTALL_DIR ${CMAKE_BINARY_DIR}/opus-package
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/opus-package
)

ExternalProject_Add(vorbis
PREFIX vorbis-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/vorbis-1.3.4
DEPENDS ogg

CMAKE_ARGS -DOGG_ROOT=${CMAKE_BINARY_DIR}/ogg-package
-DBUILD_PROGRAMS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF

INSTALL_DIR ${CMAKE_BINARY_DIR}/vorbis-package
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/vorbis-package
)

ExternalProject_Add(libsndfile
PREFIX libsndfile-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/libsndfile
DEPENDS flac vorbis opus

CMAKE_ARGS
-DBUILD_PROGRAMS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
-DBUILD_REGTEST=OFF
-DFLAC_ROOT=${CMAKE_BINARY_DIR}/flac-package
-DPC_OGG_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/ogg-package/include
-DPC_OGG_LIBRARY_DIRS=${CMAKE_BINARY_DIR}/ogg-package/lib
-DPC_FLAC_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/flac-package/include
-DPC_FLAC_LIBRARY_DIRS=${CMAKE_BINARY_DIR}/flac-package/lib
-DPC_VORBIS_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/include
-DPC_VORBIS_LIBRARY_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/lib
-DPC_VORBISENC_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/include
-DPC_VORBISENC_LIBRARY_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/lib
-DPC_OPUS_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/opus-package/include
-DPC_OPUS_LIBRARY_DIRS=${CMAKE_BINARY_DIR}/opus-package/lib

INSTALL_DIR ${CMAKE_BINARY_DIR}/libsndfile-package
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/libsndfile-package
)

ExternalProject_Add(Aubio
PREFIX aubio-prefix
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/aubio
DEPENDS libsndfile

CMAKE_ARGS -DLIBSNDFILE_INCLUDE_DIR=${CMAKE_BINARY_DIR}/libsndfile-package/include
-DLIBSNDFILE_LIBRARY_DIR=${CMAKE_BINARY_DIR}/libsndfile-package/lib
-DLIBOGG_LIBRARY_DIR=${CMAKE_BINARY_DIR}/ogg-package/lib
-DLIBVORBIS_LIBRARY_DIR=${CMAKE_BINARY_DIR}/vorbis-package/lib
-DLIBOPUS_LIBRARY_DIR=${CMAKE_BINARY_DIR}/opus-package/lib
-DLIBFLAC_LIBRARY_DIR=${CMAKE_BINARY_DIR}/flac-package/lib

-DPC_OGG_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/ogg-package/include
-DPC_VORBIS_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/include
-DPC_VORBISENC_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/vorbis-package/include
-DPC_OPUS_INCLUDE_DIRS=${CMAKE_BINARY_DIR}/opus-package/include
INSTALL_COMMAND ""
)

# Kick off a generation by making a dummy/empty project
add_library(AubioBuilder STATIC externals.cpp)

# Dependency ensures the externals are built
add_dependencies(AubioBuilder Aubio)

78 changes: 78 additions & 0 deletions app/gui/qt/external/aubio/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# appveyor configuration. See http://www.appveyor.com/docs/appveyor-yml
# and http://www.appveyor.com/docs/installed-software#python

environment:

matrix:

# pre-installed python version, see:
# http://www.appveyor.com/docs/installed-software#python
- PYTHONDIR: C:\Python27
PYTHON_VERSION: 2.7.x
PYTHON_ARCH: 32

- PYTHONDIR: C:\Python27-x64
PYTHON_VERSION: 2.7.x
PYTHON_ARCH: 64

- PYTHONDIR: C:\Python35
PYTHON_VERSION: 3.5.x
PYTHON_ARCH: 32

- PYTHONDIR: C:\Python35-x64
PYTHON_VERSION: 3.5.x
PYTHON_ARCH: 64

- PYTHONDIR: C:\Python36
PYTHON_VERSION: 3.6.x
PYTHON_ARCH: 32

- PYTHONDIR: C:\Python36-x64
PYTHON_VERSION: 3.6.x
PYTHON_ARCH: 64

- PYTHONDIR: C:\Python37
PYTHON_VERSION: 3.7.x
PYTHON_ARCH: 32

- PYTHONDIR: C:\Python37-x64
PYTHON_VERSION: 3.7.x
PYTHON_ARCH: 64

install:
- ECHO "Installed SDKs:"
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""

- "SET PATH=%PYTHONDIR%;%PYTHONDIR%\\Scripts;%PATH%"

# Check that we have the expected version and architecture for Python
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""

- "python -m pip install --disable-pip-version-check --user --upgrade pip"
- "python -m pip install --upgrade setuptools"

# We need wheel installed to build wheels
- "python -m pip install wheel"

- "pip install -r requirements.txt"

before_build:
- "bash scripts/get_waf.sh"

build_script:
# also build libaubio with waf
- python waf configure build install --verbose --msvc_version="msvc 14.0"
# clean before building python package
- python waf distclean
# build, upload and install wheel (inspired by numpy's appveyor)
- ps: |
pip wheel -v -v -v --wheel-dir=dist .
ls dist -r | Foreach-Object {
Push-AppveyorArtifact $_.FullName
pip install $_.FullName
}
test_script:
- "python python\\demos\\demo_create_test_sounds.py"
- "pytest --verbose"
3 changes: 3 additions & 0 deletions app/gui/qt/external/aubio/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
branch = True
source = aubio
54 changes: 54 additions & 0 deletions app/gui/qt/external/aubio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
*.pyc
*.~[0-9]~
*.swp

# gcov generated files
*.gcno
*.gcda
python/lib/aubio/_aubio.*.so
.coverage

# ignore compiled examples
RE:examples/[a-z]*

# ignore compiled test programs
RE:tests/src/test-[a-z-_]*$
RE:tests/cpp/test-[a-z-_]*$

# only sgml manpages count
doc/*.1

# cachegrind/callgrind stuff
**/cachegrind.out.[0-9]*
**/callgrind.out.[0-9]*

# waf stuff
.lock-waf*
.waf-*
waf
waflib
build/

# doxygen
doc/web/
doc/full/
doc/_build/

python/gen
python/dist
python/MANIFEST
python/*.db
python/*.wav

pip-delete-this-directory.txt

aubio-*.tar.bz2
aubio-*.zip
dist/*.tar.gz
dist/*.whl

# test sounds
python/tests/sounds
aubio.egg-info
.eggs
.cache
Loading

0 comments on commit 79f2eb4

Please sign in to comment.