本文整理汇总了C++中TTValue类的典型用法代码示例。如果您正苦于以下问题:C++ TTValue类的具体用法?C++ TTValue怎么用?C++ TTValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TTValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createUnit
JamomaError RampLib::createUnit(const TTSymbol* unitName, RampUnit **unit, RampUnitCallback callback, void* baton)
{
TTValue v;
v.setSize(2);
v.set(0, TTPtr(callback));
v.set(1, TTPtr(baton));
// These should be alphabetized
if (unitName == TT("async"))
TTObjectInstantiate(TT("AsyncRamp"), (TTObjectPtr*)unit, v);
//*unit = (RampUnit*) new AsyncRamp(callback, baton);
else if (unitName == TT("none"))
TTObjectInstantiate(TT("NoneRamp"), (TTObjectPtr*)unit, v);
// *unit = (RampUnit*) new NoneRamp(callback, baton);
else if (unitName == TT("queue"))
TTObjectInstantiate(TT("QueueRamp"), (TTObjectPtr*)unit, v);
// *unit = (RampUnit*) new QueueRamp(callback, baton);
else if (unitName == TT("scheduler"))
TTObjectInstantiate(TT("SchedulerRamp"), (TTObjectPtr*)unit, v);
// *unit = (RampUnit*) new SchedulerRamp(callback, baton);
else {
// Invalid function specified default to linear
error("Jamoma RampLib: Invalid RampUnit ( %s ) specified", (char*)unitName);
TTObjectInstantiate(TT("NoneRamp"), (TTObjectPtr*)unit, v);
// *unit = (RampUnit*) new NoneRamp(callback, baton);
}
return JAMOMA_ERR_NONE;
}
示例2: TTScoreTimeProcessCreate
TTErr TTScoreTimeProcessCreate(TTTimeProcessPtr *timeProcess, const std::string timeProcessClass, TTTimeEventPtr startEvent, TTTimeEventPtr endEvent, TTTimeContainerPtr timeContainer)
{
TTValue args;
*timeProcess = NULL;
if (timeContainer) {
TTValue out;
TTErr err;
args = TTSymbol(timeProcessClass);
args.append(TTObjectBasePtr(startEvent));
args.append(TTObjectBasePtr(endEvent));
err = timeContainer->sendMessage(TTSymbol("TimeProcessCreate"), args, out);
if (!err)
*timeProcess = TTTimeProcessPtr(TTObjectBasePtr(out[0]));
return err;
}
else {
args = TTObjectBasePtr(startEvent);
args.append(TTObjectBasePtr(endEvent));
return TTObjectBaseInstantiate(timeProcessClass.c_str(), TTObjectBaseHandle(timeProcess), args);
}
}
示例3: UnpackNew
t_unpack* UnpackNew(t_symbol *msg, long argc, t_atom* argv)
{
t_unpack* self;
TTValue sr(sys_getsr());
long attrstart = attr_args_offset(argc, argv); // support normal arguments
short i;
TTValue v;
TTErr err;
self = (t_unpack*)object_alloc(sUnpackClass);
if (self) {
self->maxNumChannels = 2; // An initial argument to this object will set the maximum number of channels
if (attrstart && argv)
self->maxNumChannels = atom_getlong(argv);
ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
v.resize(2);
v[0] = "thru";
v[1] = 1; // arg is the number of inlets
err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
//self->audioGraphObject->getUnitGenerator()->setAttributeValue(TT("linearGain"), 1.0);
attr_args_process(self, argc, argv);
object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); // dumpout
dsp_setup((t_pxobject*)self, 1);
for (i=0; i < self->maxNumChannels; i++)
outlet_new((t_pxobject*)self, "signal");
self->qelem = qelem_new(self, (method)UnpackQFn);
self->obj.z_misc = Z_NO_INPLACE | Z_PUT_LAST;
}
return self;
}
示例4: InfoNew
InfoPtr InfoNew(t_symbol* msg, long argc, t_atom* argv)
{
InfoPtr self;
TTValue v;
TTErr err;
self = InfoPtr(object_alloc(sInfoClass));
if (self) {
object_obex_store((TTPtr)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));
self->outletNumChannels = outlet_new((t_pxobject*)self, 0);
self->outletVectorSize = outlet_new((t_pxobject*)self, 0);
self->outletSampleRate = outlet_new((t_pxobject*)self, 0);
self->outletSmartSignal = outlet_new((t_pxobject*)self, "audio.connect");
self->qelem = qelem_new(self, (method)InfoQfn);
v.resize(2);
v[0] = "thru";
v[1] = 1; // we set it up with 1 inlet, and later modify to 2 inlets if the connection is made
err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
if (!self->audioGraphObject->getUnitGenerator().valid()) {
object_error(SELF, "cannot load Jamoma DSP object");
return NULL;
}
attr_args_process(self, argc, argv);
}
return self;
}
示例5: UnpackNew
UnpackPtr UnpackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
UnpackPtr self;
TTValue v;
TTErr err;
self = UnpackPtr(object_alloc(sUnpackClass));
if (self) {
object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); // dumpout
self->graphOutlets[0] = outlet_new(self, NULL);
v.setSize(2);
v.set(0, TT("graph.output"));
v.set(1, TTUInt32(1));
err = TTObjectInstantiate(TT("graph.object"), (TTObjectPtr*)&self->graphObject, v);
if (!self->graphObject->mKernel) {
object_error(SELF, "cannot load Jamoma object");
return NULL;
}
err = TTObjectInstantiate(TT("Callback"), (TTObjectPtr*)&self->callback, kTTValNONE);
self->callback->setAttributeValue(TT("Function"), TTPtr(&UnpackGraphCallback));
self->callback->setAttributeValue(TT("Baton"), TTPtr(self));
// dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification
self->callback->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue);
// tell the graph object that we want to watch it
self->graphObject->mKernel->registerObserverForNotifications(*self->callback);
attr_args_process(self, argc, argv);
}
return self;
}
示例6: PlugOutNew
PlugOutPtr PlugOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
PlugOutPtr self = PlugOutPtr(object_alloc(sPlugOutClass));
TTValue v;
TTErr err;
if (self) {
v.setSize(2);
v.set(0, TT("plugtastic.output"));
v.set(1, 2);
err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
v = TTPtr(self->audioGraphObject);
object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));
self->audioGraphOutlet = outlet_new(self, "audio.connect");
self->qelem = qelem_new(self, (method)PlugOutQFn);
object_obex_lookup(self, GENSYM("#P"), &self->patcher);
self->pluginName = object_attr_getsym(self->patcher, _sym_name);
self->pluginVersion = GENSYM("1.0");
self->pluginVersionHex = GENSYM("0x00010000");
self->pluginManufacturer = GENSYM("Plugtastic");
self->pluginManufacturerCode = GENSYM("74Ob");
self->pluginID = GENSYM("ftmp");
attr_args_process(self, argc, argv);
}
return self;
}
示例7: convertFromNeutral
void CMYUnit::convertFromNeutral(const TTValue& input, TTValue& output)
{
output.setSize(3);
output.set(0, 255 * (1 - input.getFloat64(0)));
output.set(1, 255 * (1 - input.getFloat64(1)));
output.set(2, 255 * (1 - input.getFloat64(2)));
}
示例8: wrappedClass_attrSet
t_max_err wrappedClass_attrSet(WrappedInstancePtr self, t_object* attr, long argc, t_atom* argv)
{
if (argc && argv) {
t_symbol* attrName = (t_symbol*)object_method(attr, _sym_getname);
TTValue v;
long i;
t_max_err err;
TTPtr ptr;
err = hashtab_lookup(self->wrappedClassDefinition->maxNamesToTTNames, attrName, (t_object**)&ptr);
if (err)
return err;
TTSymbol ttAttrName(ptr);
v.resize(argc);
for (i=0; i<argc; i++) {
if (atom_gettype(argv+i) == A_LONG)
v[i] = (TTInt32)atom_getlong(argv+i);
else if (atom_gettype(argv+i) == A_FLOAT)
v[i] = atom_getfloat(argv+i);
else if (atom_gettype(argv+i) == A_SYM)
v[i] = TT(atom_getsym(argv+i)->s_name);
else
object_error(SELF, "bad type for attribute setter");
}
self->graphObject->mKernel.set(ttAttrName, v);
return MAX_ERR_NONE;
}
return MAX_ERR_GENERIC;
}
示例9: OpNew
OpPtr OpNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
OpPtr self;
TTValue v;
TTErr err;
self = OpPtr(object_alloc(sOpClass));
if (self) {
object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL)); // dumpout
self->outlet = outlet_new(self, "audio.connect");
self->inlet = proxy_new(self, 1, &self->inletnum);
v.setSize(2);
v.set(0, TT("operator"));
v.set(1, TTUInt32(1)); // we set it up with 1 inlet, and later modify to 2 inlets if the connection is made
err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v);
if (!self->audioGraphObject->getUnitGenerator()) {
object_error(SELF, "cannot load Jamoma DSP object");
return NULL;
}
attr_args_process(self, argc, argv);
}
return self;
}
示例10: PackAnything
void PackAnything(PackPtr self, t_symbol* s, long ac, t_atom* ap)
{
TTValue v;
v.resize(ac+1);
if (ac > 0) {
self->graphDictionary->setSchema(TT("array"));
v[0] = TT(s->s_name);
for (int i=0; i<ac; i++) {
switch (atom_gettype(ap+i)) {
case A_LONG:
v[i+1] = (int)atom_getlong(ap+i);
break;
case A_FLOAT:
v[i+1] = atom_getfloat(ap+i);
break;
case A_SYM:
v[i+1] = TT(atom_getsym(ap+i)->s_name);
break;
default:
break;
}
}
}
else {
self->graphDictionary->setSchema(TT("symbol"));
v[0] = TT(s->s_name);
}
self->graphDictionary->setValue(v);
((TTGraphInput*)self->graphObject->mKernel.instance())->push(*self->graphDictionary);
}
示例11: PackNew
PackPtr PackNew(t_symbol* msg, long argc, t_atom* argv)
{
PackPtr self;
TTValue v;
TTErr err;
self = PackPtr(object_alloc(sPackClass));
if (self) {
object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));
self->graphOutlets[0] = outlet_new(self, "graph.connect");
v.resize(2);
v[0] = "graph.input";
v[1] = 1;
err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);
((TTGraphInput*)self->graphObject->mKernel.instance())->setOwner(self->graphObject);
if (!self->graphObject->mKernel.valid()) {
object_error(SELF, "cannot load Jamoma object");
return NULL;
}
self->graphDictionary = new TTDictionary;
self->graphDictionary->setSchema(TT("none"));
self->graphDictionary->append(TT("outlet"), 0);
attr_args_process(self, argc, argv);
self->qelem = qelem_new(self, (method)PackQFn);
// PackStartTracking(self);
defer_low(self, (method)PackStartTracking, NULL, 0, NULL);
}
return self;
}
示例12: OpGetOperand
MaxErr OpGetOperand(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv)
{
TTValue v;
self->audioGraphObject->getUnitGenerator()->getAttributeValue(TT("operand"), v);
*argc = v.getSize();
if (!(*argv)) // otherwise use memory passed in
*argv = (t_atom *)sysmem_newptr(sizeof(t_atom) * v.getSize());
for (int i=0; i<v.getSize(); i++) {
if(v.getType(i) == kTypeFloat32 || v.getType(i) == kTypeFloat64){
TTFloat64 value;
v.get(i, value);
atom_setfloat(*argv+i, value);
}
else if(v.getType(i) == kTypeSymbol){
TTSymbol value;
v.get(i, value);
atom_setsym(*argv+i, gensym((char*)value.c_str()));
}
else{ // assume int
TTInt32 value;
v.get(i, value);
atom_setlong(*argv+i, value);
}
}
return MAX_ERR_NONE;
}
示例13: data_list
void data_list(TTPtr self, t_symbol *msg, long argc, const t_atom *argv)
{
WrappedModularInstancePtr x = (WrappedModularInstancePtr)self;
TTObject o;
if (!x->internals->isEmpty()) {
// send to each data
if (x->arrayIndex == 0) {
TTValue keys;
x->internals->getKeys(keys);
for (TTUInt32 i = 0; i < keys.size(); i++) {
x->cursor = keys[i];
o = selectedObject;
jamoma_data_command(o, msg, argc, argv);
}
// watch an instance by default
x->cursor = keys[0];
}
else {
o = selectedObject;
jamoma_data_command(o, msg, argc, argv);
}
}
else
object_error((t_object*)x, "list : the array is empty");
}
示例14: fileToLoad
TTErr TTSampleMatrix::load(const TTValue& input, TTValue& unusedOutput)
{
/* * *
Beware this method is still in progress
It will eventually work with the TTSoundfileLoader class
* * */
TTValue inputWithPointerPrepended = input;
TTObjectBase* objectBasePtrToSampleMatrix = (TTObjectBase*)(TTPtr(this));
inputWithPointerPrepended.prepend(objectBasePtrToSampleMatrix);
try {
// first instantiate the SoundfileLoader object
TTAudioObject fileToLoad("soundfile.loader");
if (fileToLoad.valid())
// then pass along the updated TTValue to its load() method
return fileToLoad.send("load", inputWithPointerPrepended);
else
return kTTErrInstantiateFailed;
}
catch (...) {
return kTTErrInstantiateFailed;
}
}
示例15: DemoAppDataReturnValueCallback
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;
}