Last active
March 22, 2019 07:01
-
-
Save vurdalakov/d9407ce224b468a7c35978086a0e3d84 to your computer and use it in GitHub Desktop.
[C++] Helper class for working with ADOBESDK_String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
class AdobeSdkString | |
{ | |
ADOBESDK_StringSuite1* _stringSuite; | |
ADOBESDK_String _string; | |
BOOL _dispose; | |
public: | |
AdobeSdkString(ADOBESDK_StringSuite1* stringSuite) | |
{ | |
this->_stringSuite = stringSuite; | |
this->_dispose = FALSE; | |
} | |
AdobeSdkString(ADOBESDK_StringSuite1* stringSuite, const char* str) | |
{ | |
this->_stringSuite = stringSuite; | |
this->_dispose = kSPNoError == this->_stringSuite->AllocateFromUTF8((ADOBESDK_UTF8Char*)str, &this->_string); | |
} | |
~AdobeSdkString() | |
{ | |
if (this->_dispose) | |
{ | |
this->_stringSuite->DisposeString(&this->_string); | |
} | |
} | |
operator ADOBESDK_String*() { return &this->_string; } | |
std::string toString() | |
{ | |
uint32_t size = 0; | |
if (this->_stringSuite->CopyToUTF8String(&this->_string, NULL, &size) != kADOBESDK_Error_StringBufferTooSmall) | |
{ | |
return ""; // error | |
} | |
std::string str; | |
str.resize(size); | |
if (kSPNoError == this->_stringSuite->CopyToUTF8String(&this->_string, (ADOBESDK_UTF8Char*)str.data(), &size)) | |
{ | |
str.resize(size - 1); // exclude zero byte | |
return str; | |
} | |
return ""; // error | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ADOBESDK_ControlSurfaceHostLumetriSuite1* pLumetriSuite; | |
ADOBESDK_ControlSurfaceHostLumetriRef lumetriRef; | |
ADOBESDK_StringSuite1* pStringSuite; | |
... | |
uint32_t parameterCount; | |
pLumetriSuite->GetParameterCount(lumetriRef, ¶meterCount); | |
for (uint32_t i = 0; i < parameterCount; i++) | |
{ | |
AdobeSdkString parameterId(pStringSuite); | |
AdobeSdkString parameterName(pStringSuite); | |
float minValue; | |
float maxValue; | |
pLumetriSuite->GetParameter(lumetriRef, i, parameterId, parameterName, &minValue, &maxValue); | |
printf("%d: [%s] '%s' from %f to %f", i, parameterId.toString().c_str(), parameterName.toString().c_str(), minValue, maxValue); | |
... | |
} | |
... | |
AdobeSdkString parameterId(pStringSuite, "Lumetri.Basic.Temperature"); | |
float value; | |
pLumetriSuite->GetParameterValue(lumetriRef, parameterId, &value); | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Vurdalakov,
I implemented the above class in ControlSurface.cpp but the APremiere is stop here
if (this->_stringSuite->CopyToUTF8String(&this->_string, NULL, &size) != kADOBESDK_Error_StringBufferTooSmall)
and give a crash
Exception thrown at 0x00007FFB3B7283E7 (ControlSurfaceSDK.acsrf) in Adobe Premiere Pro.exe: 0xC0000005: Access violation reading location 0x0000000000000010.
This is when I try to convert from ADOBESDK_String to UTF. I can not figure out what I'm wrong with. I tried to convert manually but still unsuccessfully. The interesting part is that in ControlSurfacePlugin.cpp it is misleading without error.
I want to mention that I am not a programmer, but I want to configure new features on my MIDI controller, which I did but I blocked decoding :(
Thank you