Example #1
0
TTErr Slinky3D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTUInt16			numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 3) {
		TTValue v = 3;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			 vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
    TTSampleValuePtr	outSampleZ			= out.mSampleVectors[2];
    
	TTFloat64 phi, temp;
	
	for (int i=0; i<vs; i++) {	
						
		phi = inSampleX[i] * kTTTwoPi - kTTTwoPi; // -2Pi .. 2Pi
		temp = mB + mA*cos(phi);
		outSampleX[i] = temp*cos(phi);
		outSampleY[i] = temp*sin(phi);
		outSampleZ[i] = mC*(inSampleX[i]-1.0) + mA*sin(phi);

	}
return kTTErrNone;
}
Example #2
0
// TODO: this unit requires 1 input and 2 outputs -- it does not yet configure itself for other arrangements!
TTErr TTZerocross::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	TTUInt16		vs = in.getVectorSizeAsInt();
	TTSampleValue*	inSample;
	TTSampleValue*	out1Sample;
	TTSampleValue*	out2Sample;
	TTBoolean		thisSampleIsOverZero;
	TTBoolean		zeroxOccured;

	inSample = in.mSampleVectors[0];
	out1Sample = out.mSampleVectors[0];
	out2Sample = out.mSampleVectors[1];

	while (vs--) {
		thisSampleIsOverZero = (0 < (*inSample++));
		zeroxOccured = lastSampleWasOverZero != thisSampleIsOverZero;
		lastSampleWasOverZero = thisSampleIsOverZero;
		
		counter += zeroxOccured;
		analysisLocation++;
		
		if (analysisLocation >= mSize) {
			finalCount = ((sr * counter) * rSize) * srInv;
			analysisLocation = 0;
			counter = 0;
		}
		
		*out1Sample++ = finalCount;
		*out2Sample++ = zeroxOccured;
	}
		
	return kTTErrNone;
}
Example #3
0
TTErr Bean2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 2) {
		TTValue v = 2;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			vs  = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
    TTFloat64 phi, r;
	
	for (int i=0; i<vs; i++) {	
		
		phi = inSampleX[i] * kTTPi; // 0 .. 2Pi
		r = pow(sin(phi),3.0) + pow(cos(phi), 3.0);
		
		outSampleX[i] = sin(phi) * r;
		outSampleY[i] = cos(phi) * r;

	}
return kTTErrNone;
}
Example #4
0
TTErr Hypocycloid2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 2) {
		TTValue v = 2;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			 vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
    TTFloat64 phi;
	
	for (int i=0; i<vs; i++) {	

		phi = inSampleX[i] * kTTPi; // 0 .. 2Pi
		
		outSampleX[i] = aMinusOne * cos(phi) + cos(aMinusOne * phi);
		outSampleY[i] = aMinusOne * sin(phi) + sin(aMinusOne * phi);

	}
return kTTErrNone;
}
Example #5
0
TTErr CircularHelix3D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 3) {
		TTValue v = 3;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			 vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
    TTSampleValuePtr	outSampleZ			= out.mSampleVectors[2];
    
	TTFloat64 phi;
	
	for (int i=0; i<vs; i++) {	
						
		phi = inSampleX[i] * kTTPi; // 0 .. 2Pi
		outSampleX[i] = sin(phi);
		outSampleY[i] = cos(phi);
		outSampleZ[i] = mA * (inSampleX[i]-1.0); //scaling 0 ..2 to -1.. 1

	}
return kTTErrNone;
}
Example #6
0
TTErr TTDegrade::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	TTUInt16		vs;
	TTSampleValue	*inSample,
					*outSample;
	TTUInt16		numchannels = TTAudioSignal::getMinChannelCount(in, out);
	TTUInt16		channel;
	long			l;

	for (channel=0; channel<numchannels; channel++) {
		inSample = in.mSampleVectors[channel];
		outSample = out.mSampleVectors[channel];
		vs = in.getVectorSizeAsInt();
		
		while (vs--) {
			// SampeRate Reduction
			mAccumulator[channel] += mSrRatio;
			if (mAccumulator[channel] >= 1.0) {
				mOutput[channel] = *inSample++;
				mAccumulator[channel] -= 1.0;
			}
		
			// BitDepth Reduction
			l = (long)(mOutput[channel] * BIG_INT);			// change float to long int
			l >>= mBitShift;									// shift away the least-significant bits
			l <<= mBitShift;									// shift back to the correct registers
			*outSample++ = (float) l * ONE_OVER_BIG_INT;	// back to float
		}
	}
	return kTTErrNone;
}
Example #7
0
TTErr Linear3D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 3) {
		TTValue v = 3;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);

	
	TTUInt16			vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
	TTSampleValuePtr	outSampleZ			= out.mSampleVectors[2];

	for (int i=0; i<vs; i++) {	
		outSampleX[i] = inSampleX[i]-1.0;
		outSampleY[i] = mA * outSampleX[i];			
		outSampleZ[i] = mB * outSampleX[i];
	}
	return kTTErrNone;
}
TTErr TTStaircase::processUpsample(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
    TTAudioSignal&	in = inputs->getSignal(0);
    TTAudioSignal&	out = outputs->getSignal(0);
    TTSampleValue*	inSample;
    TTSampleValue*	outSample;
    TTUInt16		numchannels = TTAudioSignal::getMinChannelCount(in, out);
    TTPtrSizedInt	channel;
    TTUInt16		targetVectorSize = in.getVectorSizeAsInt() * 2;
    TTErr			err;

    err = out.changeVectorSize(targetVectorSize);
    if (!err) {
        out.setSampleRate(in.getSampleRate() * 2);
        for (channel=0; channel<numchannels; channel++) {
            TTUInt16		n = in.getVectorSizeAsInt();
            TTSampleValue	x;

            inSample = in.mSampleVectors[channel];
            outSample = out.mSampleVectors[channel];

            while (n--) {
                x = *inSample++;
                *outSample++ = x;
                *outSample++ = x;
            }
        }
    }
    return kTTErrNone;
}
TTErr Butterfly2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
    TTAudioSignal&		out = outputs->getSignal(0);
    TTUInt16			numOutputChannels = out.getNumChannelsAsInt();

    if (numOutputChannels != 2) {
        TTValue v = 2;
        out.setMaxNumChannels(v);
        out.setNumChannels(v);
    }

    TTAudioSignal&		in0 = inputs->getSignal(0);
    TTUInt16			 vs = in0.getVectorSizeAsInt();

    TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
    TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
    TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
    TTFloat64 phi, r, temp;

    for (int i=0; i<vs; i++) {

        phi = inSampleX[i] * kTTPi; // 0 .. 2Pi
        temp = sin(1/24*(2*phi-kTTPi));
        r = exp(sin(phi)) - 2*cos(4*phi)+pow(temp,5);

        outSampleX[i] = sin(phi) * r;
        outSampleY[i] = cos(phi) * r;

    }
    return kTTErrNone;
}
Example #10
0
TTErr Lissajous2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 2) {
		TTValue v = 2;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			 vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
	TTFloat64 omega;
	
	for (int i=0; i<vs; i++) {	
		omega = inSampleX[i] * kTTPi;
		
		outSampleX[i] = sin(omega * mAa + mDeltaX);
		outSampleY[i] = sin(omega * mAb);
		}
return kTTErrNone;
}
Example #11
0
TTErr TTBalance::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	TTUInt16		vs;
	TTSampleValue	*inSampleA,
					*inSampleB,
					*outSample;
	TTFloat64		tempxA,
					absTempxA,
					tempxB,
					absTempxB,
					tempyA,
					tempyB;											
	TTUInt16		channel;
	TTUInt16		numChannels;

	// Twice as many input channels are expected as output channels
	numChannels = TTAudioSignal::getNumChannels(in) / 2;
	if (TTAudioSignal::getNumChannels(out) < numChannels)
		numChannels = TTAudioSignal::getNumChannels(out);

	// This outside loop works through each channel one at a time
	for (channel=0; channel<numChannels; channel++) {
		// We first expect all channels of inputSignalA, then all channels of inputSignalB
		inSampleA = in.mSampleVectors[channel];
		inSampleB = in.mSampleVectors[channel+numChannels];
		outSample = out.mSampleVectors[channel];
		vs = in.getVectorSizeAsInt();
		
		// This inner loop works through each sample within the channel one at a time
		while (vs--) {
			tempxA = *inSampleA++;
			absTempxA = fabs(tempxA);
			tempxB = *inSampleB++;
			absTempxB = fabs(tempxB);
			// Lopass filter left and right signals
			tempyA = a0*absTempxA + a1*xm1A[channel] + a2*xm2A[channel] - b1*ym1A[channel] - b2*ym2A[channel];
			TTZeroDenormal(tempyA);
			tempyB = a0*absTempxB + a1*xm1B[channel] + a2*xm2B[channel] - b1*ym1B[channel] - b2*ym2B[channel];		
			TTZeroDenormal(tempyB); 
			// Scale left input to produce output, avoid dividing by zero
			if (tempyA)
				*outSample++ = tempxA * (tempyB/tempyA);
			else
				*outSample++ = 0.;
			// Update filter values
			xm2A[channel] = xm1A[channel];
			xm1A[channel] = absTempxA;
			ym2A[channel] = ym1A[channel];
			ym1A[channel] = tempyA;
			xm2B[channel] = xm1B[channel];
			xm1B[channel] = absTempxB;
			ym2B[channel] = ym1B[channel];
			ym1B[channel] = tempyB;
		}
	}
	return kTTErrNone;
}
Example #12
0
TTErr TTThru::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	
	// We can't reliably simply reference in the case of jcom.unpack≈ because of crashes
	// not sure what is going wrong with that yet...
	
	//return TTAudioSignal::reference(in, out);
	return TTAudioSignal::copy(in, out);
}
Example #13
0
TTErr TTSpatBaseRenderer::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{	
	TTAudioSignal&		in = inputs->getSignal(0);
	TTAudioSignal&		out = outputs->getSignal(0);
	TTUInt16			vs = in.getVectorSizeAsInt();
	TTSampleValuePtr	inSample;
	TTSampleValuePtr	outSample;
	TTChannelCount		numInputChannels = in.getNumChannelsAsInt();
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	TTChannelCount		outChannel;
	TTChannelCount		inChannel;
    TTSampleValue       gainValue;
	
	TTInt16				sourceCount = mMixerMatrixCoefficients->getRowCount();
	TTInt16				sinkCount	= mMixerMatrixCoefficients->getColumnCount();
	
	// If the input signal has more channels than we have sources, the additional channels are ignored.
	if (numInputChannels > sourceCount) {
		numInputChannels = sourceCount;
	}
	
	// Force the right number of sinks
	if ( numOutputChannels != sinkCount ) {
		TTValue v = sinkCount;
		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);
		numOutputChannels = sinkCount;
	}
	// Setting all output signals to zero.
	out.clear();
	
	// TODO: Make sure that when we iterate over the matrix, this is done in an efficient way.
	
	for (outChannel=0; outChannel<numOutputChannels; outChannel++) {
		outSample = out.mSampleVectors[outChannel];
		for (inChannel=0; inChannel<numInputChannels; inChannel++) {
			
			mMixerMatrixCoefficients->get2d(inChannel, outChannel, gainValue);
			
			if (gainValue != 0.0){
				inSample = in.mSampleVectors[inChannel];
				for (int i=0; i<vs; i++) {
					outSample[i] += inSample[i] * gainValue;
				}
			}
		}
	}
	return kTTErrNone;
	
}
Example #14
0
TTErr TTAudioObjectBase::bypassProcess(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	for (TTChannelCount i=0; i<outputs->numAudioSignals; i++) {
		TTAudioSignal& out = outputs->getSignal(i);

		if (i<inputs->numAudioSignals) {
			TTAudioSignal& in = inputs->getSignal(i);
			TTAudioSignal::copy(in, out);
		}
		else
			out.clear();
	}
	return kTTErrNone;
}
Example #15
0
	TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
	{
		TTAudioSignal&	in = inputs->getSignal(0);
		TTUInt16		channelOffset = 0;
		
		for (TTUInt16 i=0; i < outputs->numAudioSignals; i++) {
			TTAudioSignal&	out = outputs->getSignal(i);
			TTUInt16		numChannels = mSplitChannels[i];
			
			// TODO: we don't really want to alloc this memory every time!
			out.setMaxNumChannels(numChannels);
			out.setNumChannels(numChannels);
			TTAudioSignal::copySubset(in, out, channelOffset, channelOffset+numChannels-1);
			channelOffset += numChannels;
		}
		return kTTErrNone;
	}
Example #16
0
TTErr SpatThru::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	src = inputs->getSignal(0);
	TTAudioSignal&	dst = outputs->getSignal(0);
	TTUInt16		vs = src.getVectorSizeAsInt();
	TTSampleValue*	srcSample;
	TTSampleValue*	dstSample;
	
	TTUInt16		channel;
	
	TTUInt16		srcChannelCount = src.getNumChannelsAsInt();
	TTUInt16		dstChannelCount = dst.getNumChannelsAsInt();
	
	if (srcChannelCount != mSourceCount) {
		setSourceCount(srcChannelCount);	// for now, adapting to the number of inputs 
	}
	
	if (dstChannelCount != mDestinationCount) {
		TTValue v = mDestinationCount;
		
		dst.setMaxNumChannels(v);
		dst.setNumChannelsWithInt(v);		
		dstChannelCount = mDestinationCount;
	}
	
	TTUInt16		numchannels = TTAudioSignal::getMinChannelCount(dst,src);	
	
	for (channel=0; channel<numchannels; channel++) {
		srcSample = src.mSampleVectors[channel];
		dstSample = dst.mSampleVectors[channel];
		memcpy(dstSample, srcSample, sizeof(TTSampleValue) * vs);	
	}
	
	if (dstChannelCount > srcChannelCount) {
		for (channel; channel<dstChannelCount; channel++) {
			dstSample = dst.mSampleVectors[channel];
			memset(dstSample, 0, sizeof(TTSampleValue) * vs);
		}
	}
	
	return kTTErrNone;
}
TTErr PlugtasticOutput::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	TTUInt16		vs;
	TTSampleValue	*inSample,
	*outSample;
	TTUInt16		numchannels = TTAudioSignal::getMinChannelCount(in, out);
	TTUInt16		channel;
	
	for (channel=0; channel<numchannels; channel++) {
		inSample = in.mSampleVectors[channel];
		outSample = out.mSampleVectors[channel];
		vs = in.getVectorSizeAsInt();
		
		while (vs--)
			*outSample++ = (*inSample++) * mGain;
	}
	return kTTErrNone;
}
TTErr TTAudioGraphInput::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	if (outputs->numAudioSignals){
		TTAudioSignal&	out = outputs->getSignal(0);

		out = *mBuffer;
		return kTTErrNone;
	}
	else
		return kTTErrBadChannelConfig;
}
Example #19
0
TTErr Catmullrom3D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&		out = outputs->getSignal(0);
	TTChannelCount		numOutputChannels = out.getNumChannelsAsInt();
	
	if (numOutputChannels != 3) {
		TTValue v = 3;		
		out.setMaxNumChannels(v);
		out.setNumChannels(v);		
	}
	
	TTAudioSignal&		in0 = inputs->getSignal(0);
	TTUInt16			 vs = in0.getVectorSizeAsInt();
	
	TTSampleValuePtr	inSampleX			= in0.mSampleVectors[0];
	TTSampleValuePtr	outSampleX    		= out.mSampleVectors[0];
	TTSampleValuePtr	outSampleY			= out.mSampleVectors[1];
	TTSampleValuePtr	outSampleZ			= out.mSampleVectors[2];
    TTFloat64 f;
	
	for (int i=0; i<vs; i++) {	
						
		f = inSampleX[i] * 0.5; //0... 1. 
		
		if ((f > 0) && (f < 1)){
			spline_eval(f);
			
			//calculatePoint();											// output intermediate point
			outSampleX[i] = b_op[0];
			outSampleY[i] = b_op[1];
			outSampleZ[i] = b_op[2];
		} else if (f <= 0.0){
					// output the first point
		} else if (f >= 1.0){
				// output the last point
		}
	}
return kTTErrNone;
}
Example #20
0
// Note that we can implement this function here like this, but unforunately, due to the dynamic binding
// it can't inline the calculate method, and thus it we lose all of the benefits of block processing.
// Therefore, we have a version of this in macro form that can be used.
TTErr TTAudioObjectBase::calculateProcess(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	in = inputs->getSignal(0);
	TTAudioSignal&	out = outputs->getSignal(0);
	TTUInt16		vs;
	TTSampleValue*	inSample;
	TTSampleValue*	outSample;
	TTChannelCount	numchannels = TTAudioSignal::getMinChannelCount(in, out);
	TTPtrSizedInt	channel;
	
	for (channel=0; channel<numchannels; channel++) {
		inSample = in.mSampleVectors[channel];
		outSample = out.mSampleVectors[channel];
		vs = in.getVectorSizeAsInt();
		
		while (vs--) {
			calculate(*inSample, *outSample);
			outSample++;
			inSample++;
		}
	}
	return kTTErrNone;
}
Example #21
0
TTErr TTAudioObjectBase::process(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTErr	err = kTTErrGeneric;
	
	if (valid) {
		lock();
		outputs->setAllSampleRates(sr);
		if (!ttEnvironment->mBenchmarking)
			err = (this->*currentProcessMethod)(inputs, outputs);
		else{
			startProcessingTime = TTGetTimeInMicroseconds();
			err = (this->*currentProcessMethod)(inputs, outputs);
			accumulatedProcessingTime += (TTGetTimeInMicroseconds() - startProcessingTime);
			accumulatedProcessingCalls++;
		}
		unlock();
	}
	return err;
}
Example #22
0
TTErr TTAudioObjectBase::muteProcess(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	for (TTChannelCount i=0; i<outputs->numAudioSignals; i++)
		(outputs->getSignal(i)).clear();
	return kTTErrNone;
}