Hi there, welcome to the forum,
Very interesting question...
Perfect Human Interface wrote:.. but this is one of those things where I wonder how people can live without.
I've been active on the forum and over at SynthMaker (the 'grandaddy of FS) for many years, and I've honestly never heard this question asked before! But my first love was tinkering with electronics, where it's rather useful to know - what happens if I cut the green wire?!
Firstly, yes you're right, there is no way to test if an input is connected to anything. All inputs have default values (zero,false, empty string etc,) - but a connected input could quite validly be sending in one of those values, so that wouldn't help much.
But apart from some fairly obscure things where you're trying to save CPU load on audio processing, I've never come across anything where there was any need to know whether a link was present. (I'll come back to streams in a moment).
The answer has to come from the way that a schematic is arranged then...
To take the simplest case. If having a connection or not is a choice that you offer to the end user in your final design, the solution is simple. Somewhere in your design is a GUI control that decides whether to engage that feature or not - so the on/off value is available somewhere from the relevant control.
In the case of 'green' parts, it's probably best not to think of the links as like wires in an "electric circuit", but rather as channels for sending messages along. All green parts just sit there doing nothing until a message is received containing a new value. You've probably come across the green 'trigger' data type already - the secret is that all green data types have triggers inside them too.
Nubeat's example shows this well - the 'last switch' simply responds to whichever of its two inputs are sending new values - the hidden triggers let it know when to change value, and which input the value came from.
Once you start thinking in terms of triggered messages, it becomes simple to make a module behave in different ways depending on where a value came from. As an unconnected input is never going to receive any triggers, you can be sure that it will have no influence on the module's behaviour.
To get at the triggers inside any green value is simple - just plug it into a trigger input; the value itself will be ignored, and any value changes will behave just as if you connected a real 'trigger' link.
By way of an example, here's a little schematic showing how to make a boolean that tells you which one of two knobs you are moving...
You might find this old (unfinished!!)
tutorial from the SM site useful -all of the green stuff is pretty much the same in FS, and the example schematics should load in FS just fine.
Streams are trickier - they are running all the time at sample rate, so there isn't a 'message' system in quite the same way. Because of the high speed of the data, they are designed to be as simple as possible, otherwise they would chew through CPU power.
Again it comes down to design.
A disconnected stream input always sees a steady stream of zeros. And in most cases, this is actually just fine - if you turned an LFO depth control right down, then zero is what it would output anyway . For a well designed module, disconnecting modulation inputs should have no effect on the output.
There are a few rare cases where you do have to explicitly check for silence coming in on an audio input. Just checking for zero might not be reliable because audio signals tend to cross the zero point rather a lot! The only solution there is with some kind of proper audio level detector - similar to what's used in the GUI level meters.
Hope you enjoy your time with FS. Although FS is quite new software, there's plenty of other SynthMaker old-timers here - so just pop back any time to pick our brains when you get stuck.