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

Implement optional sample-accurate event processing #78

Merged
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ are available
* `CLAP_MANUAL_URL` and `CLAP_SUPPORT_URL` generate the urls in your description
* `CLAP_MISBHEAVIOUR_HANDLER_LEVEL` can be set to `Terminate` or `Ignore` (default
is `Ignore`) to choose your behaviour for a misbehaving host.
* `CLAP_CHECKING_LEVEL` can be set to `None`, `Minimal`, or `Maximal` (default is
`Minimal`) to choose the level of sanity checks enabled for the plugin.
* `CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES` can be set to any integer value to choose the
resolution (in samples) used by the wrapper for doing sample-accurate event processing.
Setting the value to `0` (the default value) will turn off sample-accurate event processing.
* `CLAP_ALWAYS_SPLIT_BLOCK` can be set to `1` (on), or `0` (off, default), to tell the
wrapper to _always_ attempt to split incoming audio buffers into chunks of size
`CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES`, regardless of any input events being
sent from the host. Note that if the block size provided by the host is not an
even multiple of `CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES`, the plugin may be
required to process a chunk smaller than the chosen resolution.

## Risks of using this library

Expand Down
20 changes: 19 additions & 1 deletion cmake/ClapTargetHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function(clap_juce_extensions_plugin_internal)
set(oneValueArgs TARGET TARGET_PATH PLUGIN_NAME IS_JUCER PLUGIN_VERSION DO_COPY CLAP_MANUAL_URL CLAP_SUPPORT_URL CLAP_MISBEHAVIOUR_HANDLER_LEVEL CLAP_CHECKING_LEVEL)
set(oneValueArgs TARGET TARGET_PATH PLUGIN_NAME IS_JUCER PLUGIN_VERSION DO_COPY CLAP_MANUAL_URL CLAP_SUPPORT_URL
CLAP_MISBEHAVIOUR_HANDLER_LEVEL CLAP_CHECKING_LEVEL CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES
CLAP_ALWAYS_SPLIT_BLOCK)
set(multiValueArgs CLAP_ID CLAP_FEATURES)

cmake_parse_arguments(CJA "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand Down Expand Up @@ -31,6 +33,20 @@ function(clap_juce_extensions_plugin_internal)
message( STATUS "Setting Checking handler level to '${CJA_CLAP_CHECKING_LEVEL}'")
endif()

if ("${CJA_CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES}" STREQUAL "")
message( STATUS "Setting event resolution to 0 samples (no sample-accurate automation)")
set(CJA_CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES 0)
else()
message( STATUS "Setting event resolution to ${CJA_CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES} samples")
endif()

if ("${CJA_CLAP_ALWAYS_SPLIT_BLOCK}" STREQUAL "")
message( STATUS "Setting \"Always split block\" to OFF")
set(CJA_CLAP_ALWAYS_SPLIT_BLOCK 0)
else()
message( STATUS "Setting \"Always split block\" to ${CJA_CLAP_ALWAYS_SPLIT_BLOCK}")
endif()

# we need the list of features as comma separated quoted strings
foreach(feature IN LISTS CJA_CLAP_FEATURES)
list (APPEND CJA_CLAP_FEATURES_PARSED "\"${feature}\"")
Expand Down Expand Up @@ -96,6 +112,8 @@ function(clap_juce_extensions_plugin_internal)
CLAP_SUPPORT_URL="${CJA_CLAP_SUPPORT_URL}"
CLAP_MISBEHAVIOUR_HANDLER_LEVEL=${CJA_CLAP_MISBEHAVIOUR_HANDLER_LEVEL}
CLAP_CHECKING_LEVEL=${CJA_CLAP_CHECKING_LEVEL}
CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES=${CJA_CLAP_PROCESS_EVENTS_RESOLUTION_SAMPLES}
CLAP_ALWAYS_SPLIT_BLOCK=${CJA_CLAP_ALWAYS_SPLIT_BLOCK}
)

if(${CJA_IS_JUCER})
Expand Down
12 changes: 3 additions & 9 deletions cmake/JucerClap.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# use this function to create a CLAP from a jucer project
function(create_jucer_clap_target)
set(oneValueArgs TARGET PLUGIN_NAME BINARY_NAME MANUFACTURER_NAME MANUFACTURER_URL VERSION_STRING MANUFACTURER_CODE PLUGIN_CODE EDITOR_NEEDS_KEYBOARD_FOCUS MISBEHAVIOUR_HANDLER_LEVEL CHECKING_LEVEL)
set(multiValueArgs CLAP_ID CLAP_FEATURES CLAP_MANUAL_URL CLAP_SUPPORT_URL)
set(oneValueArgs TARGET PLUGIN_NAME BINARY_NAME MANUFACTURER_NAME MANUFACTURER_URL VERSION_STRING MANUFACTURER_CODE PLUGIN_CODE EDITOR_NEEDS_KEYBOARD_FOCUS)
set(multiValueArgs CLAP_FEATURES)

cmake_parse_arguments(CJA "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

Expand Down Expand Up @@ -41,16 +41,10 @@ function(create_jucer_clap_target)
endif()

clap_juce_extensions_plugin_jucer(
TARGET ${CJA_TARGET}
TARGET_PATH "${PLUGIN_LIBRARY_PATH}"
PLUGIN_NAME "${CJA_BINARY_NAME}"
PLUGIN_VERSION "${CJA_VERSION_STRING}"
CLAP_ID "${CJA_CLAP_ID}"
CLAP_FEATURES "${CJA_CLAP_FEATURES}"
CLAP_MANUAL_URL "${CJA_CLAP_MANUAL_URL}"
CLAP_SUPPORT_URL "${CJA_CLAP_SUPPORT_URL}"
CLAP_MISBEHAVIOUR_HANDLER_LEVEL "${CJA_MISBEHAVIOUR_HANDLER_LEVEL}"
CLAP_CHECKING_LEVEL "${CJA_CHECKING_LEVEL}"
${ARGV}
)

string(REPLACE " " "_" clap_target "${CJA_TARGET}_CLAP")
Expand Down
Loading