Decaying envelope when audio passes through diode
it has the annoying feature that the amplitude of the audio signal decreases over time, over a period of several seconds.


Nothing that a diode can do by itself has a gradual effect of several seconds. You have a capacitance somewhere which is slowly charging through a resistance, creating a gradually changing DC offset which somehow affects the amplitude.

Maybe some DC return resistors before and after the diode would fix the problem.

A more full schematic is probably something like this:







simulate this circuit &ndash; Schematic created using CircuitLab

Note that if C1 gets charged through the diode (current flowing left to right) and builds up a voltage, it cannot discharge back through the diode. So the R2 resistor is prevented from doing its job. A resistor R3 placed between the external-facing terminal of the capacitor and ground will provide a discharge path. That resistor has to be appropriately chosen because it sets the upper bound on the input impedance of the input device. If you, say, make it only 100 ohms, then the output device is effectively driving a 100 ohm device, which may be too low.