예제 #1
0
LoopPointsUGenInternal::LoopPointsUGenInternal(Buffer const& buffer, 
											   UGen const& rate, 
											   UGen const& start, 
											   UGen const& end,
											   UGen const& loop, 
											   UGen const& startAtZero,
											   UGen const& playToEnd,
											   const UGen::DoneAction doneAction,
											   MetaData const& metaDataToUse) throw()
:	UGenInternal(NumInputs),
	b(buffer),
	currentValue((startAtZero.getValue() >= 0.5f) ? 0.f : start.getValue() * b.size()),
	lastLoop(false),
	doneAction_(doneAction),
	shouldDeleteValue(doneAction_ == UGen::DeleteWhenDone),
	metaData(metaDataToUse),
	prevValue((rate.getValue() >= 0.f) ? currentValue - 1.f : b.size())
{
	inputs[Rate] = rate;
	inputs[Start] = start;
	inputs[End] = end;
	inputs[Loop] = loop;
	inputs[StartAtZero] = startAtZero;
	inputs[PlayToEnd] = playToEnd;
}
예제 #2
0
	void draw()
	{
		ofFill();
		ofSetColor(255, amp.getValue() * 255);
		ofCircle(pos.x, pos.y, amp.getValue() * 100);
		
		ofNoFill();
		ofSetColor(255);
		ofCircle(pos.x, pos.y, amp.getValue() * 80);
	}
예제 #3
0
MulAdd::MulAdd(UGen const& input, UGen const& mul, UGen const& add) throw()
{	
	UGen inputs[] = { input, mul, add };
	const int numInputChannels = findMaxInputChannels(numElementsInArray(inputs), inputs);
	
	ugen_assert(numInputChannels > 0);
	
	initInternal(numInputChannels);
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new MulAddUGenInternal(input, mul, add);
		internalUGens[i]->initValue(input.getValue(i) * mul.getValue(i) + add.getValue(i));
	}
}
예제 #4
0
BAllPass::BAllPass(UGen const& input, UGen const& freq, UGen const& rq) throw()
{
	UGen inputs[] = { input, freq, rq };
	const int numInputChannels = findMaxInputChannels(numElementsInArray(inputs), inputs);
	initInternal(numInputChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		BEQBaseUGenInternal* filter = new BAllPassUGenInternal(input, freq, rq);
		filter->calculateCoeffs(freq.getValue(i), rq.getValue(i), 1.f);
		filter->initValue(input.getValue(i));
		internalUGens[i] = filter;
	}
}
예제 #5
0
BHiShelf::BHiShelf(UGen const& input, UGen const& freq, UGen const& rs, UGen const& gain) throw()
{
	UGen inputs[] = { input, freq, rs, gain };
	const int numInputChannels = findMaxInputChannels(numElementsInArray(inputs), inputs);	
	initInternal(numInputChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		BEQBaseUGenInternal* filter = new BHiShelfUGenInternal(input, freq, rs, gain);
		filter->calculateCoeffs(freq.getValue(i), rs.getValue(i), gain.getValue(i));
		filter->initValue(input.getValue(i) * gain.getValue(i));
		internalUGens[i] = filter;
	}
}
예제 #6
0
SAH::SAH(UGen const& input, UGen const& trig) throw()
{
	UGen inputs[] = { input, trig };
	const int numInputChannels = findMaxInputChannels(numElementsInArray(inputs), inputs);
	initInternal(numInputChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new SAHUGenInternal(input, trig);
		if(trig.getValue(i) <= 0.f)
			internalUGens[i]->initValue(0.f);
		else
			internalUGens[i]->initValue(input.getValue(i));		
	}
}
예제 #7
0
LagUD::LagUD(UGen const& input, UGen const& lagTimeUp, UGen const& lagTimeDown) throw()
{
	UGen inputs[] = { input, lagTimeUp, lagTimeDown };
	const int numInputChannels = findMaxInputChannels(numElementsInArray(inputs), inputs);		
	initInternal(numInputChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new LagUDUGenInternal(input, lagTimeUp, lagTimeDown);
		internalUGens[i]->initValue(input.getValue(i));
	}
}
예제 #8
0
BufferSenderUGenInternal::BufferSenderUGenInternal(UGen const& input, UGen const& duration) throw()
:	UGenInternal(NumInputs),
	audioBuffer(Buffer::withSize((int)(UGen::getSampleRate()), input.getNumChannels(), true)),
	bufferIndex(0),
	audioBufferSizeUsed(0),
	samplesProcessed(0)
{	
	inputs[Input] = input;
	inputs[Duration] = duration;
	
	audioBufferSizeUsed = max(1, (int)(duration.getValue() * UGen::getSampleRate() + 0.5));
}
예제 #9
0
PlayBuf::PlayBuf(Buffer const& buffer, 
				 UGen const& rate, 
				 UGen const& trigger, 
				 UGen const& startPos, 
				 UGen const& loop, 
				 const UGen::DoneAction doneAction,
				 MetaData const& metaData) throw()
{	
	// just mix the input ugens, they should be mono
	// mix() will just return the original UGen if it has only one channel anyway
	
	const int numChannels = buffer.getNumChannels();
	
	if(numChannels > 0 && buffer.size() > 0)
	{
		initInternal(numChannels);
		
		UGen startPosChecked = startPos.mix();
		generateFromProxyOwner(new PlayBufUGenInternal(buffer, 
													   rate.mix(), 
													   trigger.mix(), 
													   startPosChecked, 
													   loop.mix(), 
													   doneAction,
													   metaData));

		for(int i = 0; i < numChannels; i++)
		{
			internalUGens[i]->initValue(buffer.getSample(i, startPosChecked.getValue(0)));
		}
	}	
	else
	{ 
		//?? what was I thinking here?
	}
}