Skip to content

Commit 80cdd7a

Browse files
authored
Merge pull request #2824 from sonic-pi-net/link
Add support for Ableton Link
2 parents 4cff551 + cdfec4c commit 80cdd7a

File tree

2,483 files changed

+490733
-1482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,483 files changed

+490733
-1482
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,7 @@ etc/synthdefs/designs/overtone/sonic-pi/native
145145

146146
# Visual Studio settings folder.
147147
.vs
148+
149+
150+
# Erlang priv dir (for dlls)
151+
app/server/erlang/tau/priv/*

BUILD-MAC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ few dependencies:
3939

4040
1. Xcode (12.1+) and command line tools
4141
2. Homebrew
42-
3. All other dependencies - Qt (5.15+), CMake (3.18+)
42+
3. All other dependencies - Qt5 (5.15+), CMake (3.18+)
4343

4444
### 1.1 Install Xcode
4545

@@ -68,7 +68,7 @@ Once you have Homebrew installed, pulling in the rest of the
6868
dependencies is a couple of lines to execute within a terminal:
6969

7070
```
71-
brew install qt cmake
71+
brew install qt@5 cmake
7272
7373
```
7474

app/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1414
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
1515

1616
if(APPLE)
17-
set(CMAKE_OSX_DEPLOYMENT_TARGET '10.13')
17+
set(CMAKE_OSX_DEPLOYMENT_TARGET '10.14')
1818
endif()
1919

2020
set(APP_ROOT ${CMAKE_CURRENT_LIST_DIR})

app/external/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This CMakeLists builds all the external libraries required for a Sonic Pi
2-
cmake_minimum_required(VERSION 3.12)
2+
cmake_minimum_required(VERSION 3.13)
33

44
message(STATUS " Aubio Builder")
55

@@ -11,7 +11,7 @@ project(AubioBuilder
1111

1212
include(ExternalProject)
1313

14-
set(CMAKE_OSX_DEPLOYMENT_TARGET '10.13')
14+
set(CMAKE_OSX_DEPLOYMENT_TARGET '10.14')
1515

1616
# sp_midi
1717
ExternalProject_Add(sp_midi
@@ -24,6 +24,16 @@ ExternalProject_Add(sp_midi
2424
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
2525
)
2626

27+
ExternalProject_Add(sp_link
28+
PREFIX sp_link-prefix
29+
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/sp_link
30+
INSTALL_COMMAND ""
31+
CMAKE_ARGS
32+
-DERLANG_INCLUDE_PATH=${ERLANG_INCLUDE_PATH}
33+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
34+
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
35+
)
36+
2737
ExternalProject_Add(ogg
2838
PREFIX ogg-prefix
2939
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ogg-1.3.4

app/external/linux_build_externals.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ ERLANG_INCLUDE_PATH=`erl -noinput -eval 'io:format("~s~n", [filename:join([lists
1010

1111
cmake -DERLANG_INCLUDE_PATH=${ERLANG_INCLUDE_PATH} -G "Unix Makefiles" ..
1212

13-
echo "Building sp_midi..."
14-
cmake --build . --target sp_midi
15-
cmake --build . --target aubio
13+
echo "Building external deps..."
14+
cmake --build . --config Release
1615

1716
cd "${SCRIPT_DIR}"

app/external/mac_build_externals.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ cd "${SCRIPT_DIR}/build"
99
echo "Running cmake with: ERLANG_INCLUDE_PATH=\"${SCRIPT_DIR}/../../prebuilt/macos/headers/erlang/\""
1010
cmake -G "Unix Makefiles" -D ERLANG_INCLUDE_PATH="${SCRIPT_DIR}/../../prebuilt/macos/headers/erlang/" ..
1111

12-
echo "Building sp_midi..."
13-
cmake --build . --target sp_midi
14-
echo "Building aubio onset..."
15-
cmake --build . --target aubio
12+
echo "Building external deps..."
13+
cmake --build . --config Release
1614

1715
cd "${SCRIPT_DIR}"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CMake
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
7+
BUILD_TYPE: Release
8+
9+
jobs:
10+
build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
16+
17+
# The CMake configure and build commands are platform agnostic and should work equally
18+
# well on Windows or Mac. You can convert this to a matrix build if you need
19+
# cross-platform coverage.
20+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Fetch packages (Linux)
26+
if: runner.os == 'Linux'
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install erlang-dev
30+
31+
- name: Fetch packages (Mac)
32+
continue-on-error: true
33+
if: runner.os == 'macOS'
34+
run: |
35+
export HOMEBREW_NO_INSTALL_CLEANUP=1
36+
brew update
37+
brew install erlang
38+
39+
- name: Fetch packages (Windows)
40+
if: runner.os == 'Windows'
41+
run: choco install erlang
42+
43+
# - name: Setup tmate session
44+
# if: runner.os == 'Windows'
45+
# uses: mxschmitt/action-tmate@v3
46+
# timeout-minutes: 15
47+
48+
- name: Create Build Environment
49+
# Some projects don't allow in-source building, so create a separate build directory
50+
# We'll use this as our working directory for all subsequent commands
51+
run: cmake -E make_directory ${{github.workspace}}/build
52+
53+
- name: Configure CMake
54+
# Use a bash shell so we can use the same syntax for environment variable
55+
# access regardless of the host operating system
56+
shell: bash
57+
working-directory: ${{github.workspace}}/build
58+
# Note the current convention is to use the -S and -B options here to specify source
59+
# and build directories, but this is only available with CMake 3.13 and higher.
60+
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
61+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
62+
63+
- name: Build
64+
working-directory: ${{github.workspace}}/build
65+
shell: bash
66+
# Execute the build. You can specify a specific target with "--target <NAME>"
67+
run: cmake --build . --config $BUILD_TYPE

app/external/sp_link/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.o
2+
*~
3+
build/
4+
.vscode/
5+
*.beam
6+
.vs/
7+
*.bak
8+
.#*

app/external/sp_link/CMakeLists.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
project (sp_link)
2+
cmake_minimum_required (VERSION 3.0)
3+
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
5+
6+
if(NOT MSVC)
7+
if(APPLE)
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=libc++")
9+
else(APPLE)
10+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
11+
endif(APPLE)
12+
endif(NOT MSVC)
13+
14+
15+
# If we need to change something based on this running on CI, we can use if(DEFINED ENV{GITHUB_ACTION})
16+
if(APPLE)
17+
set(ERLANG_INCLUDE_PATH "/usr/local/lib/erlang/usr/include" CACHE PATH "Path to erlang includes")
18+
elseif(UNIX)
19+
set(ERLANG_INCLUDE_PATH "/usr/lib/erlang/usr/include" CACHE PATH "Path to erlang includes")
20+
elseif(MSVC)
21+
if(DEFINED ENV{GITHUB_ACTION})
22+
set(ERLANG_INCLUDE_PATH "C:/Program Files/erl10.7/usr/include" CACHE PATH "Path to erlang includes")
23+
else()
24+
set(ERLANG_INCLUDE_PATH "C:/Program Files/erl-24.0/usr/include" CACHE PATH "Path to erlang includes")
25+
endif()
26+
endif(APPLE)
27+
28+
29+
# For Link
30+
include(${PROJECT_SOURCE_DIR}/external_libs/link/AbletonLinkConfig.cmake)
31+
#target_link_libraries(libsp_link Ableton::Link)
32+
33+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
34+
35+
if(WIN32)
36+
include_directories(${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include)
37+
elseif(APPLE)
38+
include_directories(${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include)
39+
else()
40+
include_directories(${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include)
41+
endif()
42+
43+
set(sp_link_sources
44+
src/sp_link.cpp
45+
src/sp_link_nifs.cpp
46+
src/sp_link_nif_callbacks.cpp
47+
)
48+
49+
# sp_link_sources
50+
add_library(libsp_link SHARED ${sp_link_sources})
51+
SET_TARGET_PROPERTIES(libsp_link PROPERTIES PREFIX "")
52+
53+
#check if armv7l architecture (Raspberry Pi OS 32bit) and add atomic linking if so
54+
#if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "armv7l")
55+
# message(STATUS("linking atomic for armv7l architecture"))
56+
# target_link_libraries(libsp_link atomic)
57+
#endif()
58+
59+
if(MSVC)
60+
add_definitions(-D_WIN32_WINNT=0x0600)
61+
include_directories(${ERLANG_INCLUDE_PATH})
62+
target_link_libraries(libsp_link Ableton::Link)
63+
# example test exe. Only under Windows, because on the others, the NIF functions are resolved when linked to the erlang VM, not on the library
64+
add_executable(sp_link_test src/sp_link_test.c)
65+
target_link_libraries(sp_link_test libsp_link)
66+
elseif(APPLE)
67+
add_definitions(-DNDEBUG=1)
68+
include_directories(${ERLANG_INCLUDE_PATH})
69+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined suppress -flat_namespace")
70+
set_target_properties(libsp_link PROPERTIES XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO")
71+
# set(CMAKE_EXE_LINKER_FLAGS "-framework CoreMIDI -framework CoreAudio -framework CoreFoundation -framework Accelerate -framework QuartzCore -framework AudioToolbox -framework IOKit -framework DiscRecording -framework Cocoa")
72+
target_link_libraries(libsp_link Ableton::Link "-framework CoreMIDI -framework CoreAudio -framework CoreFoundation -framework Accelerate -framework QuartzCore -framework AudioToolbox -framework IOKit -framework DiscRecording -framework Cocoa")
73+
elseif(UNIX)
74+
add_definitions(-DLINUX=1 -DNDEBUG=1)
75+
include_directories(${ERLANG_INCLUDE_PATH})
76+
target_link_libraries(libsp_link Ableton::Link)
77+
endif(MSVC)

app/external/sp_link/LICENSE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
sp_link uses link and spdlog. Please see the licenses in the respective "external_libs" directories
2+
3+
-------------------------------------------------------------------------------
4+
For sp_link itself:
5+
6+
MIT License
7+
8+
Copyright (c) 2021 Luis Lloret
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.

0 commit comments

Comments
 (0)