Page 1 of 1
Self-connection
Posted: Mon Feb 06, 2023 12:41 pm
by poetix
I think the anwer to this is "no", but just checking just in case: in the case that I have an output jack of my module patched into an input jack of the same module, is there any way to detect that it's the same cable at both ends? Use case: an oversampled oscillator, where rather than sending a signal at normal sample rate through the VM system I might want to detect when I'm self-connected and take the higher sample-rate output as an input via an internal patch matrix. (Obviously there are other ways to do it if not...)
Re: Self-connection
Posted: Mon Feb 06, 2023 2:41 pm
by utdgrant
Have you read through the Documentation pack?
Voltage-Developer-Kit-2.7.0/Documentation/JavaDocs/voltage/core/AudioJack.html
makes reference to a Connect method, which has an object of class VoltageCable as its parameter.
I don't really have the time to dig further at the moment, but it might be a good starting point?
Grant
Re: Self-connection
Posted: Mon Feb 06, 2023 4:26 pm
by poetix
Yeah, nothing usable there unfortunately (I'm not sure how you'd ever use that function from inside a module...). I think that means the answer is "no".
Re: Self-connection
Posted: Mon Feb 06, 2023 5:04 pm
by utdgrant
You could maybe keep track of cables connected by monitoring the longValue in Notify?
Code: Select all
case Jack_Connected: // longValue is the new cable ID
{
}
break;
Check that the value of component equals the input or output jack.
Re: Self-connection
Posted: Mon Feb 06, 2023 5:44 pm
by poetix
Ooh, that'll do it - thanks!
Re: Self-connection
Posted: Mon Feb 06, 2023 8:09 pm
by ColinP
Sounds fragile to me as multiple cables can be plugged into the same socket.
Re: Self-connection
Posted: Mon Feb 06, 2023 8:21 pm
by utdgrant
Please be aware that a Jack_Disconnected notification is only called when
ALL cables to a jack have been disconnected.
Code: Select all
case Jack_Disconnected: // All cables have been disconnected from this jack
{
}
break;
Consider the situation that a user already has one cable going into the input jack (from an LFO, say). Also, the output jack already has one cable coming from it (to Main Out Left, say).
Then they connect a loopback cable from the output jack to the input jack, two Jack_Connected notifications will be triggered (one event for each jack).
You'd be able to tell that the loopback path was being requested because both longValues would have the same cable ID.
I would imagine that your code would stop reading the GetValue of the input jack (from the LFO) and start using the oversampled 'internal' signal.
If the user then removed the loopback cable while the LFO cable and Main Out Left were still connected, there would be no notification events generated. In that situation, I think your code would 'think' that the loopback cable was still in place, and so would continue to use the 'internal' signal, rather than reverting to the LFO.
I'm not sure if there's a way to interrogate a jack to enumerate all the cables connected to it. I can't see anything obvious in the documentation, yet.
ColinP wrote: ↑Mon Feb 06, 2023 8:09 pmSounds fragile to me as multiple cables can be plugged into the same socket.
Posted just as I was writing a reply. Great minds, Colin!
Re: Self-connection
Posted: Mon Feb 06, 2023 8:50 pm
by UrbanCyborg
Fragile for another reason: the loop-back might not be a simple cable, but may contain other processing, i.e., other modules.
Reid
Re: Self-connection
Posted: Mon Feb 06, 2023 8:52 pm
by ColinP
UrbanCyborg wrote: ↑Mon Feb 06, 2023 8:50 pm
Fragile for another reason: the loop-back might not be a simple cable, but may contain other processing, i.e., other modules.
Reid
But then the cable ID would be different.
BTW I've not checked that the cable IDs are actually available. Some things in the API don't work as one might hope.
Re: Self-connection
Posted: Mon Feb 06, 2023 10:56 pm
by poetix
It does look like if you want to configure an internal routing matrix there are better ways to do it (I'm thinking of the way Sines does it, for example).