本文整理汇总了C++中TTObject::instance方法的典型用法代码示例。如果您正苦于以下问题:C++ TTObject::instance方法的具体用法?C++ TTObject::instance怎么用?C++ TTObject::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTObject
的用法示例。
在下文中一共展示了TTObject::instance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TTLogMessage
TTErr
DemoAppDataReturnValueCallback(const TTValue& baton, const TTValue& value)
{
DemoApp* demoApp = (DemoApp*)TTPtr(baton[0]);
TTObject anObject = baton[1];
// Reteive which data has been updated
if (anObject.instance() == demoApp->mDataDemoParameter.instance()) {
// print the returned value
TTLogMessage("/myParameter has been updated to %s \n", value.toString().data());
return kTTErrNone;
}
if (anObject.instance() == demoApp->mDataDemoMessage.instance()) {
// print the returned value
TTLogMessage("/myMessage has been updated to %s \n", value.toString().data());
return kTTErrNone;
}
if (anObject.instance() == demoApp->mDataDemoReturn.instance()) {
// print the returned value
TTLogMessage("/myReturn has been updated to %s \n", value.toString().data());
return kTTErrNone;
}
return kTTErrGeneric;
}
示例2: process
void TTInputAudio::process(TTSampleValue* anInputSampleVector, TTSampleValue* anOutputSampleVector, TTUInt16 aVectorSize)
{
// Store the input from the inlets
TTAudioSignalPtr(mSignalIn.instance())->setVector64Copy(0, aVectorSize, anInputSampleVector);
// Sum signal from j.send~ objects
for (mSignalCache.begin(); mSignalCache.end(); mSignalCache.next()) {
TTObject o = mSignalCache.current()[0];
TTAudioSignalPtr sentSignal = TTAudioSignalPtr(o.instance());
if (sentSignal)
*TTAudioSignalPtr(mSignalIn.instance()) += *sentSignal;
}
// if signal is bypassed or muted, send a zero signal to the algorithm
if (mBypass || mMute)
TTAudioSignal::copy(*TTAudioSignalPtr(mSignalZero.instance()), *TTAudioSignalPtr(mSignalOut.instance()));
// else copy in to out
else
TTAudioSignal::copy(*TTAudioSignalPtr(mSignalIn.instance()), *TTAudioSignalPtr(mSignalOut.instance()));
// clear the signal cache
mSignalCache.clear();
// Send the input on to the outlets for the algorithm, if desired
if (anOutputSampleVector)
TTAudioSignalPtr(mSignalOut.instance())->getVectorCopy(0, aVectorSize, anOutputSampleVector);
}
示例3: TTProtocolAttributeCallback
TTErr TTProtocolAttributeCallback(const TTValue& baton, const TTValue& data)
{
TTObject aProtocol;
TTSymbol anApplicationName;
TTAddress anAddress;
// unpack baton
aProtocol = baton[0];
anApplicationName = baton[1];
anAddress = baton[2];
if (TTProtocolPtr(aProtocol.instance())->mRunning)
return TTProtocolPtr(aProtocol.instance())->SendListenAnswer(anApplicationName, anAddress, data);
else
return kTTErrGeneric;
}
示例4: TTProtocolListenAttributeCallback
TTErr TTProtocolListenAttributeCallback(const TTValue& baton, const TTValue& data)
{
TTObject aProtocol;
TTSymbol anApplicationName;
TTAddress anAddress;
TTSymbol attribute;
TTBoolean enable;
// unpack baton
aProtocol = baton[0];
anApplicationName = baton[1];
anAddress = baton[2];
// unpack data
attribute = data[0];
enable = data[1];
// send a listen request
if (TTProtocolPtr(aProtocol.instance())->mRunning)
return TTProtocolPtr(aProtocol.instance())->SendListenRequest(anApplicationName, anAddress.appendAttribute(attribute), enable);
else
return kTTErrGeneric;
}
示例5: TTProtocolSendMessageCallback
TTErr TTProtocolSendMessageCallback(const TTValue& baton, const TTValue& data)
{
TTValuePtr value;
TTObject aProtocol;
TTSymbol anApplicationName;
TTAddress anAddress;
TTSymbol message;
// unpack baton
aProtocol = baton[0];
anApplicationName = baton[1];
anAddress = baton[2];
// unpack data
message = data[0];
value = TTValuePtr((TTPtr)data[1]);
// send a set request
if (TTProtocolPtr(aProtocol.instance())->mRunning)
return TTProtocolPtr(aProtocol.instance())->SendSetRequest(anApplicationName, anAddress.appendAttribute(message), *value);
else
return kTTErrGeneric;
}
示例6: TTProtocolDirectoryCallback
TTErr TTProtocolDirectoryCallback(const TTValue& baton, const TTValue& data)
{
TTObject aProtocol;
TTSymbol anApplicationName;
TTAddress anAddress;
TTNodePtr aNode;
TTUInt8 flag;
TTObject anObserver;
TTValue v;
// unpack baton
aProtocol = baton[0];
anApplicationName = baton[1];
// unpack data (anAddress, aNode, flag, anObserver)
anAddress = data[0];
aNode = TTNodePtr((TTPtr)data[1]);
flag = data[2];
anObserver = data[3];
if (flag == kAddressCreated) {
if (aNode->getObject().valid())
v.append(aNode->getObject().name());
else
v.append(kTTSym_none);
}
else if (flag == kAddressDestroyed) {
v.append(TTSymbol("delete"));
}
if (TTProtocolPtr(aProtocol.instance())->mRunning)
return TTProtocolPtr(aProtocol.instance())->SendListenAnswer(anApplicationName, anAddress.appendAttribute(TTSymbol("life")), v);
else
return kTTErrGeneric;
}
示例7:
TTObjectBasePtr getSelectedObject(WrappedModularInstancePtr x)
{
if (x->useInternals) {
TTValue v;
TTObject o;
TTErr err;
err = x->internals->lookup(x->cursor, v);
if (!err)
o = v[0];
return o.instance();
}
#ifndef ARRAY_EXTERNAL
else
return x->wrappedObject.instance();
#else
else
return NULL;
示例8: WriteAsText
TTErr TTData::WriteAsText(const TTValue& inputValue, TTValue& outputValue)
{
TTObject o = inputValue[0];
TTTextHandlerPtr aTextHandler = (TTTextHandlerPtr)o.instance();
if (!aTextHandler)
return kTTErrGeneric;
TTString *buffer;
TTValue toString;
TTString line;
buffer = aTextHandler->mWriter;
// Type
*buffer += "\t\t\t<td class =\"instructionType\">";
*buffer += this->mType.c_str();
*buffer += "</td>";
// range/bounds
toString = this->mRangeBounds;
toString.toString();
line = TTString(toString[0]);
if ( (this->mType == kTTSym_integer) || (this->mType == kTTSym_boolean) || (this->mType == kTTSym_decimal) || (this->mType == kTTSym_generic) ) {
*buffer +="\t\t\t<td class =\"instructionRangeBounds\">";
*buffer +=line.data();
*buffer += "</td>";
}
else
*buffer += "\t\t\t<td class = \"instructionRangeBounds\"> N/A </td>";
// clipmode
*buffer += "\t\t\t<td class =\"instructionRangeClipmode\">";
*buffer += this->mRangeClipmode.c_str();
*buffer += "</td>";
// ramp/drive
*buffer += "\t\t\t<td class =\"instructionRampDrive\">";
*buffer += this->mRampDrive.c_str();
*buffer += "</td>";
#ifndef TT_NO_DSP
// ramp/function
*buffer += "\t\t\t<td class =\"instructionRampFunction\">";
*buffer += this->mRampFunction.c_str();
*buffer += "</td>";
#endif
// dataspace
*buffer += "\t\t\t<td class =\"instructionDataspace\">";
*buffer += this->mDataspace.c_str();
*buffer += "</td>";
// dataspace/unit
*buffer += "\t\t\t<td class =\"instructionDataspaceUnit\">";
*buffer += this->mDataspaceUnit.c_str();
*buffer += "</td>";
// repetitions/filter
toString = this->mRepetitionsFilter;
toString.toString();
line = TTString(toString[0]);
*buffer += "\t\t\t<td class =\"instructionRepetitionsFilter\">";
*buffer += line.data();
*buffer += "</td>";
// description
*buffer += "\t\t\t<td class =\"instructionDescription\">";
*buffer += this->mDescription.c_str();
*buffer += "</td>";
return kTTErrNone;
}
示例9: wrapTTModularClassAsMaxClass
TTErr wrapTTModularClassAsMaxClass(TTSymbol& ttblueClassName, const char* maxClassName, WrappedClassPtr* c, ModularSpec* specificities)
{
TTObject o;
TTValue v, args;
WrappedClass* wrappedMaxClass = NULL;
TTSymbol TTName;
t_symbol *MaxName = NULL;
TTUInt16 i;
jamoma_init();
common_symbols_init();
if (!wrappedMaxClasses)
wrappedMaxClasses = hashtab_new(0);
wrappedMaxClass = new WrappedClass;
wrappedMaxClass->maxClassName = gensym(maxClassName);
wrappedMaxClass->maxClass = class_new( maxClassName,
(method)wrappedModularClass_new,
(method)wrappedModularClass_free,
sizeof(WrappedModularInstance),
(method)0L,
A_GIMME,
0);
wrappedMaxClass->ttblueClassName = ttblueClassName;
wrappedMaxClass->validityCheck = NULL;
wrappedMaxClass->validityCheckArgument = NULL;
wrappedMaxClass->options = NULL;
wrappedMaxClass->maxNamesToTTNames = hashtab_new(0);
wrappedMaxClass->specificities = specificities;
#ifdef AUDIO_EXTERNAL
// Setup our class to work with MSP
class_dspinit(wrappedMaxClass->maxClass);
#endif
// Create a temporary instance of the class so that we can query it.
o = TTObject(ttblueClassName);
// Register Messages as Max method
o.messages(v);
for (i = 0; i < v.size(); i++)
{
TTName = v[i];
if (TTName == TTSymbol("test") ||
TTName == TTSymbol("getProcessingBenchmark") ||
TTName == TTSymbol("resetBenchmarking"))
continue;
else if ((MaxName = jamoma_TTName_To_MaxName(TTName)))
{
hashtab_store(wrappedMaxClass->maxNamesToTTNames, MaxName, (t_object*)(TTName.rawpointer()));
class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_anything, MaxName->s_name, A_GIMME, 0);
}
}
// Register Attributes as Max attr
o.attributes(v);
for (i = 0; i < v.size(); i++) {
TTAttributePtr attr = NULL;
t_symbol *maxType = _sym_atom;
TTName = v[i];
#ifdef AUDIO_EXTERNAL
// the enable word is already used by a message declared in the dsp_init method
if (TTName == TTSymbol("enable"))
continue;
#endif
// we want to hide service attribute for Max external
if (TTName == TTSymbol("service"))
continue;
if ((MaxName = jamoma_TTName_To_MaxName(TTName))) {
if (TTName == kTTSym_bypass && wrappedMaxClass->maxClassName != gensym("j.in") && wrappedMaxClass->maxClassName != gensym("j.in~"))
continue;
o.instance()->findAttribute(TTName, &attr);
if (attr->type == kTypeFloat32)
maxType = _sym_float32;
else if (attr->type == kTypeFloat64)
maxType = _sym_float64;
else if (attr->type == kTypeSymbol || attr->type == kTypeString)
maxType = _sym_symbol;
else if (attr->type == kTypeLocalValue)
maxType = _sym_atom;
hashtab_store(wrappedMaxClass->maxNamesToTTNames, MaxName, (t_object*)(TTName.rawpointer()));
class_addattr(wrappedMaxClass->maxClass, attr_offset_new(MaxName->s_name, maxType, 0, (method)wrappedModularClass_attrGet, (method)wrappedModularClass_attrSet, 0));
// Add display styles for the Max 5 inspector
if (attr->type == kTypeBoolean)
CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, (char*)TTName.c_str(), 0, "onoff");
if (TTName == TTSymbol("fontFace"))
CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, "fontFace", 0, "font");
}
//.........这里部分代码省略.........
示例10: test
TTErr TTSoundfileLoader::test(TTValue& returnedTestInfo)
{
int errorCount = 0;
int testAssertionCount = 0;
// assemble the full path of the target sound file
TTString testSoundPath = TTFoundationBinaryPath;
int pos = testSoundPath.find_last_of('/');
testSoundPath = testSoundPath.substr(0,pos+1);
testSoundPath += TESTFILE;
std::cout << "We will be using the following path for testing: " << testSoundPath << "\n";
try {
TTTestLog("\n");
TTTestLog("Testing TTSoundfileLoader Basics...");
// TEST 0: establish our objects & pointers
TTObject* testTargetMatrix = new TTObject("samplematrix");
TTObject* testNonSampleMatrix = new TTObject("delay");
TTObjectBase* objectBasePtrToSampleMatrix;
TTObjectBase* ptrToNonSampleMatrix;
// TEST 1: set the filepath
TTBoolean result1 = { this->setFilePath(TT(testSoundPath)) == kTTErrNone };
TTTestAssertion("setFilePath operates successfully",
result1,
testAssertionCount,
errorCount);
// TEST 2: set up the samplematrix first
int channelsSend = 1; // compiler complained about TTInt32 being ambiguous here
int lengthSend = 22050; // compiler complained about TTInt32 being ambiguous here
testTargetMatrix->set("numChannels", channelsSend);
testTargetMatrix->set("lengthInSamples", lengthSend);
TTInt32 channelsReturn, lengthReturn;
testTargetMatrix->get("numChannels", channelsReturn);
testTargetMatrix->get("lengthInSamples", lengthReturn);
// now for the actual test
TTBoolean result2a = { channelsSend == channelsReturn };
TTTestAssertion("numChannels attribute set successfully",
result2a,
testAssertionCount,
errorCount);
TTBoolean result2b = { lengthSend == lengthReturn };
TTTestAssertion("lengthInSamples attribute set successfully",
result2b,
testAssertionCount,
errorCount);
//
// TEST 3: set the target via an objectBasePtr
objectBasePtrToSampleMatrix = testTargetMatrix->instance(); // is there a better syntax for this?
TTBoolean result3 = { this->setTargetMatrix(objectBasePtrToSampleMatrix) == kTTErrNone };
TTTestAssertion("setTargetMatrix via ObjectBasePtr operates successfully",
result3,
testAssertionCount,
errorCount);
// TEST 4: set the target to a non-SampleMatrix, should FAIL
ptrToNonSampleMatrix = testNonSampleMatrix->instance();
TTBoolean result4 = { this->setTargetMatrix(ptrToNonSampleMatrix) == kTTErrInvalidValue };
TTTestAssertion("setTargetMatrix returns error when not a SampleMatrix",
result4,
testAssertionCount,
errorCount);
// TEST 5: copy samplevalues until samplematrix is filled
TTBoolean result5 = { this->copyUntilFilled() == kTTErrNone };
TTTestAssertion("copyUntilFilled operates successfully",
result5,
testAssertionCount,
errorCount);
// releasing objects
objectBasePtrToSampleMatrix = NULL;
ptrToNonSampleMatrix = NULL;
delete testTargetMatrix;
delete testNonSampleMatrix;
// TEST 6: use TTSampleMatrix's load message, then compare 5 random sample values for equivalence
// create a new TTSampleMatrix
TTObject newTargetMatrix("samplematrix");
//.........这里部分代码省略.........
示例11:
bool operator != (const TTObject& anObject, const TTObject& anotherObject)
{
return (anObject.instance() != anotherObject.instance());
}