Skip to content

Commit 58bc8bc

Browse files
committed
Squashed 'app/external/sp_midi/' content from commit 6cdd945
git-subtree-dir: app/external/sp_midi git-subtree-split: 6cdd9452551cc677d11bb9cf043e55e9f5cfc354
0 parents  commit 58bc8bc

File tree

1,967 files changed

+396949
-0
lines changed

Some content is hidden

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

1,967 files changed

+396949
-0
lines changed

.github/workflows/cmake.yml

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 libasound2-dev librtmidi-dev 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

.gitignore

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

CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
project (sp_midi)
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+
find_package(ALSA REQUIRED)
21+
elseif(MSVC)
22+
if(DEFINED ENV{GITHUB_ACTION})
23+
set(ERLANG_INCLUDE_PATH "C:/Program Files/erl10.7/usr/include" CACHE PATH "Path to erlang includes")
24+
else()
25+
set(ERLANG_INCLUDE_PATH "C:/Program Files/erl-23.0/usr/include" CACHE PATH "Path to erlang includes")
26+
endif()
27+
endif(APPLE)
28+
29+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
30+
31+
if(WIN32)
32+
include_directories( ${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include ${PROJECT_SOURCE_DIR}/external_libs/concurrentqueue ${PROJECT_SOURCE_DIR}/external_libs)
33+
elseif(APPLE)
34+
include_directories( ${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include ${PROJECT_SOURCE_DIR}/external_libs/concurrentqueue ${PROJECT_SOURCE_DIR}/external_libs)
35+
else()
36+
include_directories(${PROJECT_SOURCE_DIR}/external_libs/spdlog-1.8.2/include ${PROJECT_SOURCE_DIR}/external_libs/concurrentqueue)
37+
endif()
38+
39+
set(sp_midi_sources
40+
src/sp_midi.cpp
41+
src/midiin.cpp
42+
src/midiout.cpp
43+
src/midicommon.cpp
44+
src/midisendprocessor.cpp
45+
src/utils.cpp
46+
)
47+
48+
if(MSVC)
49+
list(APPEND sp_midi_sources ${PROJECT_SOURCE_DIR}/external_libs/rtmidi/RtMidi.cpp)
50+
add_definitions(-D__WINDOWS_MM__)
51+
endif(MSVC)
52+
53+
if(APPLE)
54+
list(APPEND sp_midi_sources ${PROJECT_SOURCE_DIR}/external_libs/rtmidi/RtMidi.cpp)
55+
add_definitions(-D__MACOSX_CORE__)
56+
endif(APPLE)
57+
58+
# sp_midi_sources
59+
add_library(libsp_midi SHARED ${sp_midi_sources})
60+
SET_TARGET_PROPERTIES(libsp_midi PROPERTIES PREFIX "")
61+
62+
#check if armv7l architecture (Raspberry Pi OS 32bit) and add atomic linking if so
63+
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "armv7l")
64+
message(STATUS("linking atomic for armv7l architecture"))
65+
target_link_libraries(libsp_midi atomic)
66+
endif()
67+
68+
if(MSVC)
69+
add_definitions(-D_WIN32_WINNT=0x0600)
70+
include_directories(${ERLANG_INCLUDE_PATH})
71+
target_link_libraries(libsp_midi winmm)
72+
# 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
73+
add_executable(sp_midi_test src/sp_midi_test.c)
74+
target_link_libraries(sp_midi_test libsp_midi)
75+
elseif(APPLE)
76+
add_definitions(-DNDEBUG=1)
77+
include_directories(${ERLANG_INCLUDE_PATH})
78+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined suppress -flat_namespace")
79+
set_target_properties(libsp_midi PROPERTIES XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO")
80+
# set(CMAKE_EXE_LINKER_FLAGS "-framework CoreMIDI -framework CoreAudio -framework CoreFoundation -framework Accelerate -framework QuartzCore -framework AudioToolbox -framework IOKit -framework DiscRecording -framework Cocoa")
81+
target_link_libraries(libsp_midi "-framework CoreMIDI -framework CoreAudio -framework CoreFoundation -framework Accelerate -framework QuartzCore -framework AudioToolbox -framework IOKit -framework DiscRecording -framework Cocoa")
82+
elseif(UNIX)
83+
add_definitions(-DLINUX=1 -DNDEBUG=1)
84+
include_directories(${ERLANG_INCLUDE_PATH})
85+
target_link_libraries(libsp_midi pthread ${ALSA_LIBRARY} dl rtmidi)
86+
endif(MSVC)
87+

INSTALL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Build instructions
2+
sp_midi uses cmake for build management.
3+
4+
## Requisites:
5+
### Windows:
6+
* cmake (version 3.0 or later)
7+
* Microsoft Visual C++ 2019 (Community or Express editions are fine)
8+
9+
### Linux (you can normally install all these using your distribution package manager)
10+
* cmake (version 3.0 or later)
11+
* gcc compiler (4.9 or later)
12+
* ALSA development libraries
13+
14+
### Mac
15+
Don't know yet...
16+
17+
18+
## Building
19+
* go to the root directory where you have the sp_midi sources (probably where this file is)
20+
* create `build` directory, and get into it (`mkdir build`, and then `cd build`)
21+
* It is normally enough to do `cmake ..`. If cmake complains about not finding a library make sure that it is installed.
22+
* On Linux, if cmake was successful then it created the necessary Makefiles. Do `make`, and that will compile the code and create the binaries.
23+
* On Windows, if cmake was successful then it created the necessary Visual Studio solution and Project files. Open the `sp_midi.sln` file, and Build normally to create the binaries.
24+
25+

LICENSE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
sp_midi uses concurrent_queue, rtmidi and spdlog. Please see the licenses in the respective "external_libs" directories
2+
3+
-------------------------------------------------------------------------------
4+
For sp_midi itself:
5+
6+
MIT License
7+
8+
Copyright (c) 2016-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.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# sp_midi
2+
3+
sp_midi aims to provide a lightweight, portable, easy to use library for Sonic Pi to be able to work with MIDI devices.
4+
5+
It provides an erlang NIF interface to be integrated into Sonic Pi's erlang event dispatching architecture.
6+
7+
For the erlang side to drive the API it provides some NIF-based functions. On the other direction for the library to provide events to erlang it uses enif_send (also part of erlang's NIF).
8+
9+
## Building
10+
For build instruction see INSTALL.md.
11+
12+
sp_midi is built assuming C++14. The build system is based on cmake. Tested target compiler in Windows is MSVC 2019 Win64, in Linux is gcc 4.9 or later, and on Mac, clang 5.1
13+
or later.
14+
15+
sp_midi uses the following Open Source libs:
16+
* spdlog, for logging (included in the tree)
17+
* concurrentqueue (included in the tree)
18+
* rtmidi (included in the tree)
19+
20+
## LICENSE
21+
See LICENSE.md file for details.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
*.ipch
2+
*.suo
3+
*.user
4+
*.sdf
5+
*.opensdf
6+
*.exe
7+
*.pdb
8+
*.vs
9+
*.VC.db
10+
build/bin/
11+
build/*.log
12+
build/msvc16/*.log
13+
build/msvc16/obj/
14+
build/msvc15/*.log
15+
build/msvc15/obj/
16+
build/msvc14/*.log
17+
build/msvc14/obj/
18+
build/msvc12/*.log
19+
build/msvc12/obj/
20+
build/msvc11/*.log
21+
build/msvc11/obj/
22+
build/xcode/build/
23+
tests/fuzztests/fuzztests.log
24+
benchmarks/benchmarks.log
25+
tests/CDSChecker/*.o
26+
tests/CDSChecker/*.log
27+
tests/CDSChecker/model-checker/
28+
tests/relacy/freelist.exe
29+
tests/relacy/spmchash.exe
30+
tests/relacy/log.txt
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.9)
2+
project(concurrentqueue VERSION 1.0.0)
3+
4+
include(GNUInstallDirs)
5+
6+
add_library(${PROJECT_NAME} INTERFACE)
7+
8+
target_include_directories(concurrentqueue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
9+
10+
install(FILES blockingconcurrentqueue.h concurrentqueue.h lightweightsemaphore.h LICENSE.md
11+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
12+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
This license file applies to everything in this repository except that which
2+
is explicitly annotated as being written by other authors, i.e. the Boost
3+
queue (included in the benchmarks for comparison), Intel's TBB library (ditto),
4+
dlib::pipe (ditto),
5+
the CDSChecker tool (used for verification), the Relacy model checker (ditto),
6+
and Jeff Preshing's semaphore implementation (used in the blocking queue) which
7+
has a zlib license (embedded in lightweightsempahore.h).
8+
9+
---
10+
11+
Simplified BSD License:
12+
13+
Copyright (c) 2013-2016, Cameron Desrochers.
14+
All rights reserved.
15+
16+
Redistribution and use in source and binary forms, with or without modification,
17+
are permitted provided that the following conditions are met:
18+
19+
- Redistributions of source code must retain the above copyright notice, this list of
20+
conditions and the following disclaimer.
21+
- Redistributions in binary form must reproduce the above copyright notice, this list of
22+
conditions and the following disclaimer in the documentation and/or other materials
23+
provided with the distribution.
24+
25+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
26+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28+
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
32+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
35+
---
36+
37+
I have also chosen to dual-license under the Boost Software License as an alternative to
38+
the Simplified BSD license above:
39+
40+
Boost Software License - Version 1.0 - August 17th, 2003
41+
42+
Permission is hereby granted, free of charge, to any person or organization
43+
obtaining a copy of the software and accompanying documentation covered by
44+
this license (the "Software") to use, reproduce, display, distribute,
45+
execute, and transmit the Software, and to prepare derivative works of the
46+
Software, and to permit third-parties to whom the Software is furnished to
47+
do so, all subject to the following:
48+
49+
The copyright notices in the Software and this entire statement, including
50+
the above license grant, this restriction and the following disclaimer,
51+
must be included in all copies of the Software, in whole or in part, and
52+
all derivative works of the Software, unless such copies or derivative
53+
works are solely in the form of machine-executable object code generated by
54+
a source language processor.
55+
56+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
59+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
60+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
61+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
62+
DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)