Ndef fade in and fade out using keys as control

Hi all,

I am trying to control a Ndef with a key of the keyboard using the GUI using the “.send” “.release” methods in order to be able to use fade in and out the Ndef. However, for the conditional to use the key I am using the isPlaying method, which is always true unless the Ndef is stop. This is the code:

case
{keycode == 49} {if(Ndef(\sca).isPlaying == true,
	{Ndef(\sca).release},
	{Ndef(\sca).send})} 

is there another method for recognizing whether the Ndef is “released”?, or is there a form to fade in the Ndef similar to the stop(10) that fade out in order to use the isPlaying?.

Thanks

Hi all,

well I have changed the .release and .send for

Ndef(\sca).play(fadeTime:5);
Ndef(\sca).stop(fadeTime:5);

but the

Ndef(\sca).isPlaying

is always true. How can I check whether the Ndef is stop or playing in order to use a conditional?

thanks

Have a look at NodeWatcher.
This is the only way I found to have isPlaying having the right value.

This is how I do with Synth. But never tried this with Ndef.

[EDIT]
I did some trials without a lot of success.
When playing a basic Ndef, 2 groups are created

  1. one representing the Ndef (and always present) : 1006+1007
  2. one for the Synth. Which is removed when stopping the Ndef : 1012+1013
    image

The .isPlaying = true isn’t false, because the Ndef’s main group keeps being alive.

Those functions are returning the Ndef’s main group (1006):

Ndef(\a).asNodeID;
Ndef(\a).nodeID;

And those ones are returning the Synth within the Ndef’s main group (1007):

Ndef(\a).objects[0] // --> SynthDefControl
Ndef(\a).objects[0].nodeID 

So even if you register a NodeWatcher on any of those 2 nodes, you’ll keep having a .isPlaying=true

I failed for now to fetch the Synth Group from the Ndef…

To be continued…

isPlaying is about the internal state of the proxy. You are looking for isMonitoring (check also the helpfile). Sorry, the methods are not so clearly named, different conventions crossing there.

1 Like

Thanks for your answers,

Perhaps I am missing something. The big problem is to have a “fade in” when playing the instrument that use the fadeTime assigned. The only form that I have found is using the .send method. I can use the .stop(fadeTime: 10) to fade out, but the .play(fadeTime: xx) seems that is not possible.

I am afraid using the .isMonitoring method is always true when using .send .release methods. Perhaps there is a different method than .send to play the instrument with a fade in that I am not aware of.

The patch is working, but I am using two keys of the keyboard per instrument. I would like to use just one by checking the state of the instrument. Perhaps I can do it assigning a global variable per instrument that change of state to make the conditional, but it would be great to not overcomplicate the code.

Strange, this little one is working fine for me:

(
Ndef(\a).clear;
Ndef(\a).fadeTime=0.2;
Ndef(\a).prime({ |freq=440| SinOsc.ar(freq) * 0.1 });
)

// Single Start/Stop
(
if (Ndef(\a).isMonitoring,{
Ndef(\a).stop(fadeTime: 2);
},{
Ndef(\a).play(fadeTime: 2);
})
)
1 Like

This works!! perhaps was the .prime which I did not use before. Thanks a lot!! :grin:

If you want to keep the monitor playing and know what the internal object is doing, you need to drill down (the reason is that there are many different objects that can be a node proxy source).

// check if the synth is playing
a.objects.at(0).nodeID.isNil

But I need to write an interface that is simple and reliable without digging.

I’ll have a look. However, using the .play .stop works right. Thanks