19 #define thisTTClass TTData
20 #define thisTTClassName "Data"
21 #define thisTTClassTags "data"
25 return new TTData(arguments);
29 extern "C" void TTData::registerClass()
31 TTClassRegister(
TTSymbol(
"Data"), thisTTClassTags, TTData::instantiate);
35 TTData::TTData(
const TTValue& arguments) :
40 mType(kTTSym_generic),
43 mDescription(kTTSym_none),
44 mRepetitionsFilter(NO),
47 mRangeBounds(0.0, 1.0),
48 mRangeClipmode(kTTSym_none),
49 mDynamicInstances(NO),
50 mInstanceBounds(0, -1),
51 mRampDrive(kTTSym_none),
52 mRampDriveDefault(
TTSymbol(
"system")),
54 mRampFunction(kTTSym_none),
57 mDataspace(kTTSym_none),
58 mDataspaceUnit(kTTSym_none),
61 if (arguments.
size() == 1)
62 mService = arguments[0];
130 mIsOverridingDataspaceUnit = NO;
136 this->
findAttribute(kTTSym_initialized, &initializedAttribute);
139 externalRampTime = 0;
156 if (mType == kTTSym_string)
159 vStepsize = mValueStepsize[0];
161 switch (inputValue.
size()) {
169 for (i = 0; i < mValue.
size(); i++) {
171 command.
append(v + inc * vStepsize);
183 for (i = 0; i < mValue.
size(); i++) {
185 command.
append(v + inc * vStepsize);
189 ramp = inputValue[1];
190 if (ramp == kTTSym_ramp) {
193 ramptime = inputValue[2];
205 for (i = 0; i < mValue.
size(); i++) {
207 command.
append(v + vStepsize);
227 if (mType == kTTSym_string)
230 vStepsize = mValueStepsize[0];
232 switch (inputValue.
size()) {
240 for (i = 0; i < mValue.
size(); i++) {
242 command.
append(v - dec * vStepsize);
254 for (i = 0; i < mValue.
size(); i++) {
256 command.
append(v - dec * vStepsize);
260 ramp = inputValue[1];
261 if (ramp == kTTSym_ramp) {
264 ramptime = inputValue[2];
276 for (i = 0; i < mValue.
size(); i++) {
278 command.
append(v - vStepsize);
306 value = mValueDefault;
314 mValueDefault = value;
315 this->notifyObservers(kTTSym_valueDefault, n);
322 value = mValueStepsize;
330 mValueStepsize = value;
331 this->notifyObservers(kTTSym_valueStepsize, n);
339 this->notifyObservers(kTTSym_tags, n);
343 TTErr TTData::setRepetitionsFilter(
const TTValue& value)
346 mRepetitionsFilter = value;
347 this->notifyObservers(kTTSym_repetitionsFilter, n);
356 this->notifyObservers(kTTSym_active, n);
364 mRangeBounds = value;
366 if (mType == kTTSym_integer)
371 this->notifyObservers(kTTSym_rangeBounds, n);
379 mRangeClipmode = value;
380 this->notifyObservers(kTTSym_rangeClipmode, n);
391 mInstanceBounds[0] = vmin;
392 mInstanceBounds[1] = vmax;
405 this->notifyObservers(kTTSym_rampDrive, n);
414 mRampFunction = value;
416 if (mRampFunction != kTTSym_none && mRamper.
valid()) {
419 mRamper.
set(kTTSym_function, mRampFunction);
426 n = mRampFunctionParameters.
size();
427 for (i = 0; i < n; i++) {
428 aName = mRampFunctionParameters[i];
431 mRampFunctionParameters.
clear();
438 for (i = 0; i < n; i++) {
442 if (aName == kTTSym_bypass || aName == kTTSym_mute || aName == kTTSym_maxNumChannels || aName == kTTSym_sampleRate)
448 mRampFunctionParameters.
append(aName);
452 if (mRampFunctionParameters.
size() == 0)
453 mRampFunctionParameters.
append(kTTSym_none);
456 this->notifyObservers(kTTSym_rampFunction, n);
470 if (!mDataspaceConverter.
valid()) {
471 mDataspaceConverter =
TTObject(
"dataspace");
472 mDataspaceInverseConverter =
TTObject(
"dataspace");
475 err = mDataspaceConverter.
set(
"dataspace", mDataspace);
476 mDataspaceInverseConverter.
set(
"dataspace", mDataspace);
480 mDataspace = kTTSym_none;
485 err = mDataspaceConverter.
set(
"outputUnit", mDataspaceUnit);
486 mDataspaceInverseConverter.
set(
"inputUnit", mDataspaceUnit);
490 mDataspaceConverter.
get(
"outputUnit", v);
491 mDataspaceUnit = v[0];
492 mDataspaceConverter.
set(
"outputUnit", mDataspaceUnit);
493 mDataspaceInverseConverter.
set(
"inputUnit", mDataspaceUnit);
496 this->notifyObservers(kTTSym_dataspace, n);
504 mDataspaceUnit = value;
506 if (mDataspaceConverter.
valid()) {
508 mDataspaceConverter.
set(
"outputUnit", mDataspaceUnit);
509 mDataspaceInverseConverter.
set(
"inputUnit", mDataspaceUnit);
511 this->notifyObservers(kTTSym_dataspaceUnit, n);
522 mDescription = value;
524 this->notifyObservers(kTTSym_description, n);
533 this->notifyObservers(kTTSym_priority, n);
540 return mRamper.
send(
"Set", inputValue, outputValue);
546 return mRamper.
send(
"Target", inputValue, outputValue);
552 return mRamper.
send(kTTSym_Go, inputValue, outputValue);
558 return mRamper.
send(
"Slide", inputValue, outputValue);
562 TTErr TTData::rampSetup()
567 if (mRamper.
valid()) {
569 externalRampTime = 0;
574 if (mType == kTTSym_none || mType == kTTSym_string || mType == kTTSym_generic)
575 mRampDrive = kTTSym_none;
580 if (mRampDrive == kTTSym_external || mRampDrive == kTTSym_none)
587 mRamper.
set(
"drive", mRampDrive);
592 return setRampFunction(mRampFunction);
601 return mDataspaceConverter.
send(
"convert", inputValue, outputValue);
607 return mDataspaceInverseConverter.
send(
"convert", inputValue, outputValue);
628 TTTextHandlerPtr aTextHandler = (TTTextHandlerPtr)o.
instance();
636 buffer = aTextHandler->mWriter;
639 *buffer +=
"\t\t\t<td class =\"instructionType\">";
640 *buffer += this->mType.
c_str();
644 toString = this->mRangeBounds;
648 if ( (this->mType == kTTSym_integer) || (this->mType == kTTSym_boolean) || (this->mType == kTTSym_decimal) || (this->mType == kTTSym_generic) ) {
649 *buffer +=
"\t\t\t<td class =\"instructionRangeBounds\">";
650 *buffer +=line.data();
654 *buffer +=
"\t\t\t<td class = \"instructionRangeBounds\"> N/A </td>";
657 *buffer +=
"\t\t\t<td class =\"instructionRangeClipmode\">";
658 *buffer += this->mRangeClipmode.
c_str();
662 *buffer +=
"\t\t\t<td class =\"instructionRampDrive\">";
663 *buffer += this->mRampDrive.
c_str();
667 *buffer +=
"\t\t\t<td class =\"instructionRampFunction\">";
668 *buffer += this->mRampFunction.
c_str();
672 *buffer +=
"\t\t\t<td class =\"instructionDataspace\">";
673 *buffer += this->mDataspace.
c_str();
677 *buffer +=
"\t\t\t<td class =\"instructionDataspaceUnit\">";
678 *buffer += this->mDataspaceUnit.
c_str();
682 toString = this->mRepetitionsFilter;
685 *buffer +=
"\t\t\t<td class =\"instructionRepetitionsFilter\">";
686 *buffer += line.data();
690 *buffer +=
"\t\t\t<td class =\"instructionDescription\">";
691 *buffer += this->mDescription.
c_str();
699 #pragma mark Some Methods
709 if (!parseUnitAndRamp) {
725 commandSize = commandValue.
size();
726 switch(commandSize) {
748 unit = commandValue[1];
759 ramp = commandValue[1];
760 if (ramp == kTTSym_ramp)
766 unit = commandValue[2];
776 if (commandValue[commandSize - 2].type() ==
kTypeSymbol) {
777 ramp = commandValue[commandSize - 2];
778 if (ramp == kTTSym_ramp)
785 if (commandValue[commandSize - 3].type() ==
kTypeSymbol) {
787 unit = commandValue[commandSize - 3];
790 else if (commandValue[commandSize - 1].type() ==
kTypeSymbol) {
794 for (
TTUInt32 i = 0; i < commandSize - 1; i++)
795 numerical &= commandValue[i].type() !=
kTypeSymbol;
799 unit = commandValue[commandSize - 1];
809 if (hasRamp && hasUnit) {
810 aValue = commandValue;
811 aValue.
resize(commandSize - 3);
814 aValue = commandValue;
815 aValue.
resize(commandSize - 2);
818 aValue = commandValue;
819 aValue.
resize(commandSize - 1);
822 aValue = commandValue;
826 command->
append(kTTSym_unit, unit);
831 time = commandValue[commandSize - 1];
832 command->
append(kTTSym_ramp, (
int)time);
852 for (i = 0; i < n; i++)
853 rampedValue[i] = rampedArray[i];
873 aData->mRamper.
get(kTTSym_running, isRunning);
874 if (aData->mRampStatus != isRunning) {
876 aData->mRampStatus = isRunning;
879 if (!aData->mRampStatus)
880 aData->mRamper.
send(kTTSym_Stop);
882 aData->notifyObservers(kTTSym_rampStatus, aData->mRampStatus);
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
TTErr setSchema(const TTSymbol schemaName)
TODO: Add documentation schemaName TODO: Add documentation.
TTErr(TTObjectBase::* TTSetterMethod)(const TTAttribute &attribute, const TTValue &value)
A type that can be used to store a pointer to a message for an object.
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
std::uint16_t TTUInt16
16 bit unsigned integer
friend void TTMODULAR_EXPORT TTDataRampCallback(void *o, TTUInt32 n, TTFloat64 *v)
This class is used to be sensitive to any TTObject notifications and report them using a function wit...
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
TTString toString(TTBoolean quotes=YES) const
Return the content as a single string with spaces between elements.
TTRamp generates a linear traversal from 0.0 to 1.0 over the course of a specified time period...
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
A type that contains a key and a value.
TTErr removeAttribute(const TTSymbol name)
Remove an attribute.
TTErr setValue(const TTValue &newValue)
TODO: Add documentation.
Create and use Jamoma object instances.
size_type size() const noexcept
Return the number of elements.
TTErr sendNotification(const TTSymbol name, const TTValue &arguments)
Send a notification.
TTErr(TTObjectBase::* TTMethodValue)(const TTValue &anInputValue, TTValue &anOutputValue)
A type that can be used to call a message for an object that does not declare the name argument...
This class represents a single attribute, as used by the TTObjectBase class.
Base class for all first-class Jamoma objects.
TTErr(TTObjectBase::* TTMethod)(const TTSymbol methodName, const TTValue &anInputValue, TTValue &anOutputValue)
A type that can be used to store a pointer to a message for an object.
TTErr registerAttribute(const TTSymbol name, const TTDataType type, void *address)
Register an attribute.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
This is a special type used by TTAttribute to indicate that a value is a TTValue and is locally maint...
TTErr registerMessage(const TTSymbol name, TTMethod method)
Register a message with this object.
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
void * TTPtr
A generic pointer.
std::int16_t TTInt16
16 bit signed integer
TTErr get(const TTSymbol aName, T &aReturnedValue) const
Get an attribute value for an object.
void TTDataRampCallback(void *o, TTUInt32 n, TTFloat64 *rampedArray)
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTErr extendAttribute(const TTSymbol name, const TTObjectBasePtr extendedObject, const TTSymbol extendedName)
Extend the attribute of an existing TTObjectBase to this TTObjectBase (using another attribute name) ...
Boolean (1/0) or (true/false) flag.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
const char * c_str() const
Return a pointer to the internal string as a C-string.
TTData establishes a control point, which is to say a TTNode that is dramaticly expanded, for a model to get/set its state.
void clear()
Clear all values from the vector, leaving with size of 0.
32-bit signed integer, range is -2,147,483,648 through 2,147,483,647.
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
std::uint32_t TTUInt32
32 bit unsigned integer
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
TTDictionaryBasePtr TTDataParseCommand(const TTValue &commandValue, TTBoolean parseUnitAndRamp)
Format the command to update the value of TTData as a TTDictionary.
TTObjectBase * instance() const
Return a direct pointer to the internal instance.
Set this flag if the method you are binding to this message is prototyped to accept no arguments...
The TTString class is used to represent a string.
void truncate()
Truncate float & double elements so that only whole number remains.
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
TTErr(TTObjectBase::* TTGetterMethod)(const TTAttribute &attribute, TTValue &value)
A type that can be used to store a pointer to a message for an object.
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]
TTErr findAttribute(const TTSymbol name, TTAttribute **attr)
Find an attribute.
#define addAttributeWithGetterAndSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter and sett...
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.