Can't get transistor to work correctly as a switch
If I assume that that the X junction is connected, then when the PWM signal is "high", the output is indeed high, however when it is low, the transistor is 'off' and the capacitor discharges through the resistor. 

You really have to disconnect the capacitor to get this to work. A simple 4000-series analog switch would work beautifully (eg. 74HC4053)- you could simply multiplex between the PWM signal and the analog signal (the 4.7K resistor won't affect the digital signal unduly, but the capacitor will). 









simulate this circuit &ndash; Schematic created using CircuitLab

I guess you could simulate an analog switch by adding another transistor (NPN) driven with the opposite logic, but you will still have the capacitor connected to the logic signal, which will affect the waveform greatly.