18 #define thisTTClass TTAudioSignal
19 #define thisTTClassName "audiosignal"
20 #define thisTTClassTags "dspLibrary, audio, processor, dynamics, envelope"
26 mIsLocallyOwned(
false),
58 setAttributeValue(kTTSym_maxNumChannels, initialMaxNumChannels);
59 setAttributeValue(kTTSym_numChannels, initialMaxNumChannels);
65 mIsLocallyOwned(original.mIsLocallyOwned),
93 TTAudioSignal::~TTAudioSignal()
99 void TTAudioSignal::chuck()
103 if (mIsLocallyOwned) {
104 for (i=0; i<mMaxNumChannels; i++) {
108 mIsLocallyOwned =
false;
119 TTBoolean wasLocallyOwned = mIsLocallyOwned;
122 TTLimitMin<TTChannelCount>(newMaxNumChannels, 1);
125 mMaxNumChannels = newMaxNumChannels;
126 if (mMaxNumChannels) {
128 for (i=0; i<mMaxNumChannels; i++)
140 return mMaxNumChannels;
151 mVectorSize = newVectorSize;
153 if (mIsLocallyOwned) {
154 for (i=0; i<mMaxNumChannels; i++) {
158 mIsLocallyOwned =
false;
186 if (mBitdepth != 64 || !mIsLocallyOwned || vectorSize != mVectorSize) {
188 mVectorSize = vectorSize;
215 if (mBitdepth != 32 || !mIsLocallyOwned || newVectorSize != mVectorSize) {
217 mVectorSize = newVectorSize;
222 for (i=0; i<mVectorSize; i++)
233 for (i=0; i<theVectorSize; i++)
244 for (i=0; i<theVectorSize; i++)
253 if (mIsLocallyOwned) {
254 for (i=0; i<mMaxNumChannels; i++) {
260 for (i=0; i<mMaxNumChannels; i++) {
263 mIsLocallyOwned = mMaxNumChannels > 0 ?
true :
false;
272 if (newChannelCount < mMaxNumChannels)
275 TTLimitMin<TTChannelCount>(newChannelCount, 1);
280 for (
int i=0; i<newChannelCount; i++) {
282 if (i < mMaxNumChannels)
285 memset(newSampleVectors[i], 0,
sizeof(
TTSampleValue) * mVectorSize);
290 int oldChannelCount = mMaxNumChannels;
293 mMaxNumChannels = newChannelCount;
294 mNumChannels = newChannelCount;
296 for (
int i=0; i<oldChannelCount; i++) {
298 oldSampleVectors[i] = NULL;
302 mIsLocallyOwned =
true;
312 if ((newVectorSize != mVectorSize) || !mIsLocallyOwned) {
313 mVectorSize = newVectorSize;
331 dest.mVectorSize = source.mVectorSize;
332 dest.mMaxNumChannels = source.mMaxNumChannels;
333 dest.mNumChannels = source.mNumChannels;
334 dest.mBitdepth = source.mBitdepth;
335 dest.mSampleRate = source.mSampleRate;
348 TTChannelCount additionalOutputChannels = dest.mNumChannels - numchannels;
351 for (channel=0; channel<numchannels; channel++) {
353 outSample = dest.
mSampleVectors[ TTClip(channel+channelOffset, 0, maxDestChannels-1) ];
354 vs = source.getVectorSizeAsInt();
360 for (; channel<(numchannels+additionalOutputChannels-channelOffset); channel++) {
362 vs = dest.getVectorSizeAsInt();
380 for (channel=0; channel<numchannels; channel++) {
382 outSample = dest.
mSampleVectors[ TTClip(channel+channelOffset, 0, maxDestChannels-1) ];
383 vs = source.getVectorSizeAsInt();
400 for (sourceChannel=startingChannel, destChannel=0; sourceChannel<=endingChannel; sourceChannel++, destChannel++) {
403 vs = source.getVectorSizeAsInt();
413 if (signal1.mNumChannels < signal2.mNumChannels)
414 return signal2.mNumChannels;
416 return signal1.mNumChannels;
423 if (signal2.mNumChannels > numChannels)
424 numChannels = signal2.mNumChannels;
425 if (signal3.mNumChannels > numChannels)
426 numChannels = signal3.mNumChannels;
434 return signal.mNumChannels;
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
std::uint16_t TTUInt16
16 bit unsigned integer
void TTFOUNDATION_EXPORT TTFree16(TTPtr ptr)
Free memory allocated using TTMalloc16().
TTErr allocWithNewChannelCount(TTChannelCount newChannelCount)
Allocate memory for a given number of channels, setting MaxChannelCount, at the current vector size...
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
static TTErr copySubset(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount startingChannel=0, TTChannelCount endingChannel=0)
Copy the audio from one signal into another.
8-bit unsigned integer, range is 0 through 255.
static TTErr copyDirty(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount channelOffset=0)
Copy the audio from one signal into another, but not taking care to zero channels that aren't used...
TTPtr TTFOUNDATION_EXPORT TTMalloc16(size_t numBytes)
Allocate memory from the heap aligned to 16-byte boundaries.
TTDataObjectBase is the base class for all data generating and processing objects.
static TTChannelCount getNumChannels(const TTAudioSignal &signal)
Use this class method to determine the number of channels of an input or output signal.
16-bit unsigned integer, range is 0 through 65,535.
TTErr setVector(const TTChannelCount channel, const TTUInt16 vectorSize, const TTSampleValuePtr newVector)
[doxygenAppendixC_methodExample]
TTErr clear()
Zero out all of the sample values in the audio signal.
TTErr setMaxNumChannels(const TTValue &newMaxNumChannels)
Attribute accessor.
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
float TTFloat32
32 bit floating point number
static TTChannelCount getMinChannelCount(const TTAudioSignal &signal1, const TTAudioSignal &signal2)
Use this class method to determine the least number of channels the two signals have in common...
The TTAudioSignal class represents N vectors of audio samples for M channels.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
TTSampleValue ** mSampleVectors
An array of pointers to the first sample in each vector. Declared Public for fast access...
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
static TTErr reference(const TTAudioSignal &source, TTAudioSignal &dest)
Reference the audio from one signal in another.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTErr setVector64Copy(const TTChannelCount channel, const TTUInt16 vectorSize, const TTSampleValuePtr newVector)
[doxygenAppendixC_methodExample]
TTAudioSignal(const TTAudioSignal &original)
Copy constructor.
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...
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
static TTErr copy(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount channelOffset=0)
Copy the audio from one signal into another.
TTErr allocWithVectorSize(const TTUInt16 newVectorSize)
Allocate memory for all channels at the specified vectorsize, if the vectorsize is different from the...
TT_OBJECT_CONSTRUCTOR
Constructor macro.
TTFloat64 TTSampleValue
A value representing a single audio sample.
[doxygenAppendixC_copyExample]
TTErr alloc()
Allocate memory for all channels at the current vectorsize.
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.