Power from MIDI + level shifting

I have a circuit that draws little power (under 5mA), it accepts 2 MIDI signals and does some switching. I'm not using the standard optically isolated circuit as there is only signal manipulation done by the circuit - not connected to anything "audio".

As written above, the device accepts two MIDI signals. Each has a voltage ref. pin as part of the current loop. That voltage might be 3V, 3.3V or 5V.

My circuit will work fine with a voltage going low as 2.8V and as high as 3.3V.

When VCC = 5 V, then R = 220 Ω. When VCC = 3.3 V, then R = 33 Ω.

Questions are:

1. In order to power my circuit I need to tap into one of the voltage lines of the input/s. At any current time there could be a single input or two inputs with the voltage lines being 3V, 3.3V or 5V with the two devices not necessarily have the same voltage. How can I select the line which is 3V or 3.3V in case it is present and if not step-down the 5V to 3.3V (LDO regulator). But how does the selection or bypass being done?

2. The logic signal are referenced to the voltage line (same voltage for logic 0 or 0V for a logic 1). I need to translate all the input signals to the voltage the circuit is operating in. So if the circuit is powered from 3V I need to have 3V signals going through without alternation, however a 5V signal would require stepping down. How can I achieve this?

Simple power OR-ing using MOSFETS (as diodes), although this does not work as should in the simulation (any ideas why). This is one part of the solution.

simulate this circuit – Schematic created using CircuitLab

• MIDI does not have a "voltage reference" pin; there is just a pin that might be connect to the positive supply through a resistor, so its voltage will vary. And the ground pin is intended only for shielding, so some outputs do not connect it. – CL. Oct 25 '16 at 20:16
• it's not a voltage ref. in the sense that it's an accurate voltage, just that the other pin that carries the serial data is referenced to it. – user34920 Oct 25 '16 at 20:18
• Not doing anything audio-related would not prevent ground loops from affecting other devices; what allows you to remove the isolation is that you have no own power supply. – CL. Oct 25 '16 at 20:19
• Pin 4 on a MIDI in connector is set at a constant voltage, that it my point here. – user34920 Oct 25 '16 at 20:25
• No, the voltage is not constant (the voltage drops over the output's resistors will change with the current). And pin 5 is likely to be driven by an open-collector output, so in the mark state, it will float and do not have any defined voltage. – CL. Oct 25 '16 at 20:26