How to connect Arduino output pin to Line-In

This seems to be a frequently asked question, and I find many answers, but they contradict each other and I don't know which to trust.

I'd like to try turning the Arduino into a music synthesizer. This requires not only generating signals, but also making them audible somehow.

There are many tutorials that connect an Arduino PWM pin directly to a loudspeaker or the PC's line-in, e.g. from no other than the Mozzi creators (scroll down to the section "Wiring").

And there are about as many web pages or forum contributions that warn us to never connect the Arduino directly. The speaker risks damaging the pin, and the Arduino issues 5V whereas line-in is tuned to a much lower voltage.

For people who are quite clueless about electronics (like me), it would be great to have one-and-for-all guidance. I understand the dangers of directly connecting a speaker, but can I connect the Arduino to a PC, or my HiFi amp, or powered speakers without any additional electronics, or should I add an RC circuit, a small amplifier, or whatever else?

@berndbausch suffering from similar at the moment

I need to send an audio file of some kind over a gsm module, I have a mic and a speaker connection on the gsm module, but no guidance on where to get started with making this happen.

It looks very possible and whilst it will need something from the pin to the gsm module to make it happen not sure on exactly what I need, why I need it, so will have to do some more digging.

or should I add an RC circuit,

Yes, especially if the Arduino is outputting a PWM signal. Then you need a seriese capacitor of about 0.1uF into your line input. Connect also the ground of the Arduino to the ground signal of your amplifier.

Without the RC filter the large high frequency in a PWM signal can cause a lot of distortion and internal oscillation in your amplifier.

This link might be useful (the 2nd circuit is the one): Tuto:Get analog audio(3.5mm Audio Jack) in Raspberry Pi Zero - Raspberry Pi Forums

I would increase the 0.1uF values to 0.47uF or 1uF and run PWM at an ultrasonic rate (20kHz or above).