How to detect if a signal is coming to an inlet?
So i am stuck in this easy matter:
detect when a signal is coming from an inlet.
I want to let it pass if there is one or pass a signal 1 if there is no signal coming....
Using avg~, or meter~ , etc. is not exaclty what i am looking for...
any idea?
thank you !
Is this what you mean?
if input = 0 (static)
output = 1
else output = input
There's probably a more elegant way of doing that patch as well ... but I'm just about to go to sleep on my laptop :p
Hi Tim,
great! yes it is almost what i was looking for. I had a patch similar to yours (but yours is better ;-) ) but the problem is that when a signal of 0s comes, it switches to signal 1....
imagine this:
inlet 1 inlet 2
|. . . . |
|. . . . |
[ *~ ]
|
|
out~
from inlet 1 comes a signal (say signal A), and from 2 sometimes another (say signal B), so what i want is that when there is ANY signal B (and it can be a 0 signal, as a cycle~ with zero amplitude) we multiply A * B, and when there is NO signal B, we get A * 1 = A.
So your patch is doing almost that, but when it is a signal of zero amplitude, it is giving A * 1 and i would want a A * 0. = 0.
any idea?
thank you !!
When you say "when there is no signal B" do you mean when you delete a patchcord to that inlet? Or just when a zero signal is being sent? I'm a little confused.
Hi Luke,
when i say that there is no signal, it means that no signal is coming there, so no any number, as if the patchcord was deleted. imagine a receive~ attached to the inlet, if no object is sending to that receive~, so that is having NO signal.... But if an object is sending to that receive~ , there will be a signal coming, and that signal can be 0 amplitude (i.e. zeros...).
I want to detect when any object is sending something to the inlet...
thank you....
If you are physically deleting the patchcord then you can just use a [*~] as shown in the first example below.
If you mean just re-routing a signal (have a look at the second two examples) then you have to realise the signal chain will be constantly processing zeros, this is how audio works in max. It is exactly the same as if you had muted a signal, like your [cycle~] with zero amplitude from before. There is no way to tell a muted signal from a closed [gate~] using just the signal information. Perhaps post the relevant part of your patch and we can see if there's a work-around?
no signal or a signal of 0. that is often the question.
if you really want no signal, that can be done if neccessary, but
you might end up creating very idiosyncratic poly~ abstractions
which only work for that specific case.
"when i say that there is no signal, it means that no signal is coming there, so no any number, as if the patchcord was deleted. imagine a receive~ attached to the inlet, if no object is sending to that receive~, so that is having NO signal..."
i am not so sure about that receive~ example.
you often have a signal of 0. "on" a connection only from the
connection going to an aim, even when the "outputting" object
does nothing or is turned off.
to start an individual subcircuit you normally need begin~ or to
break the connection using poly~.
Yes, i think an example patch will explain exactly what i want:
so it is let pass a signal when we do not receive any, and multiply them if we receive something....
Thanks !!!
i dont know by heart now whats the best way, but you might also look into [dspstate~].
connect the connection to it, and when the signal rate output says 0, there is no signal.
Well, as per the misinterpretation of Occam's razor ... it's easier than you think :p
Hi,
yes, Tim, this is the approach i have been using now, and works well. My send and receive are in different patches, ad when i send to, say, 1-out, i also send a 1-out-active = 1 and when i receive 1-out-active = 1, i let pass the signal, as in your patch.
I have tried also the dspstate object but does not gives the signal status... only the main audio in the window.
it seems that it is difficult to find a solution to the problem: how to detect if a signal is coming to an inlet....
Thank you for the advise!
Well like Luke said already, it's impossible to tell the difference between a stream of 0s coming from a [sig~ 0] and the same coming from a gated or 0-amplitude audio signal ... etc ... without clarifying information.
I'm not sure what RT is suggesting with [dspstate~ ].
What is it about the method you're using at the moment that doesn't work for you? It's the simplest and most efficient way of doing it.
Hi,
yes, i think this method (sending the info of if the signal is coming or not is a good solution and easy to make. The only problem is that due to the complexity of my patch, and also because there were soo many inputs of that kind that finding a solution in other way would be better, perhaps.
Still think that it can be done in a way. there must be a difference between nothing coming and 0s coming... that is what i was looking for.
thanks!!!
That's the problem ... because of how msp works, a signal-rate stream of "nothing" is a stream of 0s.
Here's a patch which returns a 1 if a signal is connected to its inlet and a 0 when there is no signal connected. It makes use of the <signal> identifier message that all msp signals output when the dsp is initialized/refreshed.