Line levels are 0.5-2.0V range. Mic inputs are expecting millivolts. You just need what is called an L-pad attenuator. Your drop should be 40-50 dB.
If you are using a consumer line level, you will need about 40 dB attenuation. (Professional audio line input would need about 50 dB.)
Attenuation in dB = 20 * log10((R1 + R2) / R2)
Try R1 = 10k and R2 = 100.
If you get accurate measurements of your line source and a know good mic signal for the iPhone, you will be able to calculate more accurate values. Or you can put a 500 ohm trimmer resistor in place of R2 to allow varying of the signal if the line out doesn't have adjustment.
It's really hard to tell from your description. A good description of the noise and when it happens would be a good start.
You already said that the noise happens when you play a note. What happens if the volume is turned down? Either using the control on the electronic piano or by using the pot in your circuit. If the noise goes away then you can assume that the problem is either with the signal level on the input, or that you're asking the amp to put out more than the rated 3.5 watts.
If I were a betting man, I would guess this is the case. You're using a 3.5 watt amp to power a 15 watt speaker. Normally for a 15 watt speaker you would be using a 15 to 30 watt amp. So your amp is undersized.
Adding a cap like what @Manmanguruman suggests isn't a bad idea, but I would hope that there is already some caps inside the amp module. Still, you would use the largest cap that is somewhat practical. Start with about 470 uF and higher.
The pot should have a log taper, not a linear taper. Changing the pot will make the volume control more useful-- but will do nothing for your noise problem.
It is also possible that you have a signal loading problem with the piano. Basically, the piano might not be able to handle having an amp plugged into it. I would hope the piano was designed better, but I have seen some products do some stupid things. Turning the volume down with your linear/log pot should help this issue.
Other than that, the only thing I can think of would be a component failure. Something like the speaker, amp, battery, or piano actually being broken in some way.
Best Answer
Impedance matching is not used in modern audio electronics.
In all these cases, the load impedance is significantly larger than the source; they are not matched. This configuration maximizes fidelity.
Impedance matching was used in the telephone systems that audio systems evolved from, and was (sometimes?) used in vacuum tube amplifiers, but even then, it's a trade-off between maximum power and maximum fidelity.
Transmission line effects don't apply. With a wavelength of at least 10 km (for 20 kHz), I think the most effect you'd ever see from reflection is some comb filtering (HF roll-off) with lines a few km long? But that's totally unrealistic.
Bill Whitlock:
Maximum power theorem doesn't apply, since:
Rane Corporation:
Shure Brothers:
It's a common misconception. HyperPhysics used to show an 8 ohm amplifier output, but they've improved the page since. Electronics Design showed an 8 ohm amplifier output for a long time, but they've finally fixed it after a bunch of complaints in the comments section: