Skip to content

Storing/sending SynthDef through disk fails with HoaEncodeDirection #144

@armandiB

Description

@armandiB

atk-sc3 5.0.7
Supercollider 3.14.0
Mac OS X 14.6.1


Hello,

Running into an issue with sending SynthDefs by disk when they contain HoaEncodeDirection (and potentially others).
As soon as the size of the SynthDef goes above 2**14 bytes, it is sent to the server by way of disk. However this fails when HoaEncodeDirection is inside the SynthDef (haven't tested with other ATK objects yet).
This is quite problematic as SynthDefs get big very fast with ambisonics.

Example:

a = SynthDef("HOA_test", {
	|out, bufnum, start, gate = 1, bufrate = 1, amp=0.1, attack = 0.07, decay = 0.07,

	aaaaaaaaa=1|   // Remove a letter here

	var snd = PlayBuf.ar(2, bufnum, rate: BufRateScale.kr(bufnum)*bufrate, startPos: start, loop:0);
	var gate_safe = gate + Impulse.kr(0);
	var eg = Env.asr(attackTime: attack, releaseTime: decay).kr(2, gate_safe);
	var thetaEnv = Env.xyc(\thetaXyc.ir([[0, 0!2, \exp], [0.1, 0!2]])).kr(gate: gate_safe);
	var phiEnv = Env.xyc(\phiXyc.ir([[0, 0!2, \exp], [0.1, 0!2]])).kr(gate: gate_safe);
	var radiusEnv = Env.xyc(\radiusXyc.ir([[0, 1.5!2, \exp], [0.1, 1.5!2]])).kr(gate: gate_safe);

	snd = snd * amp * eg;
	snd = Mix(snd.collect {|chan, i| HoaEncodeDirection.ar(chan, thetaEnv[i], phiEnv[i], radiusEnv[i], 3)});
	Out.ar(out, snd);
}).add;
a.asBytes.size;
2**14;

This is just above 16384 bytes, and fails with:

ERROR: SynthDef: could not write def: Wrong type.
CALL STACK:
	Exception:reportError
		arg this = <instance of Error>
	Nil:handleError
		arg this = nil
		arg error = <instance of Error>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of Error>
	Object:throw
		arg this = <instance of Error>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of Error>
	Function:doOnStartUp
		arg this = <instance of Function>
	Meta_StartUp:defer
		arg this = <instance of Meta_StartUp>
		arg object = <instance of Function>
	Object:writeDefFile
		arg this = <instance of SynthDef>
		arg name = "/Users/armand/Library/Applic..."
		arg dir = "/Users/armand/Library/Applic..."
		arg overwrite = true
	SynthDef:writeDefFile
		arg this = <instance of SynthDef>
		arg dir = "/Users/armand/Library/Applic..."
		arg overwrite = true
		arg mdPlugin = nil
		var desc = nil
		var defFileExistedBefore = true
	SynthDef:doSend
		arg this = <instance of SynthDef>
		arg server = <instance of Server>
		arg completionMsg = nil
		var bytes = <instance of Int8Array>
		var path = nil
		var resp = nil
		var syncID = nil
	< FunctionDef in Method Set:do >
		arg item = <instance of Server>
	ArrayedCollection:do
		arg this = [*4]
		arg function = <instance of Function>
		var i = 2
	Set:do
		arg this = <instance of Set>
		arg function = <instance of Function>
		var i = 0
	SynthDef:add
		arg this = <instance of SynthDef>
		arg libname = nil
		arg completionMsg = nil
		arg keepDef = true
		var servers = <instance of Set>
		var desc = <instance of SynthDesc>
	< closed FunctionDef >  (no arguments or variables)
	Interpreter:interpretPrintCmdLine
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "a = SynthDef("HOA_test", {
	..."
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
...
^^ The preceding error dump is for ERROR: SynthDef: could not write def: Wrong type.

.store fails the same way

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions