Skip to content

Commit

Permalink
Updated to latest AUv3Support API
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhowes committed Oct 27, 2024
1 parent a8a27b3 commit 4b748a9
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 38 deletions.
25 changes: 17 additions & 8 deletions LPF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -530,9 +530,10 @@
C437FE302223672C008D6C09 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
DefaultBuildSystemTypeForWorkspace = Latest;
LastSwiftUpdateCheck = 1240;
LastUpgradeCheck = 1410;
LastUpgradeCheck = 1600;
ORGANIZATIONNAME = Apple;
TargetAttributes = {
BD1D257525D5AAB000523748 = {
Expand Down Expand Up @@ -781,6 +782,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.braysoftware.Snapshots;
Expand Down Expand Up @@ -824,6 +826,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.braysoftware.Snapshots;
Expand All @@ -842,7 +845,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1824A3E8DB004AC8FA /* Staging.xcconfig */;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++23";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
Expand All @@ -865,6 +868,7 @@
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = c11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -885,7 +889,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1824A3E8DB004AC8FA /* Staging.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -937,6 +940,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -1008,6 +1012,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand All @@ -1028,7 +1033,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1824A3E8DB004AC8FA /* Staging.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -1084,6 +1088,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -1156,6 +1161,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand All @@ -1174,7 +1180,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1724A3E887004AC8FA /* Dev.xcconfig */;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++23";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
Expand All @@ -1198,6 +1204,7 @@
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = c11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -1219,7 +1226,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1724A3E887004AC8FA /* Dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -1277,6 +1283,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -1354,6 +1361,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand All @@ -1374,7 +1382,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BDE2CE1724A3E887004AC8FA /* Dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -1436,6 +1443,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -1515,6 +1523,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 4.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down
2 changes: 1 addition & 1 deletion LPF.xcodeproj/xcshareddata/xcschemes/Snapshots.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion LPF.xcodeproj/xcshareddata/xcschemes/iOS App.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion LPF.xcodeproj/xcshareddata/xcschemes/macOS App.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Packages/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ let package = Package(
dependencies: ["Parameters"]
),
],
cxxLanguageStandard: .cxx17
cxxLanguageStandard: .cxx20
)
11 changes: 5 additions & 6 deletions Packages/Sources/Kernel/C++/Kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "AcceleratedBiquadFilter.hpp"
#import "DSPHeaders/BusBuffers.hpp"
#import "DSPHeaders/EventProcessor.hpp"
#import "DSPHeaders/RampingParameter.hpp"

/**
The audio processing kernel that performs low-pass filtering of an audio signal.
Expand Down Expand Up @@ -49,7 +48,7 @@ struct Kernel : public DSPHeaders::EventProcessor<Kernel> {
@param value the new value for the parameter
@param duration the number of frames to ramp to the new value
*/
void setParameterValue(AUParameterAddress address, AUValue value, AUAudioFrameCount duration) noexcept;
bool setParameterValue(AUParameterAddress address, AUValue value, AUAudioFrameCount duration) noexcept;

/**
Obtain from the kernel the current value of an AU parameter.
Expand Down Expand Up @@ -82,8 +81,8 @@ struct Kernel : public DSPHeaders::EventProcessor<Kernel> {
}
}

void doParameterEvent(const AUParameterEvent& event) noexcept {
setParameterValue(event.parameterAddress, event.value, event.rampDurationSampleFrames);
bool doParameterEvent(const AUParameterEvent& event, AUAudioFrameCount rampDuration) noexcept {
return setParameterValue(event.parameterAddress, event.value, rampDuration);
}

void doRendering(NSInteger outputBusNumber, DSPHeaders::BusBuffers ins, DSPHeaders::BusBuffers outs,
Expand All @@ -100,8 +99,8 @@ struct Kernel : public DSPHeaders::EventProcessor<Kernel> {
AUValue sampleRate_;
AUValue nyquistFrequency_;
AUValue nyquistPeriod_;
DSPHeaders::Parameters::RampingParameter<AUValue> cutoff_;
DSPHeaders::Parameters::RampingParameter<AUValue> resonance_;
DSPHeaders::Parameters::Float cutoff_;
DSPHeaders::Parameters::Float resonance_;
std::string name_;
os_log_t log_;
};
7 changes: 4 additions & 3 deletions Packages/Sources/Kernel/Kernel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

@import ParameterAddress;

void Kernel::setParameterValue(AUParameterAddress address, AUValue value, AUAudioFrameCount duration) noexcept {
bool Kernel::setParameterValue(AUParameterAddress address, AUValue value, AUAudioFrameCount duration) noexcept {
os_log_with_type(log_, OS_LOG_TYPE_DEBUG, "setRampedParameterValue - %llul %f %d", address, value, duration);
switch (address) {
case ParameterAddressCutoff: cutoff_.set(value, duration); break;
case ParameterAddressResonance: resonance_.set(value, duration); break;
case ParameterAddressCutoff: cutoff_.set(value, duration); return true;
case ParameterAddressResonance: resonance_.set(value, duration); return true;
}
return false;
}

AUValue Kernel::getParameterValue(AUParameterAddress address) const noexcept {
Expand Down
21 changes: 10 additions & 11 deletions Packages/Sources/Kernel/KernelBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ - (void)setRenderingFormat:(NSInteger)busCount format:(AVAudioFormat*)inputForma

- (void)deallocateRenderResources { kernel_->deallocateRenderResources(); }

- (AUInternalRenderBlock)internalRenderBlock:(nullable AUHostTransportStateBlock)tsb {
- (AUInternalRenderBlock)internalRenderBlock {
__block auto kernel = kernel_;
__block auto transportStateBlock = tsb;
return ^AUAudioUnitStatus(AudioUnitRenderActionFlags* flags, const AudioTimeStamp* timestamp,
AUAudioFrameCount frameCount, NSInteger outputBusNumber, AudioBufferList* output,
const AURenderEvent* realtimeEventListHead, AURenderPullInputBlock pullInputBlock) {
if (transportStateBlock) {
AUHostTransportStateFlags flags;
transportStateBlock(&flags, NULL, NULL, NULL);
bool rendering = flags & AUHostTransportStateMoving;
kernel->setRendering(rendering);
}
return kernel->processAndRender(timestamp, frameCount, outputBusNumber, output, realtimeEventListHead, pullInputBlock);
};
}
Expand All @@ -48,10 +41,16 @@ - (void)magnitudes:(nonnull const float*)frequencies count:(NSInteger)count outp
filter.magnitudes(frequencies, count, kernel_->nyquistPeriod(), output);
}

- (void)set:(AUParameter *)parameter value:(AUValue)value {
kernel_->setParameterValue(parameter.address, value, 0);
- (AUImplementorValueObserver)parameterValueObserverBlock {
return ^(AUParameter* parameter, AUValue value) {
kernel_->setParameterValue(parameter.address, value, 0);
};
}

- (AUValue)get:(AUParameter *)parameter { return kernel_->getParameterValue(parameter.address); }
- (AUImplementorValueProvider)parameterValueProviderBlock {
return ^AUValue(AUParameter* parameter) {
return kernel_->getParameterValue(parameter.address);
};
}

@end
6 changes: 3 additions & 3 deletions Packages/Sources/Kernel/include/Kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
@returns AUInternalRenderBlock instance
*/
- (AUInternalRenderBlock)internalRenderBlock:(nullable AUHostTransportStateBlock)tsb;
- (AUInternalRenderBlock)internalRenderBlock;

/**
Set the bypass state.
Expand All @@ -62,9 +62,9 @@ NS_ASSUME_NONNULL_BEGIN
// These are the functions that satisfy the AUParameterHandler protocol
@interface KernelBridge (AUParameterHandler)

- (void)set:(AUParameter *)parameter value:(AUValue)value;
- (AUImplementorValueObserver)parameterValueObserverBlock;

- (AUValue)get:(AUParameter *)parameter;
- (AUImplementorValueProvider)parameterValueProviderBlock;

@end

Expand Down
2 changes: 1 addition & 1 deletion Packages/Sources/KernelBridge/KernelBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import Kernel

// Extend the Obj-C KernelBridge with protocols for interoperability with `FilterAudioUnit` and `AudioUnitParameters`
// classes.
extension KernelBridge: AUParameterHandler, AudioRenderer {}
extension KernelBridge: @retroactive AUParameterHandler, @retroactive AudioRenderer {}

0 comments on commit 4b748a9

Please sign in to comment.