Error when trying to get TX81Z UGen to work

Hi there, I was wondering if this TX81Z UGen / synth can be made available for Sonic Pi, so I am trying to work myself into it. On Scide I get an error when trying to create the synthdef.

So far I have always been using built-in UGens. I don’t have experience with custom UGens, so I am probably doing something stupid and this is the reason for my asking. I have asked a similar question on GitHub but the answer was that the error can’t be reproduced. I wonder if something is wrong with my setup.

sclang 3.12.1 (Built from branch 'develop' [0ff1fe45d])
scsynth 3.12.1 (Built from branch 'develop' [0ff1fe45d])

I have put the TX81Z UGen in SCClassLibrary and recompiled it without errors. I can then init the UGen and set up MIDI as suggested in the code’s comments with

(
// init data of Tx81z, connect to midi
Tx81z.initData();
MIDIClient.init;
MIDIIn.connectAll;
)

However, when I run

(
SynthDef(\tx81z_demo, {|gate=1, kfreq=220, vel=90, algorithm=0|
    var tx = Tx81z.ar(gate, velocity:vel, algorithm:algorithm,
        kfreq1:kfreq/2, kfreq2:kfreq/2*1.02, kfreq3:kfreq*0.996, kfreq4:kfreq,
        feedback:0.91, wave4:3, op2:0.6, op3: 0.52, op4:0.6, doneAction:2);
    Out.ar(0, tx);
}).send;

I get an error:

ERROR: Message 'bufnum' not understood.
RECEIVER:
   nil
ARGS:

PROTECTED CALL STACK:
	Meta_MethodError:new	0x55f02c113f80
		arg this = DoesNotUnderstandError
		arg what = nil
		arg receiver = nil
	Meta_DoesNotUnderstandError:new	0x55f02c1162c0
		arg this = DoesNotUnderstandError
		arg receiver = nil
		arg selector = bufnum
		arg args = [  ]
	Object:doesNotUnderstand	0x55f02c2214c0
		arg this = nil
		arg selector = bufnum
		arg args = nil
	Meta_Tx81z:ar	0x55f02cd89140
		arg this = Tx81z
		arg gate = an OutputProxy
		arg velocity = an OutputProxy
		arg kfreq1 = a BinaryOpUGen
		arg kfreq2 = a BinaryOpUGen
		arg kfreq3 = a BinaryOpUGen
		arg kfreq4 = an OutputProxy
		arg volume = 99
		arg velocityCurve = 2
		arg op1 = 1
		arg op2 = 0.6
		arg op3 = 0.52
		arg op4 = 0.6
		arg feedback = 0.91
		arg algorithm = an OutputProxy
		arg doneAction = 2
		arg att4 = 31
		arg dec4 = 16
		arg sust4 = 3
		arg ext4 = 7
		arg rel4 = 15
		arg wave4 = 3
		arg att3 = 31
		arg dec3 = 17
		arg sust3 = 3
		arg ext3 = 0
		arg rel3 = 8
		arg wave3 = 0
		arg att2 = 31
		arg dec2 = 9
		arg sust2 = 0
		arg ext2 = 0
		arg rel2 = 8
		arg wave2 = 0
		arg att1 = 31
		arg dec1 = 9
		arg sust1 = 0
		arg ext1 = 0
		arg rel1 = 8
		arg wave1 = 0
		var algIdx = an OutputProxy
		var kOut = nil
		var algbuf = nil
		var algnumcols = nil
		var waveTables = nil
		var kWaveBuf4 = nil
		var kWaveBuf3 = nil
		var kWaveBuf2 = nil
		var kWaveBuf1 = nil
		var mtxcols = nil
		var algrow = nil
		var velcurveBuf = nil
		var fback = nil
		var aOP1 = nil
		var aOP2 = nil
		var aOP3 = nil
		var aOP4 = nil
		var ain4 = nil
		var ain3 = nil
		var ain2 = nil
		var ain1 = nil
		var a0 = nil
		var coef = nil
		var doneEnv = nil
	a FunctionDef	0x55f02c3eeed8
		sourceCode = "{|gate=1, kfreq=220, vel=90, algorithm=0|
    var tx = Tx81z.ar(gate, velocity:vel, algorithm:algorithm,
        kfreq1:kfreq/2, kfreq2:kfreq/2*1.02, kfreq3:kfreq*0.996, kfreq4:kfreq,
        feedback:0.91, wave4:3, op2:0.6, op3: 0.52, op4:0.6, doneAction:2);
    Out.ar(0, tx);
}"
		arg gate = an OutputProxy
		arg kfreq = an OutputProxy
		arg vel = an OutputProxy
		arg algorithm = an OutputProxy
		var tx = nil
	SynthDef:buildUgenGraph	0x55f02babd380
		arg this = a SynthDef
		arg func = a Function
		arg rates = nil
		arg prependArgs = [  ]
		var result = nil
		var saveControlNames = nil
	a FunctionDef	0x55f02baab7c0
		sourceCode = "<an open Function>"
	Function:prTry	0x55f02895eac0
		arg this = a Function
		var result = nil
		var thread = a Thread
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of DoesNotUnderstandError>
	SynthDef:build
		arg this = <instance of SynthDef>
		arg ugenGraphFunc = <instance of Function>
		arg rates = nil
		arg prependArgs = nil
	< closed FunctionDef >  (no arguments or variables)
	Interpreter:interpretPrintCmdLine
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "(
SynthDef(\tx81z_demo, {|ga..."
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
	Process:interpretPrintCmdLine
		arg this = <instance of Main>
^^ ERROR: Message 'bufnum' not understood.
RECEIVER: nil

Any help is much appreciated.

For the records: The synth works for me now. Apparently, my issue had something to do with the server not getting sync’ed on time in *m_initData, leaving the vars uninitialised. So I guess the problem was related to my setup. The error went away for me when I added some postln at the end of *m_initData. The synth sounds grrrrreat!

1 Like