If you intend to use the mic input mic input to your sound card, it will have a current source or pullup resistor to supply a bias to the microphone to which it was intended.
It might not be good for the speaker to have DC flowing through it.
If your phone is connected to the telco, be very careful. The speaker may run at quite a CM voltage and the DC offset might be -48V (depending which way round it is wired).
Telephones wires are very good at attracting lightning. During a storm high common mode voltages may be on the earpiece.
Stricly speaking you should use an audio transformer to couple the earpiece signal into the sound card, this provides DC isolation and some protection against lightning. Adding a TVS across the output of that transformer would be a good idea too.
The ac signal on the earpiece might be quite small. Only a few hundred mV. For a mic input, this will be fine (and can be potted down at the output of your transformer) but for line levels, which are usually 1Vrms it might be very quiet.
Not all phones work the same way, so measure the voltage first using a scope and judge the divsor as required.
The audio transformer should also be protected against DC usign a DC blocking (aka coupling) capacitor.
This circuit protects against discharge and DC currents, though use with caution as a mistake will cost you a PC!
Adding to @GeorgeHerold's answer:
- You need to include frequencies down to below 30Hz. Most of the energy in a typical heartbeat is between 30 and 40Hz. Given the cutoff for the highpass that @GeorgHerold computed, you are losing a good 15dB at the lower end.
- Try using a directional microphone instead of an omnidirectional. Directional microphones have two openings, one in front and one in back by the solder pads. I find I get much better results by installing a directional mic such that the front (where you normally speak into the mic) is inside the tube, with the port on the back of the microphone out in open air.
Actually, I don't use a stethoscope in my experiments. A simple plastic shell with a hole in it for the microphone works very well. What I've used for this is a plastic cap like you would use to close one end of a plastic water line. I had some laying around that are about 2" in diameter, and they work well.
I find that a directional electret microphone installed in a platic cap as described works well enough that I can capture heart sounds using nothing more than a PC or smartphone with no additional electronics - I can then do filtering, recording, or other processing digitally.
The PC soundcard has a 20dB boost on the mic input, but the smartphones don't. Since the cards use 16Bit sampling, you have plenty of headroom to digitally amplify the signal even without using the boost. If you resample from 44100 down to 400 or so, then you could probably gain the equivalent of a few bits
Best Answer
You should understand how the microphone input of the phone works, first. Here's a good article:
http://www.openmusiclabs.com/learning/sensors/electret-microphones/
Note that the microphone port provides a tiny bit of power to the microphone. Honestly this isn't a lot of current, and it's meant simply to operate the JFET inside the microphone capsule.
If you can, you should install a battery in your project and use a typical amplifier setup, which then leads to the microphone port of the phone.
Beyond adding a battery, what I'm suggesting is that you may be able to subvert this current and use it to power an amplifier circuit. If you measure the current available under different loads (just measure the voltage and current across a variety of resistors, graph it, and it'll tell you how much power is actually available for your use.
Once you know the voltage and current you'll be running at, you can attach a regulator to the microphone port, filter the output of that, and power a simple opamp electret microphone amplifier with it. The output of the opamp then goes back through a capacitor to the microphone port (which is the opamp's power supply source).
You're going to have a lot of side effects doing it this way, but it may give you enough headroom in your signal to succeed in your project.
I still think a stethoscope style pickup is a better option, though.