Initial release
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
|
||||
if(SMTG_MAC)
|
||||
if (XCODE AND SMTG_ENABLE_AUV2_BUILDS)
|
||||
|
||||
option(SMTG_AUWRAPPER_ACTIVATE_ONLY_DEFAULT_ACTIVE_BUSES
|
||||
"Activate only the buses that have the kDefaultActive flag set in the AUWrapper. This may not work on some hosts because they never activate a bus later."
|
||||
OFF
|
||||
)
|
||||
|
||||
string(RANDOM LENGTH 20 CocoaId)
|
||||
file(CONFIGURE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/au/aucocoaclassprefix.h"
|
||||
CONTENT "#define SMTG_AUCocoaUIBase_CLASS_NAME SMTG_AUCocoaUIBase_${CocoaId}"
|
||||
)
|
||||
|
||||
set(target au_wrapper)
|
||||
set(${target}_sources
|
||||
aucarbonview.mm
|
||||
aucarbonview.h
|
||||
aucocoaview.mm
|
||||
aucocoaview.h
|
||||
auwrapper.mm
|
||||
auwrapper.h
|
||||
NSDataIBStream.mm
|
||||
NSDataIBStream.h
|
||||
)
|
||||
add_library(${target}
|
||||
STATIC
|
||||
${${target}_sources}
|
||||
)
|
||||
smtg_target_setup_universal_binary(${target})
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${SDK_IDE_LIBS_FOLDER}
|
||||
)
|
||||
target_compile_features(${target}
|
||||
PUBLIC
|
||||
cxx_std_17
|
||||
)
|
||||
|
||||
if(SMTG_AUWRAPPER_ACTIVATE_ONLY_DEFAULT_ACTIVE_BUSES)
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
SMTG_AUWRAPPER_ACTIVATE_ONLY_DEFAULT_ACTIVE_BUSES
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
sdk_hosting
|
||||
"-framework AudioUnit" "-framework CoreMIDI"
|
||||
"-framework AudioToolbox"
|
||||
"-framework CoreFoundation"
|
||||
"-framework Carbon"
|
||||
"-framework Cocoa"
|
||||
"-framework CoreAudio"
|
||||
)
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/au/"
|
||||
)
|
||||
|
||||
if(NOT ${SMTG_COREAUDIO_SDK_PATH} STREQUAL "")
|
||||
target_sources(${target} PRIVATE
|
||||
ausdk.mm
|
||||
)
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
"${SMTG_COREAUDIO_SDK_PATH}/**"
|
||||
)
|
||||
elseif(NOT ${SMTG_AUDIOUNIT_SDK_PATH} STREQUAL "")
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
SMTG_AUWRAPPER_USES_AUSDK
|
||||
)
|
||||
## Adding the xcodeproj will crash Xcode when closing and reopening the cmake generated project
|
||||
# target_sources(${target} PRIVATE
|
||||
# "${SMTG_AUDIOUNIT_SDK_PATH}/AudioUnitSDK.xcodeproj"
|
||||
# )
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
"${SMTG_AUDIOUNIT_SDK_PATH}/include/**"
|
||||
)
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
AudioUnitSDK
|
||||
)
|
||||
else()
|
||||
message(${SMTG_AUDIOUNIT_SDK_PATH})
|
||||
message(FATAL_ERROR "The option SMTG_ENABLE_AUV2_BUILDS is set but the audio unit SDK paths are not set")
|
||||
endif()
|
||||
|
||||
else()
|
||||
message("[SMTG] * To enable building the AudioUnit wrapper, you need to use the Xcode generator and set SMTG_COREAUDIO_SDK_PATH to the path of your installation of the CoreAudio SDK!")
|
||||
endif(XCODE AND SMTG_ENABLE_AUV2_BUILDS)
|
||||
endif(SMTG_MAC)
|
||||
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/NSDataIBStream.h
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "pluginterfaces/base/ibstream.h"
|
||||
#import "public.sdk/source/vst/hosting/hostclasses.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace Steinberg {
|
||||
namespace Vst {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class NSDataIBStream : public IBStream, Vst::IStreamAttributes
|
||||
{
|
||||
public:
|
||||
NSDataIBStream (NSData* data, bool hideAttributes = false);
|
||||
virtual ~NSDataIBStream ();
|
||||
|
||||
//---from IBStream-------------------
|
||||
tresult PLUGIN_API read (void* buffer, int32 numBytes, int32* numBytesRead = 0) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API write (void* buffer, int32 numBytes, int32* numBytesWritten = 0) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API seek (int64 pos, int32 mode, int64* result = 0) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API tell (int64* pos) SMTG_OVERRIDE;
|
||||
|
||||
//---from Vst::IStreamAttributes-----
|
||||
tresult PLUGIN_API getFileName (String128 name) SMTG_OVERRIDE;
|
||||
IAttributeList* PLUGIN_API getAttributes () SMTG_OVERRIDE;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
protected:
|
||||
NSData* data;
|
||||
int64 currentPos;
|
||||
IPtr<IAttributeList> attrList;
|
||||
bool hideAttributes;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class NSMutableDataIBStream : public NSDataIBStream
|
||||
{
|
||||
public:
|
||||
NSMutableDataIBStream (NSMutableData* data);
|
||||
virtual ~NSMutableDataIBStream ();
|
||||
|
||||
tresult PLUGIN_API write (void* buffer, int32 numBytes, int32* numBytesWritten = 0) SMTG_OVERRIDE;
|
||||
//------------------------------------------------------------------------
|
||||
protected:
|
||||
NSMutableData* mdata;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // namespace Vst
|
||||
} // namespace Steinberg
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,185 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/NSDataIBStream.mm
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#include "NSDataIBStream.h"
|
||||
|
||||
#include "pluginterfaces/vst/ivstattributes.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if __clang__
|
||||
#if __has_feature(objc_arc) && __clang_major__ >= 3
|
||||
#define ARC_ENABLED 1
|
||||
#endif // __has_feature(objc_arc)
|
||||
#endif // __clang__
|
||||
|
||||
namespace Steinberg {
|
||||
namespace Vst {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
NSDataIBStream::NSDataIBStream (NSData* data, bool hideAttributes)
|
||||
: data (data)
|
||||
, currentPos (0)
|
||||
, hideAttributes (hideAttributes)
|
||||
{
|
||||
FUNKNOWN_CTOR
|
||||
if (!hideAttributes)
|
||||
attrList = HostAttributeList::make ();
|
||||
#if !ARC_ENABLED
|
||||
[data retain];
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
NSDataIBStream::~NSDataIBStream ()
|
||||
{
|
||||
#if !ARC_ENABLED
|
||||
[data release];
|
||||
#endif
|
||||
FUNKNOWN_DTOR
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IMPLEMENT_REFCOUNT (NSDataIBStream)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::queryInterface (const TUID iid, void** obj)
|
||||
{
|
||||
QUERY_INTERFACE (iid, obj, FUnknown::iid, IBStream)
|
||||
QUERY_INTERFACE (iid, obj, IBStream::iid, IBStream)
|
||||
if (!hideAttributes)
|
||||
QUERY_INTERFACE (iid, obj, IStreamAttributes::iid, IStreamAttributes)
|
||||
*obj = 0;
|
||||
return kNoInterface;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::read (void* buffer, int32 numBytes, int32* numBytesRead)
|
||||
{
|
||||
int32 useBytes = std::min (numBytes, (int32)([data length] - currentPos));
|
||||
if (useBytes > 0)
|
||||
{
|
||||
[data getBytes: buffer range: NSMakeRange (currentPos, useBytes)];
|
||||
if (numBytesRead)
|
||||
*numBytesRead = useBytes;
|
||||
currentPos += useBytes;
|
||||
return kResultTrue;
|
||||
}
|
||||
return kResultFalse;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::write (void* buffer, int32 numBytes, int32* numBytesWritten)
|
||||
{
|
||||
return kResultFalse;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::seek (int64 pos, int32 mode, int64* result)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case kIBSeekSet:
|
||||
{
|
||||
if (pos <= [data length])
|
||||
{
|
||||
currentPos = pos;
|
||||
if (result)
|
||||
tell (result);
|
||||
return kResultTrue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kIBSeekCur:
|
||||
{
|
||||
if (currentPos + pos <= [data length])
|
||||
{
|
||||
currentPos += pos;
|
||||
if (result)
|
||||
tell (result);
|
||||
return kResultTrue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kIBSeekEnd:
|
||||
{
|
||||
if ([data length] + pos <= [data length])
|
||||
{
|
||||
currentPos = [data length] + pos;
|
||||
if (result)
|
||||
tell (result);
|
||||
return kResultTrue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return kResultFalse;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::tell (int64* pos)
|
||||
{
|
||||
if (pos)
|
||||
{
|
||||
*pos = currentPos;
|
||||
return kResultTrue;
|
||||
}
|
||||
return kResultFalse;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSDataIBStream::getFileName (String128 name)
|
||||
{
|
||||
return kNotImplemented;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IAttributeList* PLUGIN_API NSDataIBStream::getAttributes ()
|
||||
{
|
||||
return attrList;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------
|
||||
NSMutableDataIBStream::NSMutableDataIBStream (NSMutableData* data)
|
||||
: NSDataIBStream (data, true)
|
||||
, mdata (data)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
NSMutableDataIBStream::~NSMutableDataIBStream ()
|
||||
{
|
||||
[mdata setLength:currentPos];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API NSMutableDataIBStream::write (void* buffer, int32 numBytes, int32* numBytesWritten)
|
||||
{
|
||||
[mdata replaceBytesInRange:NSMakeRange (currentPos, numBytes) withBytes:buffer];
|
||||
if (numBytesWritten)
|
||||
*numBytesWritten = numBytes;
|
||||
currentPos += numBytes;
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // namespace Vst
|
||||
} // namespace Steinberg
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,68 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/aucarbonview.h
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "pluginterfaces/base/fplatform.h"
|
||||
|
||||
#if !SMTG_PLATFORM_64
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#include "AUPublic/AUCarbonViewBase/AUCarbonViewBase.h"
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#include "pluginterfaces/vst/ivsteditcontroller.h"
|
||||
#include "base/source/fobject.h"
|
||||
#include "pluginterfaces/gui/iplugview.h"
|
||||
|
||||
namespace Steinberg {
|
||||
namespace Vst {
|
||||
class AUCarbonPlugFrame;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class AUCarbonView : public AUCarbonViewBase, public IPlugFrame, public FObject
|
||||
{
|
||||
public:
|
||||
AUCarbonView (AudioUnitCarbonView auv);
|
||||
~AUCarbonView ();
|
||||
|
||||
OSStatus CreateUI (Float32 xoffset, Float32 yoffset) override;
|
||||
|
||||
OBJ_METHODS(AUCarbonView, FObject)
|
||||
DEF_INTERFACES_1(IPlugFrame, FObject)
|
||||
REFCOUNT_METHODS(FObject)
|
||||
|
||||
protected:
|
||||
tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* vr) SMTG_OVERRIDE;
|
||||
|
||||
static OSStatus HIViewAdded (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData);
|
||||
|
||||
IEditController* editController;
|
||||
AUCarbonPlugFrame* plugFrame;
|
||||
IPlugView* plugView;
|
||||
HIViewRef hiPlugView;
|
||||
EventHandlerRef eventHandler;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // namespace Vst
|
||||
} // namespace Steinberg
|
||||
|
||||
#endif // !SMTG_PLATFORM_64
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,146 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/aucarbonview.mm
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#include "aucarbonview.h"
|
||||
|
||||
#if !SMTG_PLATFORM_64
|
||||
|
||||
namespace Steinberg {
|
||||
namespace Vst {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AUCarbonView::AUCarbonView (AudioUnitCarbonView auv)
|
||||
: AUCarbonViewBase (auv)
|
||||
, editController (0)
|
||||
, plugView (0)
|
||||
, hiPlugView (0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AUCarbonView::~AUCarbonView ()
|
||||
{
|
||||
if (plugView)
|
||||
{
|
||||
plugView->setFrame (0);
|
||||
plugView->removed ();
|
||||
plugView->release ();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
OSStatus AUCarbonView::HIViewAdded (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
|
||||
{
|
||||
UInt32 eventClass = GetEventClass (inEvent);
|
||||
UInt32 eventKind = GetEventKind (inEvent);
|
||||
if (eventClass == kEventClassControl && eventKind == kEventControlAddedSubControl)
|
||||
{
|
||||
HIViewRef newControl;
|
||||
if (GetEventParameter (inEvent, kEventParamControlSubControl, typeControlRef, NULL, sizeof (HIViewRef) , NULL , &newControl) == noErr)
|
||||
{
|
||||
AUCarbonView* wrapper = (AUCarbonView*)inUserData;
|
||||
wrapper->hiPlugView = newControl;
|
||||
RemoveEventHandler (wrapper->eventHandler);
|
||||
wrapper->eventHandler = 0;
|
||||
}
|
||||
}
|
||||
return eventNotHandledErr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
OSStatus AUCarbonView::CreateUI (Float32 xoffset, Float32 yoffset)
|
||||
{
|
||||
AudioUnit unit = GetEditAudioUnit ();
|
||||
if (unit)
|
||||
{
|
||||
if (!editController)
|
||||
{
|
||||
UInt32 size = sizeof (IEditController*);
|
||||
if (AudioUnitGetProperty (unit, 64000, kAudioUnitScope_Global, 0, &editController, &size) != noErr)
|
||||
return kAudioUnitErr_NoConnection;
|
||||
}
|
||||
if (editController)
|
||||
{
|
||||
plugView = editController->createView (ViewType::kEditor);
|
||||
if (!plugView)
|
||||
return kAudioUnitErr_NoConnection;
|
||||
|
||||
HIViewRef contentView;
|
||||
const EventTypeSpec eventTypes[] = {
|
||||
{ kEventClassControl, kEventControlAddedSubControl },
|
||||
};
|
||||
OSStatus err = HIViewFindByID (HIViewGetRoot (GetCarbonWindow ()), kHIViewWindowContentID, &contentView);
|
||||
err = InstallControlEventHandler (contentView, HIViewAdded, 1, eventTypes, this, &eventHandler);
|
||||
|
||||
plugView->setFrame (this);
|
||||
|
||||
if (plugView->attached (GetCarbonWindow (), kPlatformTypeHIView) == kResultTrue)
|
||||
{
|
||||
HIViewRemoveFromSuperview (hiPlugView);
|
||||
EmbedControl (hiPlugView);
|
||||
HIViewMoveBy (hiPlugView, xoffset, yoffset);
|
||||
return noErr;
|
||||
}
|
||||
else
|
||||
plugView->setFrame (0);
|
||||
}
|
||||
}
|
||||
return kAudioUnitErr_NoConnection;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
tresult PLUGIN_API AUCarbonView::resizeView (IPlugView* view, ViewRect* vr)
|
||||
{
|
||||
if (vr == 0 || view != plugView)
|
||||
return kInvalidArgument;
|
||||
|
||||
HIViewRef hiView = GetCarbonPane ();
|
||||
if (hiView)
|
||||
{
|
||||
HIRect r;
|
||||
if (HIViewGetFrame (hiView, &r) != noErr)
|
||||
return kResultFalse;
|
||||
r.size.width = vr->right - vr->left;
|
||||
r.size.height = vr->bottom - vr->top;
|
||||
if (HIViewSetFrame (hiView, &r) != noErr)
|
||||
return kResultFalse;
|
||||
|
||||
if (plugView)
|
||||
plugView->onSize (vr);
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
return kResultFalse;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//COMPONENT_ENTRY(AUCarbonView)
|
||||
//------------------------------------------------------------------------
|
||||
extern "C" {
|
||||
ComponentResult AUCarbonViewEntry(ComponentParameters *params, AUCarbonView *obj);
|
||||
__attribute__ ((visibility ("default"))) ComponentResult AUCarbonViewEntry(ComponentParameters *params, AUCarbonView *obj)
|
||||
{
|
||||
return ComponentEntryPoint<AUCarbonView>::Dispatch(params, obj);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // namespace Vst
|
||||
} // namespace Steinberg
|
||||
#endif // !SMTG_PLATFORM_64
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/aucocoaview.h
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SMTG_AUCocoaUIBase_CLASS_NAME
|
||||
#import "aucocoaclassprefix.h"
|
||||
#endif
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AudioUnit/AUCocoaUIView.h>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@interface SMTG_AUCocoaUIBase_CLASS_NAME : NSObject<AUCocoaUIBase>
|
||||
@end
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,275 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/aucocoaview.mm
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#import "aucocoaview.h"
|
||||
#import "auwrapper.h"
|
||||
#import "public.sdk/source/vst/utility/objcclassbuilder.h"
|
||||
#import "pluginterfaces/base/funknownimpl.h"
|
||||
#import "pluginterfaces/gui/iplugview.h"
|
||||
#import "pluginterfaces/vst/ivsteditcontroller.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@interface NSObject (SMTG_AUView)
|
||||
- (id)initWithEditController:(Steinberg::Vst::IEditController*)editController
|
||||
audioUnit:(AudioUnit)au
|
||||
preferredSize:(NSSize)size;
|
||||
@end
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace Steinberg {
|
||||
namespace {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct AUPlugFrame : U::Implements<U::Directly<IPlugFrame>>
|
||||
{
|
||||
AUPlugFrame (NSView* parent) : parent (parent) {}
|
||||
tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* vr) override
|
||||
{
|
||||
NSRect newSize = NSMakeRect ([parent frame].origin.x, [parent frame].origin.y,
|
||||
vr->right - vr->left, vr->bottom - vr->top);
|
||||
[parent setFrame:newSize];
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
NSView* parent;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct AUView
|
||||
{
|
||||
static constexpr auto VarNamePlugView = "plugView";
|
||||
static constexpr auto VarNameEditController = "editController";
|
||||
static constexpr auto VarNameAudioUnit = "audioUnit";
|
||||
static constexpr auto VarNameDynlib = "dynlib";
|
||||
static constexpr auto VarNamePlugFrame = "plugFrame";
|
||||
static constexpr auto VarNameIsAttached = "isAttached";
|
||||
|
||||
struct Instance : ObjCInstance
|
||||
{
|
||||
using PlugViewVar = std::optional<ObjCVariable<IPlugView*>>;
|
||||
using EditControllerVar = std::optional<ObjCVariable<Vst::IEditController*>>;
|
||||
using AudioUnitVar = std::optional<ObjCVariable<AudioUnit>>;
|
||||
using DynlibVar = std::optional<ObjCVariable<FObject*>>;
|
||||
using PlugFrameVar = std::optional<ObjCVariable<AUPlugFrame*>>;
|
||||
using IsAttachedVar = std::optional<ObjCVariable<BOOL>>;
|
||||
|
||||
Instance (__unsafe_unretained id obj) : ObjCInstance (obj, [NSView class])
|
||||
{
|
||||
plugView = getVariable<IPlugView*> (VarNamePlugView);
|
||||
editController = getVariable<Vst::IEditController*> (VarNameEditController);
|
||||
audioUnit = getVariable<AudioUnit> (VarNamePlugView);
|
||||
dynlib = getVariable<FObject*> (VarNameDynlib);
|
||||
plugFrame = getVariable<AUPlugFrame*> (VarNamePlugFrame);
|
||||
isAttached = getVariable<BOOL> (VarNameIsAttached);
|
||||
}
|
||||
|
||||
PlugViewVar plugView;
|
||||
EditControllerVar editController;
|
||||
AudioUnitVar audioUnit;
|
||||
DynlibVar dynlib;
|
||||
PlugFrameVar plugFrame;
|
||||
IsAttachedVar isAttached;
|
||||
};
|
||||
|
||||
static id alloc ()
|
||||
{
|
||||
static ObjCClass gInstance;
|
||||
return [gInstance.cl alloc];
|
||||
}
|
||||
|
||||
private:
|
||||
struct ObjCClass
|
||||
{
|
||||
Class cl;
|
||||
|
||||
ObjCClass ()
|
||||
{
|
||||
cl = ObjCClassBuilder ()
|
||||
.init ("SMTG_AUView", [NSView class])
|
||||
.addIvar<IPlugView*> (VarNamePlugView)
|
||||
.addIvar<Vst::IEditController*> (VarNameEditController)
|
||||
.addIvar<AudioUnit> (VarNameAudioUnit)
|
||||
.addIvar<FObject*> (VarNameDynlib)
|
||||
.addIvar<AUPlugFrame*> (VarNamePlugFrame)
|
||||
.addIvar<BOOL> (VarNameIsAttached)
|
||||
.addMethod (@selector (initWithEditController:audioUnit:preferredSize:),
|
||||
initWithEditController)
|
||||
.addMethod (@selector (setFrame:), setFrame)
|
||||
.addMethod (@selector (isFlipped), isFlipped)
|
||||
.addMethod (@selector (viewDidMoveToSuperview), viewDidMoveToSuperview)
|
||||
.addMethod (@selector (dealloc), dealloc)
|
||||
.finalize ();
|
||||
}
|
||||
|
||||
static id initWithEditController (id self, SEL cmd, Vst::IEditController* editController,
|
||||
AudioUnit au, NSSize size)
|
||||
{
|
||||
ObjCInstance obj (self);
|
||||
self = obj.callSuper<id (NSRect), id> (@selector (initWithFrame:),
|
||||
NSMakeRect (0, 0, size.width, size.height));
|
||||
if (self)
|
||||
{
|
||||
Instance inst (self);
|
||||
inst.editController->set (editController);
|
||||
editController->addRef ();
|
||||
inst.audioUnit->set (au);
|
||||
auto plugView = editController->createView (Vst::ViewType::kEditor);
|
||||
if (!plugView ||
|
||||
plugView->isPlatformTypeSupported (kPlatformTypeNSView) != kResultTrue)
|
||||
{
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
inst.plugView->set (plugView);
|
||||
auto plugFrame = NEW AUPlugFrame (self);
|
||||
inst.plugFrame->set (plugFrame);
|
||||
plugView->setFrame (plugFrame);
|
||||
|
||||
if (plugView->attached (self, kPlatformTypeNSView) != kResultTrue)
|
||||
{
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
ViewRect vr;
|
||||
if (plugView->getSize (&vr) == kResultTrue)
|
||||
{
|
||||
NSRect newSize = NSMakeRect (0, 0, vr.right - vr.left, vr.bottom - vr.top);
|
||||
[self setFrame:newSize];
|
||||
}
|
||||
inst.isAttached->set (YES);
|
||||
FObject* fObject = nullptr;
|
||||
UInt32 size = sizeof (FObject*);
|
||||
if (AudioUnitGetProperty (au, 64001, kAudioUnitScope_Global, 0, &fObject, &size) ==
|
||||
noErr)
|
||||
{
|
||||
fObject->addRef ();
|
||||
inst.dynlib->set (fObject);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static void setFrame (id self, SEL cmd, NSRect newSize)
|
||||
{
|
||||
Instance inst (self);
|
||||
inst.callSuper<void (NSRect)> (@selector (setFrame:), newSize);
|
||||
ViewRect viewRect (0, 0, newSize.size.width, newSize.size.height);
|
||||
|
||||
if (inst.plugView->get ())
|
||||
inst.plugView->get ()->onSize (&viewRect);
|
||||
}
|
||||
|
||||
static BOOL isFlipped (id self, SEL cmd) { return YES; }
|
||||
|
||||
static void viewDidMoveToSuperview (id self, SEL cmd)
|
||||
{
|
||||
Instance inst (self);
|
||||
if (inst.plugView->get ())
|
||||
{
|
||||
if ([self superview])
|
||||
{
|
||||
if (!inst.isAttached->get ())
|
||||
{
|
||||
if (inst.plugView->get ()->attached (self, kPlatformTypeNSView) ==
|
||||
kResultTrue)
|
||||
{
|
||||
inst.isAttached->set (YES);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst.isAttached->get ())
|
||||
{
|
||||
inst.plugView->get ()->removed ();
|
||||
inst.isAttached->set (NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dealloc (id self, SEL cmd)
|
||||
{
|
||||
Instance inst (self);
|
||||
if (auto plugView = inst.plugView->get ())
|
||||
{
|
||||
if (inst.isAttached->get ())
|
||||
{
|
||||
plugView->setFrame (0);
|
||||
plugView->removed ();
|
||||
}
|
||||
plugView->release ();
|
||||
if (auto plugFrame = inst.plugFrame->get ())
|
||||
plugFrame->release ();
|
||||
|
||||
if (auto editController = inst.editController->get ())
|
||||
{
|
||||
auto refCount = editController->addRef ();
|
||||
if (refCount == 2)
|
||||
editController->terminate ();
|
||||
|
||||
editController->release ();
|
||||
editController->release ();
|
||||
inst.editController->set (nullptr);
|
||||
}
|
||||
}
|
||||
if (auto dynlib = inst.dynlib->get ())
|
||||
dynlib->release ();
|
||||
inst.callSuper<void ()> (@selector (dealloc));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // anonymous
|
||||
} // Steinberg
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@implementation SMTG_AUCocoaUIBase_CLASS_NAME
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
- (unsigned)interfaceVersion
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
- (NSString*)description
|
||||
{
|
||||
return @"Cocoa View";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
- (NSView*)uiViewForAudioUnit:(AudioUnit)inAU withSize:(NSSize)inPreferredSize
|
||||
{
|
||||
using namespace Steinberg;
|
||||
|
||||
Vst::IEditController* editController = 0;
|
||||
UInt32 size = sizeof (Vst::IEditController*);
|
||||
if (AudioUnitGetProperty (inAU, 64000, kAudioUnitScope_Global, 0, &editController, &size) !=
|
||||
noErr)
|
||||
return nil;
|
||||
return [[AUView::alloc () initWithEditController:editController
|
||||
audioUnit:inAU
|
||||
preferredSize:inPreferredSize] autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/auresource.r
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <AudioUnit/AudioUnit.r>
|
||||
#include <AudioUnit/AudioUnitCarbonView.r>
|
||||
|
||||
#include "audiounitconfig.h"
|
||||
/* ----------------------------------------------------------------------------------------------------------------------------------------
|
||||
// audiounitconfig.h needs the following definitions:
|
||||
#define kAudioUnitVersion 0xFFFFFFFF // Version Number, needs to be in hex
|
||||
#define kAudioUnitName "Steinberg: MyVST3 as AudioUnit" // Company Name + Effect Name
|
||||
#define kAudioUnitDescription "My VST3 as AudioUnit" // Effect Description
|
||||
#define kAudioUnitType kAudioUnitType_Effect // can be kAudioUnitType_Effect or kAudioUnitType_MusicDevice
|
||||
#define kAudioUnitComponentSubType 'test' // unique id
|
||||
#define kAudioUnitComponentManuf 'SMTG' // registered company id
|
||||
#define kAudioUnitCarbonView 1 // if 0 no Carbon view support will be added
|
||||
*/
|
||||
|
||||
|
||||
#define kAudioUnitResID_Processor 1000
|
||||
#define kAudioUnitResID_CarbonView 9000
|
||||
|
||||
//----------------------Processor----------------------------------------------
|
||||
|
||||
#define RES_ID kAudioUnitResID_Processor
|
||||
#define COMP_TYPE kAudioUnitType
|
||||
#define COMP_SUBTYPE kAudioUnitComponentSubType
|
||||
#define COMP_MANUF kAudioUnitComponentManuf
|
||||
|
||||
#define VERSION kAudioUnitVersion
|
||||
#define NAME kAudioUnitName
|
||||
#define DESCRIPTION kAudioUnitDescription
|
||||
#define ENTRY_POINT "AUWrapperEntry"
|
||||
|
||||
#include "AUResources.r"
|
||||
|
||||
#if kAudioUnitCarbonView
|
||||
//----------------------View----------------------------------------------
|
||||
|
||||
#define RES_ID kAudioUnitResID_CarbonView
|
||||
#define COMP_TYPE kAudioUnitCarbonViewComponentType
|
||||
#define COMP_SUBTYPE kAudioUnitComponentSubType
|
||||
#define COMP_MANUF kAudioUnitComponentManuf
|
||||
|
||||
#define VERSION kAudioUnitVersion
|
||||
#define NAME "CarbonView"
|
||||
#define DESCRIPTION "CarbonView"
|
||||
#define ENTRY_POINT "AUCarbonViewEntry"
|
||||
|
||||
#include "AUResources.r"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/ausdk.mm
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma clang diagnostic ignored "-Wunused-value"
|
||||
#pragma clang diagnostic ignored "-Wparentheses"
|
||||
#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_7
|
||||
#define MAC_OS_X_VERSION_10_7 1070
|
||||
#endif
|
||||
|
||||
#import "PublicUtility/CAAudioChannelLayout.cpp"
|
||||
#import "PublicUtility/CABundleLocker.cpp"
|
||||
#import "PublicUtility/CAHostTimeBase.cpp"
|
||||
#import "PublicUtility/CAStreamBasicDescription.cpp"
|
||||
#import "PublicUtility/CAVectorUnit.cpp"
|
||||
#import "PublicUtility/CAAUParameter.cpp"
|
||||
|
||||
#import "AUPublic/AUBase/ComponentBase.cpp"
|
||||
#import "AUPublic/AUBase/AUScopeElement.cpp"
|
||||
#import "AUPublic/AUBase/AUOutputElement.cpp"
|
||||
#import "AUPublic/AUBase/AUInputElement.cpp"
|
||||
#import "AUPublic/AUBase/AUBase.cpp"
|
||||
|
||||
#if !__LP64__
|
||||
#ifndef verify_noerr
|
||||
#define verify_noerr(x) x
|
||||
#endif
|
||||
#ifndef verify
|
||||
#define verify(x)
|
||||
#endif
|
||||
#import "AUPublic/AUCarbonViewBase/AUCarbonViewBase.cpp"
|
||||
#import "AUPublic/AUCarbonViewBase/AUCarbonViewControl.cpp"
|
||||
#import "AUPublic/AUCarbonViewBase/AUCarbonViewDispatch.cpp"
|
||||
#import "AUPublic/AUCarbonViewBase/AUControlGroup.cpp"
|
||||
#import "AUPublic/AUCarbonViewBase/CarbonEventHandler.cpp"
|
||||
#endif
|
||||
|
||||
#import "AUPublic/Utility/AUTimestampGenerator.cpp"
|
||||
#import "AUPublic/Utility/AUBuffer.cpp"
|
||||
#import "AUPublic/Utility/AUBaseHelper.cpp"
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
#import "AUPublic/OtherBases/AUMIDIEffectBase.cpp"
|
||||
#import "AUPublic/Utility/AUDebugDispatcher.cpp"
|
||||
#else
|
||||
#import "AUPublic/AUBase/AUPlugInDispatch.cpp"
|
||||
#endif
|
||||
|
||||
#if !CA_USE_AUDIO_PLUGIN_ONLY
|
||||
#import "AUPublic/AUBase/AUDispatch.cpp"
|
||||
#import "AUPublic/OtherBases/MusicDeviceBase.cpp"
|
||||
#import "AUPublic/OtherBases/AUMIDIBase.cpp"
|
||||
#import "AUPublic/OtherBases/AUEffectBase.cpp"
|
||||
#endif
|
||||
|
||||
/// \endcond
|
||||
@@ -0,0 +1,287 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/auwrapper.h
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \cond ignore
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef SMTG_AUWRAPPER_USES_AUSDK
|
||||
#if CA_USE_AUDIO_PLUGIN_ONLY
|
||||
#include "AudioUnitSDK/AUBase.h"
|
||||
#define AUWRAPPER_BASE_CLASS ausdk::AUBase
|
||||
#else
|
||||
#include "AudioUnitSDK/MusicDeviceBase.h"
|
||||
#define AUWRAPPER_BASE_CLASS ausdk::MusicDeviceBase
|
||||
#endif // CA_USE_AUDIO_PLUGIN_ONLY
|
||||
#else
|
||||
#if CA_USE_AUDIO_PLUGIN_ONLY
|
||||
#include "AudioUnits/AUPublic/AUBase/AUBase.h"
|
||||
#define AUWRAPPER_BASE_CLASS AUBase
|
||||
#else
|
||||
#include "AudioUnits/AUPublic/OtherBases/MusicDeviceBase.h"
|
||||
#define AUWRAPPER_BASE_CLASS MusicDeviceBase
|
||||
#endif // CA_USE_AUDIO_PLUGIN_ONLY
|
||||
#endif // SMTG_AUWRAPPER_USES_AUSDK
|
||||
|
||||
#include "public.sdk/source/vst/hosting/eventlist.h"
|
||||
#include "public.sdk/source/vst/hosting/parameterchanges.h"
|
||||
#include "public.sdk/source/vst/hosting/processdata.h"
|
||||
#include "public.sdk/source/vst/utility/ringbuffer.h"
|
||||
#include "public.sdk/source/vst/utility/rttransfer.h"
|
||||
#include "base/source/fstring.h"
|
||||
#include "base/source/timer.h"
|
||||
#include "base/thread/include/flock.h"
|
||||
#include "pluginterfaces/vst/ivstaudioprocessor.h"
|
||||
#include "pluginterfaces/vst/ivsteditcontroller.h"
|
||||
#include "pluginterfaces/vst/ivstmidilearn.h"
|
||||
#include "pluginterfaces/vst/ivstprocesscontext.h"
|
||||
#include "pluginterfaces/vst/ivstunits.h"
|
||||
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Steinberg {
|
||||
class VST3DynLibrary;
|
||||
|
||||
namespace Vst {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------
|
||||
class AUWrapper : public AUWRAPPER_BASE_CLASS, public IComponentHandler, public ITimerCallback
|
||||
{
|
||||
public:
|
||||
#ifdef SMTG_AUWRAPPER_USES_AUSDK
|
||||
using AUElement = ausdk::AUElement;
|
||||
#else
|
||||
using AudioStreamBasicDescription = CAStreamBasicDescription;
|
||||
#endif
|
||||
|
||||
AUWrapper (ComponentInstanceRecord* ci);
|
||||
~AUWrapper ();
|
||||
|
||||
//---ComponentBase---------------------
|
||||
#if !CA_USE_AUDIO_PLUGIN_ONLY && !defined(SMTG_AUWRAPPER_USES_AUSDK)
|
||||
ComponentResult Version () SMTG_OVERRIDE;
|
||||
#endif
|
||||
void PostConstructor () SMTG_OVERRIDE;
|
||||
|
||||
//---AUBase-----------------------------
|
||||
void Cleanup () SMTG_OVERRIDE;
|
||||
ComponentResult Initialize () SMTG_OVERRIDE;
|
||||
#ifdef SMTG_AUWRAPPER_USES_AUSDK
|
||||
std::unique_ptr<AUElement> CreateElement (AudioUnitScope scope, AudioUnitElement element) SMTG_OVERRIDE;
|
||||
#else
|
||||
AUElement* CreateElement (AudioUnitScope scope, AudioUnitElement element) SMTG_OVERRIDE;
|
||||
#endif
|
||||
UInt32 SupportedNumChannels (const AUChannelInfo** outInfo) SMTG_OVERRIDE;
|
||||
bool StreamFormatWritable (AudioUnitScope scope, AudioUnitElement element) SMTG_OVERRIDE;
|
||||
ComponentResult ChangeStreamFormat (AudioUnitScope inScope, AudioUnitElement inElement, const AudioStreamBasicDescription& inPrevFormat, const AudioStreamBasicDescription& inNewFormat) SMTG_OVERRIDE;
|
||||
ComponentResult SetConnection (const AudioUnitConnection& inConnection) SMTG_OVERRIDE;
|
||||
ComponentResult GetParameterInfo (AudioUnitScope inScope, AudioUnitParameterID inParameterID, AudioUnitParameterInfo& outParameterInfo) SMTG_OVERRIDE;
|
||||
ComponentResult SetParameter (AudioUnitParameterID inID, AudioUnitScope inScope, AudioUnitElement inElement, AudioUnitParameterValue inValue, UInt32 inBufferOffsetInFrames) SMTG_OVERRIDE;
|
||||
|
||||
ComponentResult SaveState (CFPropertyListRef* outData) SMTG_OVERRIDE;
|
||||
ComponentResult RestoreState (CFPropertyListRef inData) SMTG_OVERRIDE;
|
||||
|
||||
ComponentResult Render (AudioUnitRenderActionFlags &ioActionFlags, const AudioTimeStamp &inTimeStamp, UInt32 inNumberFrames) SMTG_OVERRIDE;
|
||||
void processOutputEvents (const AudioTimeStamp &inTimeStamp);
|
||||
|
||||
#if !CA_USE_AUDIO_PLUGIN_ONLY && !defined(SMTG_AUWRAPPER_USES_AUSDK)
|
||||
int GetNumCustomUIComponents () SMTG_OVERRIDE;
|
||||
void GetUIComponentDescs (ComponentDescription* inDescArray) SMTG_OVERRIDE;
|
||||
#endif
|
||||
|
||||
#ifdef SMTG_AUWRAPPER_USES_AUSDK
|
||||
OSStatus GetPropertyInfo (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32 &outDataSize, bool &outWritable) SMTG_OVERRIDE;
|
||||
#else
|
||||
OSStatus GetPropertyInfo (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32 &outDataSize, Boolean &outWritable) SMTG_OVERRIDE;
|
||||
#endif
|
||||
ComponentResult GetProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData) SMTG_OVERRIDE;
|
||||
ComponentResult SetProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize) SMTG_OVERRIDE;
|
||||
bool CanScheduleParameters() const SMTG_OVERRIDE;
|
||||
|
||||
Float64 GetLatency () SMTG_OVERRIDE;
|
||||
Float64 GetTailTime () SMTG_OVERRIDE;
|
||||
|
||||
//---Factory presets
|
||||
OSStatus GetPresets (CFArrayRef* outData) const SMTG_OVERRIDE;
|
||||
OSStatus NewFactoryPresetSet (const AUPreset& inNewFactoryPreset) SMTG_OVERRIDE;
|
||||
|
||||
#if !CA_USE_AUDIO_PLUGIN_ONLY
|
||||
//---MusicDeviceBase-------------------------
|
||||
OSStatus HandleNoteOn (UInt8 inChannel, UInt8 inNoteNumber, UInt8 inVelocity, UInt32 inStartFrame) SMTG_OVERRIDE;
|
||||
OSStatus HandleNoteOff (UInt8 inChannel, UInt8 inNoteNumber, UInt8 inVelocity, UInt32 inStartFrame) SMTG_OVERRIDE;
|
||||
ComponentResult StartNote (MusicDeviceInstrumentID inInstrument, MusicDeviceGroupID inGroupID, NoteInstanceID* outNoteInstanceID, UInt32 inOffsetSampleFrame, const MusicDeviceNoteParams &inParams) SMTG_OVERRIDE;
|
||||
ComponentResult StopNote (MusicDeviceGroupID inGroupID, NoteInstanceID inNoteInstanceID, UInt32 inOffsetSampleFrame) SMTG_OVERRIDE;
|
||||
OSStatus GetInstrumentCount (UInt32 &outInstCount) const SMTG_OVERRIDE;
|
||||
|
||||
//---AUMIDIBase------------------------------
|
||||
OSStatus HandleNonNoteEvent (UInt8 status, UInt8 channel, UInt8 data1, UInt8 data2, UInt32 inStartFrame) SMTG_OVERRIDE;
|
||||
#endif
|
||||
|
||||
#if AUSDK_MIDI2_AVAILABLE
|
||||
OSStatus MIDIEventList (UInt32 inOffsetSampleFrame,
|
||||
const struct MIDIEventList* eventList) override;
|
||||
bool handleMIDIEventPacket (UInt32 inOffsetSampleFrame, const MIDIEventPacket* packet);
|
||||
#endif
|
||||
|
||||
//---custom----------------------------------
|
||||
void setControllerParameter (ParamID pid, ParamValue value);
|
||||
|
||||
// return for a given midiChannel the unitID and the ProgramListID
|
||||
bool getProgramListAndUnit (int32 midiChannel, UnitID& unitId, ProgramListID& programListId);
|
||||
|
||||
// restore preset state, add StateType "Project" to stream if loading from project
|
||||
ComponentResult restoreState (CFPropertyListRef inData, bool fromProject);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
#if !CA_USE_AUDIO_PLUGIN_ONLY && !defined(SMTG_AUWRAPPER_USES_AUSDK)
|
||||
static ComponentResult ComponentEntryDispatch (ComponentParameters* params, AUWrapper* This);
|
||||
#endif
|
||||
//------------------------------------------------------------------------
|
||||
static CFBundleRef gBundleRef;
|
||||
//------------------------------------------------------------------------
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
protected:
|
||||
//---from IComponentHandler-------------------
|
||||
tresult PLUGIN_API beginEdit (ParamID tag) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API performEdit (ParamID tag, ParamValue valueNormalized) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API endEdit (ParamID tag) SMTG_OVERRIDE;
|
||||
tresult PLUGIN_API restartComponent (int32 flags) SMTG_OVERRIDE;
|
||||
|
||||
//---from ITimerCallback----------------------
|
||||
void onTimer (Timer* timer) SMTG_OVERRIDE;
|
||||
|
||||
// internal helpers
|
||||
double getSampleRate () const { return sampleRate; }
|
||||
void updateProcessContext ();
|
||||
void syncParameterValues ();
|
||||
void cacheParameterValues ();
|
||||
void clearParameterValueCache ();
|
||||
void updateProgramChangesCache ();
|
||||
|
||||
virtual IPluginFactory* getFactory ();
|
||||
void loadVST3Module ();
|
||||
void unloadVST3Module ();
|
||||
bool validateChannelPair (int inChannelsIn, int inChannelsOut, const AUChannelInfo* info,
|
||||
UInt32 numChanInfo) const;
|
||||
|
||||
IAudioProcessor* audioProcessor;
|
||||
IEditController* editController;
|
||||
|
||||
Timer* timer;
|
||||
|
||||
HostProcessData processData;
|
||||
ParameterChanges processParamChanges;
|
||||
ParameterChanges outputParamChanges;
|
||||
ParameterChangeTransfer transferParamChanges;
|
||||
ParameterChangeTransfer outputParamTransfer;
|
||||
ProcessContext processContext;
|
||||
EventList eventList;
|
||||
|
||||
typedef std::map<ParamID, AudioUnitParameterInfo> CachedParameterInfoMap;
|
||||
typedef std::map<UnitID, UnitInfo> UnitInfoMap;
|
||||
typedef std::vector<String> ClumpGroupVector;
|
||||
|
||||
UnitInfoMap unitInfos;
|
||||
ClumpGroupVector clumpGroups;
|
||||
CachedParameterInfoMap cachedParameterInfos;
|
||||
Steinberg::Base::Thread::FLock parameterCacheChanging;
|
||||
|
||||
NoteInstanceID noteCounter;
|
||||
double sampleRate;
|
||||
ParamID bypassParamID;
|
||||
|
||||
AUPreset* presets;
|
||||
int32 numPresets;
|
||||
ParamID factoryProgramChangedID;
|
||||
|
||||
AUParameterListenerRef paramListenerRef;
|
||||
std::vector<ParameterInfo> programParameters;
|
||||
|
||||
static constexpr int32 kMaxProgramChangeParameters = 16;
|
||||
struct ProgramChangeInfo
|
||||
{
|
||||
ParamID pid {kNoParamId};
|
||||
int32 numPrograms {0};
|
||||
};
|
||||
using ProgramChangeInfoList = std::array<ProgramChangeInfo, kMaxProgramChangeParameters>;
|
||||
using ProgramChangeInfoTransfer = RTTransferT<ProgramChangeInfoList>;
|
||||
ProgramChangeInfoList programChangeInfos;
|
||||
ProgramChangeInfoTransfer programChangeInfoTransfer;
|
||||
|
||||
// midi mapping
|
||||
struct MidiMapping
|
||||
{
|
||||
using CC2ParamMap = std::unordered_map<CtrlNumber, ParamID>;
|
||||
using ChannelList = std::vector<CC2ParamMap>;
|
||||
using BusList = std::vector<ChannelList>;
|
||||
|
||||
BusList busList;
|
||||
bool empty () const { return busList.empty () || busList[0].empty (); }
|
||||
};
|
||||
using MidiMappingTransfer = RTTransferT<MidiMapping>;
|
||||
|
||||
MidiMappingTransfer midiMappingTransfer;
|
||||
MidiMapping midiMappingCache;
|
||||
|
||||
struct MidiLearnEvent
|
||||
{
|
||||
int32 busIndex;
|
||||
int16 channel;
|
||||
CtrlNumber midiCC;
|
||||
};
|
||||
using MidiLearnRingBuffer = OneReaderOneWriter::RingBuffer<MidiLearnEvent>;
|
||||
MidiLearnRingBuffer midiLearnRingBuffer;
|
||||
IPtr<IMidiLearn> midiLearn;
|
||||
|
||||
struct MIDIOutputCallbackHelper;
|
||||
|
||||
int32 midiOutCount; // currently only 0 or 1 supported
|
||||
std::unique_ptr<MIDIOutputCallbackHelper> mCallbackHelper;
|
||||
EventList outputEvents;
|
||||
|
||||
bool isInstrument;
|
||||
bool isBypassed;
|
||||
bool isOfflineRender;
|
||||
|
||||
private:
|
||||
void buildUnitInfos (IUnitInfo* unitInfoController, UnitInfoMap& units) const;
|
||||
void updateMidiMappingCache ();
|
||||
|
||||
IPtr<VST3DynLibrary> dynLib;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
class AutoreleasePool
|
||||
{
|
||||
public:
|
||||
AutoreleasePool () { ap = [[NSAutoreleasePool alloc] init]; }
|
||||
~AutoreleasePool () { [ap drain]; }
|
||||
//------------------------------------------------------------------------
|
||||
protected:
|
||||
NSAutoreleasePool* ap;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // namespace Vst
|
||||
} // namespace Steinberg
|
||||
|
||||
/// \endcond
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : public.sdk/source/vst/auwrapper/auwrapper_prefix.pch
|
||||
// Created by : Steinberg, 12/2007
|
||||
// Description : VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : ausdkpath.xcconfig
|
||||
// Created by : Steinberg, 5/24/12
|
||||
// Description : Xcode configuration file to specify paths to the AU SDK files, VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
// If you are building with Xcode >= 4.x please add the path to your downloaded Audio Tools for Xcode
|
||||
CUSTOM_AU_SDK_PATH=/Applications/Xcode.app/Contents/Developer/Extras/CoreAudio/ // AUWRAPPER_CHANGE
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : auwrapper.xcconfig
|
||||
// Created by : Steinberg, 5/24/12
|
||||
// Description : Xcode configuration file to specify paths to the AU SDK files, VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../../../../base/mac/config/libc++base"
|
||||
#include "ausdkpath"
|
||||
|
||||
PRODUCT_NAME = auwrapper
|
||||
|
||||
HEADER_SEARCH_PATHS = ../../../.. $(DEVELOPER_DIR)/Examples/CoreAudio/** $(DEVELOPER_DIR)/Extras/CoreAudio/** $(DEVELOPER_DIR)/Extras/CoreAudio/AudioUnits/AUPublic/AUViewBase/** ../../../../external.apple.coreaudio/**
|
||||
GCC_PREFIX_HEADER = auwrapper_prefix.pch
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
|
||||
CLANG_CXX_LANGUAGE_STANDARD = c++17
|
||||
CLANG_CXX_LIBRARY = libc++
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : ausdkpath_debug.xcconfig
|
||||
// Created by : Steinberg, 5/24/12
|
||||
// Description : Xcode configuration file to specify paths to the AU SDK files, VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../../../../base/mac/config/debug"
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = 0
|
||||
DEPLOYMENT_POSTPROCESSING = NO
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Helpers
|
||||
// Filename : auwrapper_release.xcconfig
|
||||
// Created by : Steinberg, 5/24/12
|
||||
// Description : Xcode configuration file to specify paths to the AU SDK files, VST 3 -> AU Wrapper
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../../../../base/mac/config/release"
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = 3
|
||||
DEPLOYMENT_POSTPROCESSING = NO
|
||||
@@ -0,0 +1,55 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Project : VST SDK
|
||||
//
|
||||
// Category : Validator
|
||||
// Filename : usediids.cpp
|
||||
// Created by : Steinberg 09.2008
|
||||
// Description : Interface symbols file
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file is part of a Steinberg SDK. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this distribution
|
||||
// and at www.steinberg.net/sdklicenses.
|
||||
// No part of the SDK, including this file, may be copied, modified, propagated,
|
||||
// or distributed except according to the terms contained in the LICENSE file.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//#define INIT_CLASS_IID
|
||||
// This macro definition modifies the behavior of DECLARE_CLASS_IID (funknown.h)
|
||||
// and produces the actual symbols for all interface identifiers.
|
||||
// It must be defined before including the interface headers and
|
||||
// in only one source file!
|
||||
//------------------------------------------------------------------------
|
||||
//#define INIT_CLASS_IID
|
||||
|
||||
#include "pluginterfaces/vst/ivstaudioprocessor.h"
|
||||
#include "pluginterfaces/vst/ivsteditcontroller.h"
|
||||
#include "pluginterfaces/vst/ivsthostapplication.h"
|
||||
#include "pluginterfaces/vst/ivstmidilearn.h"
|
||||
#include "pluginterfaces/vst/ivstparameterchanges.h"
|
||||
#include "pluginterfaces/vst/ivstpluginterfacesupport.h"
|
||||
#include "pluginterfaces/vst/ivstevents.h"
|
||||
#include "pluginterfaces/vst/ivstunits.h"
|
||||
|
||||
namespace Steinberg {
|
||||
DEF_CLASS_IID (Vst::IAttributeList)
|
||||
DEF_CLASS_IID (Vst::IAudioProcessor)
|
||||
DEF_CLASS_IID (Vst::IEditController)
|
||||
DEF_CLASS_IID (Vst::IEditController2)
|
||||
DEF_CLASS_IID (Vst::IComponent)
|
||||
DEF_CLASS_IID (Vst::IComponentHandler)
|
||||
DEF_CLASS_IID (Vst::IConnectionPoint)
|
||||
DEF_CLASS_IID (Vst::IEventList)
|
||||
DEF_CLASS_IID (Vst::IHostApplication)
|
||||
DEF_CLASS_IID (Vst::IMessage)
|
||||
DEF_CLASS_IID (Vst::IMidiLearn)
|
||||
DEF_CLASS_IID (Vst::IMidiMapping)
|
||||
DEF_CLASS_IID (Vst::IParameterChanges)
|
||||
DEF_CLASS_IID (Vst::IParamValueQueue)
|
||||
DEF_CLASS_IID (Vst::IPlugInterfaceSupport)
|
||||
DEF_CLASS_IID (Vst::IProgramListData)
|
||||
DEF_CLASS_IID (Vst::IStreamAttributes)
|
||||
DEF_CLASS_IID (Vst::IVst3ToAUWrapper)
|
||||
DEF_CLASS_IID (Vst::IUnitData)
|
||||
DEF_CLASS_IID (Vst::IUnitInfo)
|
||||
}
|
||||
Reference in New Issue
Block a user