Bad sound
I've managed to get audio in and out from my laptop (playing from iTunes). I sent a post on the Arduino forum regarding this.
The main issue I have now is that the quality of sound is really bad (I mean, you can't hear what it is, it's totally distorted by noise).
That could be explained maybe by the fact that analogRead() runs at less than 1 kHz. So in the end it might be impossible to achieve something even near good.
The other issue might be the way the sound is output. The value sent to the PWM is between 0 and 255 and it sends a modulated voltage to the speaker between 0 and 5V (at least that's what I guess).
The sound input goes from 0 to 1023 with a mean around 510. I wonder if 0-5V is really what should be sent to the speaker, or maybe it should be different (like, say, -2.5V to 2.5V) ? The reason I'm thinking about this is I realize that even when I cut the sound of, I still hear a noise. Also, if I call analogWrite() (ie. the speaker) with a value bigger than 0, the speaker emits a constant noise.
Arduino 8!
There was an answer to my post on the Arduino forum suggesting to use Arduino 8, where the delay(1) has been removed!
Fix
This post just suggests to remove the delay(1) in analogRead() function in wiring.c. I wonder if there is anything that needs to be compiled, but I guess not, since this is just sent on the chip. Anyway, it seems to be working according to the reply.