[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] UGen creation q



Stilll having Problems with this ugen, I got it to
compile a LFPulseLock.scx file fine and I put it in
the plugins dir and i put the .sc code below in common
but i get this error when i start the server sc:

*** ERROR: dlsym _load err 'symbol not found'
exception in GrafDef_Load: UGen 'MulAdd' not
installed.
exception in GrafDef_Load: UGen 'LFNoise1' not
installed.

any thoughts?

p.s. I played at ceait last night and i was checking
out some peoples max patches, ouch, is anyone working
on some new gui stuff, drop down menu's, canvases,
signal views?  I looked at the gui code... ouch, lots
of stuff to sift through.

LFPulseLock : UGen {
	*ar {
		arg freq = 440.0, iphase = 0.0, width = 0.5, mul =
1.0, add = 0.0;
		^this.multiNew('audio', freq, iphase,
width).madd(mul, add)
	}
	*kr {
		arg freq = 440.0, iphase = 0.0, width = 0.5, mul =
1.0, add = 0.0;
		^this.multiNew('control', freq, iphase,
width).madd(mul, add)
	}
	signalRange { ^\unipolar }
}

#include "SC_PlugIn.h"

static InterfaceTable *ft;

struct LFPulse : public Unit
{
	float mPhase, mFreqMul, mDuty;
	float mPrevFreq;
};

extern "C"
{
    void LFPulse_next_a(LFPulse *unit, int
inNumSamples);
    void LFPulse_next_k(LFPulse *unit, int
inNumSamples);
    void LFPulse_Ctor(LFPulse* unit);
}

void LFPulse_next_a(LFPulse *unit, int inNumSamples)
{
	float *out = ZOUT(0);
	float *freq = ZIN(0);
	float nextDuty = ZIN0(2);
	float duty = unit->mDuty;
	
	float freqmul = unit->mFreqMul;
	float phase = unit->mPhase;
	float frequency = unit->mPrevFreq;
	
	LOOP(inNumSamples, 
		float z;
		if (phase >= 1.f) {
			phase -= 1.f;
			duty = unit->mDuty = nextDuty;
			// output at least one sample from the opposite
polarity
			z = duty < 0.5 ? 1.f : 0.f;
			frequency = ZXP(freq) * freqmul;
		} else {
			z = phase < duty ? 1.f : 0.f;
			ZXP(freq);
		}

		phase += frequency;
		ZXP(out) = z;
	);

	unit->mPrevFreq = frequency;
	unit->mPhase = phase;
}

void LFPulse_next_k(LFPulse *unit, int inNumSamples)
{
	float *out = ZOUT(0);
	float freq = ZIN0(0) * unit->mFreqMul;
	float nextDuty = ZIN0(2);
	float duty = unit->mDuty;
	
	float phase = unit->mPhase;
	float frequency = unit->mPrevFreq;
	LOOP(inNumSamples, 
		float z;
		if (phase >= 1.f) {
			phase -= 1.f;
			duty = unit->mDuty = nextDuty;
			// output at least one sample from the opposite
polarity
			z = duty < 0.5 ? 1.f : 0.f;
			frequency = freq;
		} else {
			z = phase < duty ? 1.f : 0.f;
		}
		phase += frequency;
		ZXP(out) = z;
	);

	unit->mPrevFreq = frequency;
	unit->mPhase = phase;
}

void LFPulse_Ctor(LFPulse* unit)
{
	if (INRATE(0) == calc_FullRate) {
		SETCALC(LFPulse_next_a);
	} else {
		SETCALC(LFPulse_next_k);
	}

	unit->mFreqMul = unit->mRate->mSampleDur;
	unit->mPhase = ZIN0(1);
	unit->mDuty = ZIN0(2);
	unit->mPrevFreq = ZIN0(0) * unit->mFreqMul;
	
	LFPulse_next_k(unit, 1);

}

void load(InterfaceTable *inTable)
{
	ft = inTable;

	DefineSimpleUnit(LFPulse);
}

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com