Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add polyphonic sampler #50

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "Sampler/thirdparty/Sampler"]
path = Sampler/thirdparty/Sampler
url = https://github.com/DBraun/Sampler
[submodule "Sampler/thirdparty/JUCE"]
path = Sampler/thirdparty/JUCE
url = https://github.com/juce-framework/JUCE
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ List of Current Chugins
- **PowerADSR**
- by [@ericheep](https://github.com/ericheep)
- Power function ADSR envelope.
- **Sampler**
- by [@dbraun](https://github.com/dbraun)
- A polyphonic [sampler](https://github.com/DBraun/Sampler) with ADSR envelopes, filters, and more in development.
- **WinFuncEnv**
- by [@ericheep](https://github.com/ericheep)
- Envelope built on window functions.
Expand Down
38 changes: 38 additions & 0 deletions Sampler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
build/*
Debug/

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

!tests/plugins/*
!win-x64/*.chug
160 changes: 160 additions & 0 deletions Sampler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)

project(SamplerChugin VERSION 0.0.1)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT SamplerChugin)

set(CMAKE_VS_PLATFORM_NAME "x64")

project(SamplerChugin VERSION 0.0.1)

FILE(GLOB CK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../chuck/include/*.h)

file (GLOB SAMPLER_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/Components/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/Components/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/DataModels/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/DataModels/*.cpp")

set(Sources
"src/SamplerChugin.cpp"
)

source_group("Sources" FILES ${Sources})

add_library(SamplerChugin SHARED ${CK_SOURCES} ${Sources} ${SAMPLER_SOURCES})

add_subdirectory(thirdparty/JUCE)

target_link_libraries(SamplerChugin
PRIVATE
juce::juce_audio_utils
juce::juce_dsp
juce::juce_audio_basics
juce::juce_audio_devices
juce::juce_audio_formats
# juce::juce_audio_plugin_client
juce::juce_audio_processors
juce::juce_audio_utils
juce::juce_core
juce::juce_data_structures
juce::juce_dsp
juce::juce_events
juce::juce_graphics
juce::juce_gui_basics
juce::juce_gui_extra
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)

target_compile_definitions(SamplerChugin
PUBLIC
# JUCE_DLL=1
# JUCE_STANDALONE_APPLICATION=0
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
_WINDOWS
WIN32
__WINDOWS_MODERN__
__PLATFORM_WIN32__
__WINDOWS_DS__
_USRDLL
Use_MFC=0
Use_Debug_Libraries=0
NDEBUG
_NDEBUG
_MBCS
SamplerChugin_EXPORTS

JUCE_STANDALONE_APPLICATION=0
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
# JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1
JUCE_MODULE_AVAILABLE_juce_audio_basics=1
JUCE_MODULE_AVAILABLE_juce_audio_devices=1
JUCE_MODULE_AVAILABLE_juce_audio_formats=1
# JUCE_MODULE_AVAILABLE_juce_audio_plugin_client=1
JUCE_MODULE_AVAILABLE_juce_audio_processors=1
JUCE_MODULE_AVAILABLE_juce_audio_utils=1
JUCE_MODULE_AVAILABLE_juce_core=1
JUCE_MODULE_AVAILABLE_juce_data_structures=1
JUCE_MODULE_AVAILABLE_juce_dsp=1
JUCE_MODULE_AVAILABLE_juce_events=1
JUCE_MODULE_AVAILABLE_juce_graphics=1
JUCE_MODULE_AVAILABLE_juce_gui_basics=1
JUCE_MODULE_AVAILABLE_juce_gui_extra=1

PIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==
JucePlugin_Build_VST=0
JucePlugin_Build_VST3=0
JucePlugin_Build_AU=0
JucePlugin_Build_AUv3=0
JucePlugin_Build_RTAS=0
JucePlugin_Build_AAX=0
JucePlugin_Build_Standalone=0
JucePlugin_Build_Unity=0
_LIB
# PRIVATE
# JUCE_DLL_BUILD=1
)

if(MSVC)
target_compile_definitions(SamplerChugin
PUBLIC
_WINDOWS
WIN32
__WINDOWS_MODERN__
__PLATFORM_WIN32__
__WINDOWS_DS__
)
endif()

# Include header directories
target_include_directories(SamplerChugin PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../chuck/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/JuceLibraryCode>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Sampler/Source/>
$<INSTALL_INTERFACE:SamplerChugin> )

# Install library
INSTALL(TARGETS SamplerChugin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )

target_compile_options(SamplerChugin PRIVATE /EHsc /GR)

if(MSVC)
target_compile_options(SamplerChugin PRIVATE
$<$<CONFIG:Debug>:
/Od;
/RTC1;
/MDd;
>
$<$<CONFIG:Release>:
/MD;
>
/W3;
/Zi;
${DEFAULT_CXX_EXCEPTION_HANDLING};
/Y-;
)
target_link_options(SamplerChugin PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/DEBUG;
/SUBSYSTEM:WINDOWS;
/INCREMENTAL:NO
)
endif()

if (MSVC)
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:SamplerChugin>"
"%USERPROFILE%/Documents/ChucK/chugins/Sampler.chug")
endif (MSVC)
30 changes: 30 additions & 0 deletions Sampler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Sampler Chugin

## Patching Chuck

In the root of the chugins directory, there's a git diff file `vst_patch.patch`. Open a command window to the root and apply the patch: `git apply vst_patch.patch`. This will change a file in `chugins/chuck/include`. Don't commit these changes to the repo. Be prepared to undo them once the patch is no longer necessary.

## Installation on Windows

Update submodules:
`git submodule update --init --recursive`

Create an extra folder for your chugins, `%USERPROFILE%/Documents/ChucK/chugins/`. Create a system environment variable `CHUCK_CHUGIN_PATH` equal to this path.

In `chugins/Sampler`, open a Windows command window:

```
mkdir build
cd build
cmake ..
```

Then open `chugins/Sampler/build/Sampler.sln` and build in 64-bit Release mode. You should see a new Sampler.chug file in the chugins folder you created earlier.

Build 64-bit chuck.exe from [source](https://github.com/ccrma/chuck/tree/main/src/visual-studio). If you want to use [miniAudicle](https://github.com/ccrma/miniAudicle), then miniAudicle must also be 64-bit. Check that your chuck is 64-bit with `chuck --version`.

Run any of the test scripts: `chuck.exe "tests/sampler_test.ck"`.

## License

The Sampler chugin uses [Sampler](https://github.com/DBraun/Sampler), which uses JUCE, so you must follow all of the licenses.
Loading