Sound sensor works as temporary
That makes no sense at all, you have used the wrong word, "temporary" means not permanent or efermal.
Have you tested that source code that i have there
Yes.
The problem is that using PWM as a D/A is poor. You have to up the speed of the PWM to get the sample rate up. Have you done this?
I assume it is in the setup function. You should use a frequency of over 30KHz.