Receiver Objects seem not to be working

hey there,
I’m a new SuperCollider user and trying to master fundamental concepts here.
I stumped on some problem here and dont understand how to fix it.

this code generates no sound:


(
~fn={
	var sig, env;
	sig = SinOsc.ar(300, mul:0.6);
	env = Line.kr(1,0,0.1);
	sig=sig*env;
})

x = {~fn}.play;

whereas the following one works perfectly well:


{SinOsc.ar(200, mul:0.6)*Line.kr(1,0,0.5);}.play;

I guess my variables sig and env dont work like expected. What could be the reason?
thanx…

You have a function wrapped inside of another function. Try

x = ~fn.play

I tried it. i got ->nil and no sound…

Both work fine here, but the sound is really short
Have you:

  • checked server is booted
  • made sure sound was up
  • had a look at s.meter to make sure there is sound
  • checked s.plotTree to check that nodes are being made

nodes are not made. when I launch the code I get an unexpected respond in the post window: ->nil
dont understand what can that be…

It does work for me! Perhaps you are evaluating more lines at a time than you think?

try simply

(
~fn = {
	var sig, env;
	sig = SinOsc.ar(300, mul:0.6);
	env = Line.kr(1,0,1);
	sig=sig*env;
}
)
// then immediately
(
~fn.play
)

if ~fn.play evaluates to nil please evaluate

~fn.cs

and let us know what you see!

weirdly, it works now. thanks a lot for helping me