Amplifying AC voltage via DC supply voltage
Answer

You didn't tell us you were trying to drive the loudspeaker directly from an low-power opamp!



Figure 1. Extract from the CA3240 datasheet showing that the most you can get out of the device is 11 mA (since you need it to both source and sink current).

The opamp is can supply &lt; 100 mW into a high impedance load. Your speaker shows a 3 Ω load.

You need a power amplifier.



History of debug


  But all I get is just an annoying noise sounding horrible.


This is not really an adequate technical description of your problem. It could mean anything from a permanent buzz or hum to gross audio distortion when playing music.

Step 1: Short out your input terminal to ground. The output should be silent. If the noise persists then it points to a power problem or faulty connection. Is your 12 V supply adequate and is the voltage stable?

Step 2: Your original amplifier has a gain of \$ \frac {22k}{2k2} = 10 \$ and if your input signal is large you may be driving the amplifier into clipping. Use a source with adjustable volume control. Turn the volume down to zero, connect up and gradually increase the volume. If this solves the problem then reduce the gain of your amplifier.



The sound sample you posted shows that "music" is in fact getting through but that it is heavily distorted with a characteristic clipped sound. (i.e., The output is hitting V+ or GND and being squared off.

Step 3: Measure the voltage between non-inverting input and ground. It should be 6 V or so and steady!

Step 4: With the input shorted measure the voltage between the opamp output and ground. It should also be 6 V or so.


  OP's comment: The voltage between the output and the ground is 0 if the input is grounded.


This is the cause of the distortion!

Step 5: Assuming the opamp is working, for the output to go low it means the voltage on the inverting input must be higher than the 6 V on the non-inverting input. Something is pulling the signal input high. What is the voltage on the inverting input?

Is it time to add a photo of the setup to your post?