ERROR: Message 'bufnum' not understood

Hi everyone !

I have been revisiting previous code - and I keep getting this error whenever I register more than a few Synth instances of Synthdef… I think the cause of the error is the one described here. I am not sure what to do to debug.

The reason why I think this is that if I play two or three different Synths, then free them, the next Synth will try to register using an already used nodeID - ie if 1000 is registered then freed, then 1001 is registered then freed, then for some reason, the third one will try to register with 1001, as if the process hadn’t finished yet ?

Does that make sense? How could I either fix the code or debug this?

I am running SuperCollider 3.11.2 installed from apt on Ubuntu 22.04, and I also tried this on a dev-installed-from-source SC 3.14 on Ubuntu 22.04

Thanks :partying_face:

Hi – one thing is that node IDs and bufnums are separate concepts, with separate allocators. A “bufnum not understood” error should not have anything to do with node IDs (and if the issue is node IDs, you’d see a “duplicate node ID” posting from the server).

Second thing is, the meaning of this error is that you’re calling .bufnum on something, and you’re expecting that thing to be a Buffer object, but for some reason it’s something else. (I’ll guess possibly nil.)

It would help a lot to see the entire error dump – all of it – the stack dump might look intimidating but it’s very important.

hjh

1 Like

Here is the error dump - if it looks like something is missing, let me know:

Shared memory server interface initialized
-> Buffer(0, nil, nil, nil, /home/mercure/dev/tmp/session.wav)
-> a SynthDef
-> Synth('help-LoopBuf' : 1000)
-> Synth('help-LoopBuf' : 1000)
-> Synth('help-LoopBuf' : 1001)
-> Synth('help-LoopBuf' : 1001)
ERROR: Message 'bufnum' not understood.
RECEIVER:
Instance of Synth {    (0x58e52c919598, gc=6C, fmt=00, flg=00, set=03)
  instance variables [6]
    nodeID : Integer 1001
    server : instance of Server (0x58e52ab10aa8, size=30, set=5)
    group : nil
    isPlaying : false
    isRunning : false
    defName : Symbol 'help-LoopBuf'
}
ARGS:
PATH: /home/mercure/dev/tmp/code.scd
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>
	Object:doesNotUnderstand
		arg this = <instance of Synth>
		arg selector = 'bufnum'
		arg args = [*0]
	< closed FunctionDef >  (no arguments or variables)
	Interpreter:interpretPrintCmdLine
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "c = Synth("help-LoopBuf", [\..."
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
	Process:interpretPrintCmdLine
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Message 'bufnum' not understood.
RECEIVER: Synth('help-LoopBuf' : 1001)

It’s pretty cut-and-dried here – you have some object reference somewhere that you’re expecting to be a Buffer, but instead it’s a Synth.

One possible way you might have gotten here is, if you have a synth that plays a buffer, you might have thought you could ask the synth which buffer it’s playing by using the bufnum method – but the Synth object doesn’t work like that. Synth is a thin layer over server nodes, “thin” meaning that it maintains relatively little state. It’s not really meant to be queried in that way.

That’s just a guess – you could be doing something totally different. In any case, check your .bufnum calls carefully and make sure the receiver really is a Buffer.

hjh

1 Like

Thank you for the explanation!

I think you are on spot given the code I have. I will do some checks and come back if I have to.

Update! I went from:

x = Synth("help-LoopBuf", [\bufnum, b.bufnum, \startPos, 23000, \startLoop, 23000, \endLoop, 70000]);

to

x = Synth("help-LoopBuf", [\startPos, 23000, \startLoop, 23000, \endLoop, 70000]);

and it works!

so I think you were correct :sparkles: thank you!

So I should have different synthdefs for different samples? is my understanding correct?

It works by luck, if your buffer has bufnum 0. If your buffer has a different bufnum, then it will stop working. So you should get in the habit of having a buffer number synth input, and supplying it in the synth argument list.

Without seeing your code, this is just an educated guess, but I’ll hazard that guess based on your post window output.

Shared memory server interface initialized
-> Buffer(0, nil, nil, nil, /home/mercure/dev/tmp/session.wav)

I guess here you did b = Buffer.read(s, "/home/mercure/dev/tmp/session.wav");.

-> a SynthDef
-> Synth('help-LoopBuf' : 1000)
-> Synth('help-LoopBuf' : 1000)
-> Synth('help-LoopBuf' : 1001)

I guess that at some point in this sequence, you did b = Synth(...). From that point forward, the buffer object is no longer accessible through b. I could easily imagine doing “ok, my first synth is a so I’ll make my second synth b” but it’s important to remember that b was already busy and shouldn’t be given a new job. (Side note: “my first synth is s” causes a whole slew of trouble if you’re assuming later that s is the server! So SC will warn you about that if you try it.)

hjh

1 Like