Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/plugins_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout Source Code
uses: actions/checkout@v1
uses: actions/checkout@v7.0.1
with:
fetch-depth: 1
submodules: true
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
run: iscc /o. .\installer\win64\Installer.iss

- name: Upload installer
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7.0.2
with:
name: Csound_win_x64-${{env.CSOUND_VERSION}}.${{github.run_number}}-plugins-installer
path: ./csound6-plugins-win_x86_64-*.exe
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/plugins_build_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
release: ${{ steps.check_pr.outputs.has_label }}
steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v7.0.1

- name: Install Csound build dependencies
run: |
Expand All @@ -76,7 +76,7 @@ jobs:

- name: Cache Csound install
id: cache-csound
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: ~/csound-install
key: csound-${{ runner.os }}-${{ runner.arch }}-${{ env.CSOUND_VERSION }}
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
cp 7.x/src/stk/rawwaves/*.raw package/stk/rawwaves/

- name: Upload plugins
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7.0.2
with:
name: csound7-plugins-linux
path: package/
Expand All @@ -134,7 +134,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v7.0.1

- name: Install Csound build dependencies
env:
Expand All @@ -151,15 +151,15 @@ jobs:
run: 7.x/vcpkg/bootstrap-vcpkg.sh -disableMetrics

- name: Cache vcpkg binary cache
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: vcpkg-cache
key: vcpkg-macos-${{ github.run_id }}
restore-keys: vcpkg-macos-

- name: Cache Csound install
id: cache-csound
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: ~/csound-install
key: csound-${{ runner.os }}-${{ runner.arch }}-${{ env.CSOUND_VERSION }}
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
cp 7.x/src/stk/rawwaves/*.raw package/stk/rawwaves/

- name: Upload plugins
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7.0.2
with:
name: csound7-plugins-macos
path: package/
Expand All @@ -243,7 +243,7 @@ jobs:
shell: pwsh
steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v7.0.1

- name: Install Csound build dependencies
run: choco install -y winflexbison3
Expand All @@ -255,7 +255,7 @@ jobs:

- name: Cache Csound install
id: cache-csound
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: ${{ runner.temp }}\csound-install
key: csound-${{ runner.os }}-${{ runner.arch }}-${{ env.CSOUND_VERSION }}
Expand All @@ -271,7 +271,7 @@ jobs:
run: .\7.x\vcpkg\bootstrap-vcpkg.bat -disableMetrics

- name: Cache vcpkg binary cache
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: ${{ github.workspace }}\vcpkg-cache
key: vcpkg-windows-${{ github.run_id }}
Expand Down Expand Up @@ -330,7 +330,7 @@ jobs:
Copy-Item '7.x\src\stk\rawwaves\*.raw' -Destination $rawwaves

- name: Upload plugins
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7.0.2
with:
name: csound7-plugins-windows
path: package/
Expand All @@ -344,7 +344,7 @@ jobs:
image: nvidia/cuda:12.4.1-devel-ubuntu22.04
steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v7.0.1

- name: Install build dependencies
run: |
Expand All @@ -360,7 +360,7 @@ jobs:

- name: Cache Csound install
id: cache-csound
uses: actions/cache@v4
uses: actions/cache@v6.1.0
with:
path: /csound-install
key: csound-cuda-${{ runner.os }}-${{ runner.arch }}-${{ env.CSOUND_VERSION }}
Expand Down Expand Up @@ -403,7 +403,7 @@ jobs:
cp build/src/CUDA/*.so package/

- name: Upload plugins
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7.0.2
with:
name: csound7-plugins-linux-cuda
path: package/
Expand All @@ -418,25 +418,25 @@ jobs:
contents: write
steps:
- name: Download Linux plugins
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8.0.2
with:
name: csound7-plugins-linux
path: release/linux

- name: Download Linux CUDA plugins
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8.0.2
with:
name: csound7-plugins-linux-cuda
path: release/linux

- name: Download macOS plugins
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8.0.2
with:
name: csound7-plugins-macos
path: release/macos

- name: Download Windows plugins
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8.0.2
with:
name: csound7-plugins-windows
path: release/windows
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/plugins_wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Csound 7 WASM plugins

on:
pull_request:
branches: [develop]
push:
branches: [develop]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
package:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v7.0.1
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false
- uses: actions/setup-node@v7.1.0
with:
node-version: 22
cache: npm
- uses: cachix/install-nix-action@v31.11.1
- uses: cachix/cachix-action@v17
with:
name: csound
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
skipPush: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
- name: Install JS dependencies
run: npm ci
- name: Build WASM plugins with CMake and Nix
run: npm run build
- name: Test and pack
run: npm pack
- uses: actions/upload-artifact@v7.0.2
with:
name: csound-plugins-npm
path: csound-plugins-*.tgz
if-no-files-found: error
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
build
dist
csound6-plugins-win_x86_64-*
node_modules/
result*
*.tgz
.csound/
.wasm-dist.*/
20 changes: 18 additions & 2 deletions 7.x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ endif()

project(Csound-plugins)

string(TOUPPER "${CMAKE_SYSTEM_NAME}" CMAKE_SYSTEM_NAME_UPPER)
if(CMAKE_SYSTEM_NAME_UPPER STREQUAL "WASI")
set(WASM ON)
include(cmake/WasmPlugins.cmake)
endif()

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
endif()
Expand All @@ -50,6 +56,9 @@ find_package(CSOUND 7.0)
if(NOT CSOUND_FOUND)
message(FATAL_ERROR "Csound 7.0 or newer is required")
endif()
if(WASM AND NOT CSOUND_VERSION_MAJOR EQUAL 7)
message(FATAL_ERROR "WASM plugins require the Csound 7 SDK")
endif()

include(TestBigEndian)
include(CheckFunctionExists)
Expand Down Expand Up @@ -163,7 +172,9 @@ if(LINUX)
endif()

# plugin install directories (CS_USER_PLUGIN on MacOs/Windows)
if(USE_DOUBLE)
if(WASM)
set(PLUGIN_INSTALL_DIR "lib")
elseif(USE_DOUBLE)
message(STATUS "Building with 64-bit floats")
if(APPLE)
set(PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/csound/${APIVERSION}/plugins64")
Expand Down Expand Up @@ -232,7 +243,11 @@ endfunction(check_deps)
# NB - this was moved here as it needs some VARS defined above
# for setting up the framework
function(make_plugin libname srcs)
if(APPLE)
if(WASM)
# CMake does not model WASI side modules as shared libraries.
add_executable(${libname} ${srcs})
configure_wasm_plugin(${libname})
elseif(APPLE)
add_library(${libname} SHARED ${srcs})
else()
add_library(${libname} MODULE ${srcs})
Expand All @@ -245,6 +260,7 @@ function(make_plugin libname srcs)
endwhile()

install(TARGETS ${libname}
RUNTIME DESTINATION "${PLUGIN_INSTALL_DIR}"
LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}"
ARCHIVE DESTINATION "${PLUGIN_INSTALL_DIR}" )
endfunction(make_plugin)
Expand Down
8 changes: 7 additions & 1 deletion 7.x/cmake/Modules/FindCSOUND.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ include(FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set CSOUND_FOUND to TRUE
# if all listed variables are TRUE and the version satisfies the request
if(WASM)
# Side modules call the browser engine through its API table.
set(_csound_required_vars CSOUND_INCLUDE_DIR)
else()
set(_csound_required_vars CSOUND_LIBRARY CSOUND_INCLUDE_DIR)
endif()
find_package_handle_standard_args(CSOUND
REQUIRED_VARS CSOUND_LIBRARY CSOUND_INCLUDE_DIR
REQUIRED_VARS ${_csound_required_vars}
VERSION_VAR CSOUND_VERSION
)

Expand Down
37 changes: 37 additions & 0 deletions 7.x/cmake/WasmPlugins.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Match platform/wasm-wasi/src/plugin_example*.nix in csound/csound.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(USE_COMPILER_OPTIMIZATIONS OFF CACHE BOOL "" FORCE)
set(REQUIRE_PTHREADS OFF CACHE BOOL "" FORCE)
set(USE_DOUBLE ON CACHE BOOL "" FORCE)
execute_process(COMMAND ${CMAKE_C_COMPILER} --print-libgcc-file-name
OUTPUT_VARIABLE WASM_BUILTINS OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)

function(configure_wasm_plugin target)
set_target_properties(${target} PROPERTIES SUFFIX ".wasm")
target_compile_features(${target} PRIVATE c_std_11)
target_compile_definitions(${target} PRIVATE
USE_DOUBLE=1 _WASI_EMULATED_SIGNAL _WASI_EMULATED_MMAN)
target_compile_options(${target} PRIVATE
-fPIC "SHELL:-mllvm -wasm-enable-sjlj"
"$<$<COMPILE_LANGUAGE:C>:-std=gnu11>"
"$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions;-nostdinc++>"
"$<$<COMPILE_LANGUAGE:CXX>:-isystem${WASM_CXX_INCLUDE_DIR}>")
target_link_options(${target} PRIVATE
-shared -nostdlib -nostartfiles
"LINKER:-Bsymbolic"
"LINKER:--experimental-pic"
"LINKER:--no-entry"
"LINKER:--import-table"
"LINKER:--import-memory"
"LINKER:--allow-undefined"
"LINKER:--export=__wasm_call_ctors"
"LINKER:--export-if-defined=__wasm_apply_data_relocs"
"LINKER:--export-if-defined=csound_opcode_init"
"LINKER:--export-if-defined=csoundModuleInfo"
"LINKER:--export-if-defined=csoundModuleInit"
"LINKER:--export-if-defined=csoundModuleCreate"
"LINKER:--export-if-defined=csoundModuleDestroy")
target_link_libraries(${target} PRIVATE
"${WASM_LIBCXX}" "${WASM_LIBC}" "${WASM_SETJMP}" "${WASM_BUILTINS}")
endfunction()
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ plugins.

The tree is currently organised by major Csound versions. Full and beta releases are available and build artefacts are also accessible from the actions tab.

The Csound 7 WASM package, `@csound/plugins`, uses Nix and CMake. See the
[build, test, and npm release notes](wasm/README.md).

NB: Csound 6.x is EOL. It is likely that plugins for that version will be removed from the develop and main branch after the first full release. In that case, we will keep the code solely in the csound6 branch.


Expand Down
20 changes: 20 additions & 0 deletions THIRD_PARTY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Third-party code in the WASM package

The plugins use the LGPL-2.1-or-later license in `LICENSE`. Their source and
copyright notices live under [`7.x/src`](https://github.com/csound/plugins/tree/develop/7.x/src).
The package also contains code from these libraries:

| Library | Used by | License notices |
| --- | --- | --- |
| Eigen | Chua | `dist/licenses/eigen/` |
| GMM++ (GetFEM) | Linear algebra | `dist/licenses/gmm.txt`; LGPL-3.0-or-later with the exception in the headers |
| libpng | Image | `dist/licenses/libpng.txt` |
| zlib | Image | `dist/licenses/zlib.txt` |
| wasi-libc, musl, cloudlibc, musl-fts | C runtime | `dist/licenses/wasi-libc/` |
| LLVM libc++, libc++abi, compiler-rt | C++ runtime and compiler support | `dist/licenses/libcxx.txt`, `libcxxabi.txt`, `compiler-rt.txt` |

The Nix build copies these notices from the source used to build each library.
[`wasm/nixpkgs.nix`](https://github.com/csound/plugins/blob/develop/wasm/nixpkgs.nix)
pins their source versions. The GMM++ headers live in this repository. The build
uses upstream CMake and make options for static PIC libraries; it adds no source
patches. `wasm/default.nix` records those options.
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Asset URLs for Csound 7's `withPlugins` option. */
export declare const plugins: Readonly<{
chua: string;
image: string;
linearAlgebra: string;
}>;
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Asset URLs for Csound 7's `withPlugins` option. */
export const plugins = Object.freeze({
chua: new URL("./dist/chua.wasm", import.meta.url).href,
image: new URL("./dist/image.wasm", import.meta.url).href,
linearAlgebra: new URL("./dist/linear_algebra.wasm", import.meta.url).href,
});
Loading
Loading