iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugCocoaEditorDelegate.mm
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
12#import "IPlugCocoaViewController.h"
13
14using namespace iplug;
15
16CocoaEditorDelegate::CocoaEditorDelegate(int nParams)
17: IEditorDelegate(nParams)
18{
19}
20
21CocoaEditorDelegate::~CocoaEditorDelegate()
22{
23}
24
26{
27#ifdef OS_IOS
28 IPlugCocoaViewController* vc = (IPlugCocoaViewController*) [(PLATFORM_VIEW*) pParent nextResponder];
29 [vc setEditorDelegate: this];
30 mViewController = vc;
31#endif
32
33 return pParent;
34}
35
37{
38 mViewController = nil;
39}
40
41bool CocoaEditorDelegate::OnMessage(int msgTag, int ctrlTag, int dataSize, const void* pData)
42{
44 NSData* pNSData = [NSData dataWithBytes:pData length:dataSize];
45 return [vc onMessage:msgTag : ctrlTag : pNSData];
46}
47
49{
51
52 if(vc)
53 [vc onParamChangeUI:paramIdx :GetParam(paramIdx)->GetNormalized() ];
54}
55
57{
58 [(IPlugCocoaViewController*) mViewController onMidiMsgUI:msg.mStatus : msg.mData1 : msg.mData2 : msg.mOffset];
59}
60
62{
63 NSData* pNSData = [NSData dataWithBytes:msg.mData length:msg.mSize];
64
65 [(IPlugCocoaViewController*) mViewController onSysexMsgUI:pNSData : msg.mOffset];
66}
67
68void CocoaEditorDelegate::SendControlValueFromDelegate(int ctrlTag, double normalizedValue)
69{
70 [(IPlugCocoaViewController*) mViewController sendControlValueFromDelegate:ctrlTag :normalizedValue];
71}
72
73void CocoaEditorDelegate::SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize, const void* pData)
74{
75 NSData* pNSData = [NSData dataWithBytes:pData length:dataSize];
76
77 [(IPlugCocoaViewController*) mViewController sendControlMsgFromDelegate: ctrlTag : msgTag : pNSData];
78}
79
80void CocoaEditorDelegate::SendParameterValueFromDelegate(int paramIdx, double value, bool normalized)
81{
82 [(IPlugCocoaViewController*) mViewController sendParameterValueFromDelegate:paramIdx :value :normalized];
83
84 IEditorDelegate::SendParameterValueFromDelegate(paramIdx, value, normalized);
85}
void OnSysexMsgUI(const ISysEx &msg) override
Handle incoming SysEx messages sent to the user interface.
void * OpenWindow(void *pParent) override
If you are not using IGraphics, you can implement this method to attach to the native parent view e....
void SendControlValueFromDelegate(int ctrlTag, double normalizedValue) override
SendControlValueFromDelegate (Abbreviation: SCVFD) WARNING: should not be called on the realtime audi...
void CloseWindow() override
If you are not using IGraphics you can if you need to free resources etc when the window closes.
bool OnMessage(int msgTag, int ctrlTag, int dataSize, const void *pData) override
This could be implemented in either DSP or EDITOR to receive a message from the other one.
void OnMidiMsgUI(const IMidiMsg &msg) override
Handle incoming MIDI messages sent to the user interface.
void OnParamChangeUI(int paramIdx, EParamSource source) override
Override this method to do something when a parameter changes on the main/UI thread Like OnParamChang...
void SendParameterValueFromDelegate(int paramIdx, double value, bool normalized) override
SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime au...
void SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize, const void *pData) override
SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio ...
This pure virtual interface delegates communication in both directions between a UI editor and someth...
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate's IParam objects.
virtual void SendParameterValueFromDelegate(int paramIdx, double value, bool normalized)
SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime au...
double GetNormalized() const
Returns the parameter's normalized value.
EParamSource
Used to identify the source of a parameter change.
An objc view controller base which reproduces some functionality from EditorDelegate in objc.
Encapsulates a MIDI message and provides helper functions.
Definition: IPlugMidi.h:31
A struct for dealing with SysEx messages.
Definition: IPlugMidi.h:539