Example #1
0
//-----------------------------------------------------------------------------
tresult PLUGIN_API ADelayProcessor::setActive (TBool state)
{
	SpeakerArrangement arr;
	if (getBusArrangement (kOutput, 0, arr) != kResultTrue)
		return kResultFalse;
	int32 numChannels = SpeakerArr::getChannelCount (arr);
	if (numChannels == 0)
		return kResultFalse;

	if (state)
	{
		buffer = (float**)malloc (numChannels * sizeof (float*));
		
		size_t size = (size_t)(processSetup.sampleRate * sizeof (float) + 0.5);
		for (int32 channel = 0; channel < numChannels; channel++)
		{
			buffer[channel] = (float*)malloc (size);	// 1 second delay max
			memset (buffer[channel], 0, size);
		}
		bufferPos = 0;
	}
	else
	{
		if (buffer)
		{
			for (int32 channel = 0; channel < numChannels; channel++)
			{
				free (buffer[channel]);
			}
			free (buffer);
			buffer = 0;
		}
	}
	return AudioEffect::setActive (state);
}
tresult PLUGIN_API Processor::process(ProcessData& data) {

	if (data.inputParameterChanges)
	{
		int32 numParamsChanged = data.inputParameterChanges->getParameterCount();
		for (int32 index = 0; index < numParamsChanged; index++)
		{
			IParamValueQueue* paramQueue = data.inputParameterChanges->getParameterData(index);
			if (paramQueue)
			{
				ParamValue value;
				int32 sampleOffset;
				int32 numPoints = paramQueue->getPointCount();
				switch (paramQueue->getParameterId())
				{
				case kParamInputGain:
					if (paramQueue->getPoint(numPoints - 1, sampleOffset, value) == kResultTrue)
						paramState.inputgain = value;
					break;
				case kParamOutputGain:
					if (paramQueue->getPoint(numPoints - 1, sampleOffset, value) == kResultTrue)
					{
						paramState.outputgain = value;
					}
					break;
				}
			}
		}
	}

	SpeakerArrangement arr;
	getBusArrangement(kOutput, 0, arr);
	int32 numChannels = SpeakerArr::getChannelCount(arr);

	for (int32 channel = 0; channel < numChannels; channel++)
	{
		float* inputChannel = data.inputs[0].channelBuffers32[channel];
		float* outputChannel = data.outputs[0].channelBuffers32[channel];

		
		for (int32 sample = 0; sample < data.numSamples; sample++)
		{
			outputChannel[sample] = inputChannel[sample]*1.5;
		}
	}

	return kResultTrue;
}
Example #3
0
//-----------------------------------------------------------------------------
tresult PLUGIN_API ADelayProcessor::process (ProcessData& data)
{
	if (data.inputParameterChanges)
	{
		int32 paramChangeCount = data.inputParameterChanges->getParameterCount ();
		for (int32 index = 0; index < paramChangeCount; index++)
		{
			IParamValueQueue* queue = data.inputParameterChanges->getParameterData (index);
			if (queue && queue->getParameterId () == kDelayTag)
			{
				int32 valueChangeCount = queue->getPointCount ();
				ParamValue value;
				int32 sampleOffset;
				if (queue->getPoint (valueChangeCount-1, sampleOffset, value) == kResultTrue)
					delay = value;
			}
		}
	}

	if (data.numSamples > 0)
	{
		SpeakerArrangement arr;
		getBusArrangement (kOutput, 0, arr);
		int32 numChannels = SpeakerArr::getChannelCount (arr);

		int32 delayInSamples = std::max<int32> (1, (int32)(delay * processSetup.sampleRate)); // we have a minimum of 1 sample delay here
		for (int32 channel = 0; channel < numChannels; channel++)
		{
			float* inputChannel = data.inputs[0].channelBuffers32[channel];
			float* outputChannel = data.outputs[0].channelBuffers32[channel];

			int32 tempBufferPos = bufferPos;
			for (int32 sample = 0; sample < data.numSamples; sample++)
			{
				float tempSample = inputChannel[sample];
				outputChannel[sample] = buffer[channel][tempBufferPos];
				buffer[channel][tempBufferPos] = tempSample;
				tempBufferPos++;
				if (tempBufferPos >= delayInSamples)
					tempBufferPos = 0;
			}
		}
		bufferPos += data.numSamples;
		while (delayInSamples && bufferPos >= delayInSamples)
			bufferPos -= delayInSamples;
	}	
	return kResultTrue;
}
//setActive trueでプラグイン作動 setActive falseでプラグイン停止
tresult PLUGIN_API Processor::setActive(TBool state)
{
	SpeakerArrangement arr;
	if (getBusArrangement(kOutput, 0, arr) != kResultTrue)
		return kResultFalse;
	int32 numChannels = SpeakerArr::getChannelCount(arr);
	if (numChannels == 0)
		return kResultFalse;

	if (state)
	{

	}
	else
	{
		
	}
	return AudioEffect::setActive(state);
}