Re: VSTGUI in AU ?
Re: VSTGUI in AU ?
- Subject: Re: VSTGUI in AU ?
- From: Nikolaus Gerteis <email@hidden>
- Date: Mon, 25 Aug 2003 15:17:08 +0200
On Friday, August 22, 2003, at 05:09 PM, email@hidden wrote:
is this possible ?
has anybody done this yet ?
in CreateUI i try to send the mCaronWindow to the vst
editor->open(void*
ptr) function.
but nothing happens (no crash!) my gui just doesn't appear.
Robert,
you may have to connect to the resource file and do some event handling
work. See if the code below is useful for you.
Niko
------------------------------------------------------------------------
-------------------------------------------------
//
------------------------------------------------------------------------
-----
OSStatus CVST2AUView::CreateUI(Float32 rX, Float32 rY)
{
// -> V1.1: Put the unique bundle identifier here
// Get the bundle reference with the bundle ID
CFBundleRef tRef=CFBundleGetBundleWithIdentifier(CFSTR("VST2AUDemo"));
// <- V1.1
// Open the resources
const SInt16 s16OldRes=CurResFile();
const SInt16 s16Res=CFBundleOpenBundleResourceMap(tRef);
UseResFile(s16Res);
// Get the calling Audio Unit
const AudioUnit tAU=GetEditAudioUnit();
// Get the this-ptr. This is very dirty!
AudioEffect* ptrEffect=NULL;
UInt32 u32Size=sizeof(AudioEffect*);
AudioUnitGetProperty(tAU, kVST2AudioUnitProperty_AudioEffectPtr,
kAudioUnitScope_Global, 0, (void*)(&ptrEffect), &u32Size);
// Create the VST GUI
m_pcVSTGUI=new VST2AU_GUI_CLASS(ptrEffect);
ERect* psRect=NULL;
m_pcVSTGUI->getRect(&psRect);
psRect->left+=UInt32(rX);
psRect->top+=UInt32(rY);
psRect->right+=UInt32(rX);
psRect->bottom+=UInt32(rY);
m_u32Left=psRect->left;
m_u32Top=psRect->top;
m_u32Bottom=psRect->bottom;
m_u32Right=psRect->right;
m_pcVSTGUI->open(WindowPtr(mCarbonWindow));
mBottomRight.v=psRect->bottom;
mBottomRight.h=psRect->right;
GrafPtr tPort;
GetPort(&tPort);
SetPortWindowPort(mCarbonWindow);
ERect sRect;
sRect.top=0;
sRect.left=0;
sRect.bottom=mBottomRight.v;
sRect.right=mBottomRight.h;
m_pcVSTGUI->draw(&sRect);
SetPort(tPort);
// Set the old resource file
UseResFile(s16OldRes);
// Add some events to the handler
EventTypeSpec asWindowEvents[] =
{
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassWindow, kEventWindowDrawContent },
{ kEventClassWindow, kEventWindowResizeCompleted },
{ kEventClassWindow, kEventWindowDragCompleted },
{ kEventClassWindow, kEventWindowUpdate }
};
WantEventTypes(GetWindowEventTarget(mCarbonWindow),
GetEventTypeCount(asWindowEvents), asWindowEvents);
return noErr;
}
//
------------------------------------------------------------------------
-----
bool CVST2AUView::HandleEvent(EventRef tEvent)
{
const UInt32 kTitleSize=16;
UInt32 iClass=GetEventClass(tEvent);
UInt32 iKind=GetEventKind(tEvent);
if (iClass==kEventClassWindow)
{
if (iKind==kEventWindowUpdate || iKind==kEventWindowDrawContent ||
iKind==kEventWindowResizeCompleted || iKind==kEventWindowDragCompleted)
{
// -> V1.1: Put the unique bundle identifier here
// Get the bundle reference with the bundle ID
CFBundleRef
tRef=CFBundleGetBundleWithIdentifier(CFSTR("VST2AUDemo"));
// <- V1.1
// Open the resources
const SInt16 s16OldRes=CurResFile();
const SInt16 s16Res=CFBundleOpenBundleResourceMap(tRef);
UseResFile(s16Res);
GrafPtr tPort;
GetPort(&tPort);
SetPortWindowPort(mCarbonWindow);
ERect sRect;
sRect.top=0;
sRect.left=0;
sRect.bottom=mBottomRight.v;
sRect.right=mBottomRight.h;
m_pcVSTGUI->draw(&sRect);
SetPort(tPort);
// Set the old resource file
UseResFile(s16OldRes);
return true;
}
}
else if (iClass==kEventClassMouse)
{
if (iKind==kEventMouseDown || iKind==kEventMouseDragged)
{
HIPoint tPnt;
UInt32 u32Modifiers=0;
GetEventParameter(tEvent, kEventParamWindowMouseLocation,
typeHIPoint, NULL, sizeof(HIPoint), NULL, &tPnt);
GetEventParameter(tEvent, kEventParamKeyModifiers, typeUInt32,
NULL, sizeof(UInt32), NULL, &u32Modifiers);
tPnt.y-=kTitleSize;
if (tPnt.x>=m_u32Left && tPnt.x<m_u32Right && tPnt.y>=m_u32Top &&
tPnt.y<m_u32Bottom)
{
GrafPtr tPort;
GetPort(&tPort);
SetPortWindowPort(mCarbonWindow);
SetOrigin(m_u32Left, -m_u32Top);
m_pcVSTGUI->mouse(tPnt.x, tPnt.y);
SetOrigin(0, 0);
SetPort(tPort);
return true;
}
}
}
return false;
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.