Why are you using your own sound routines? It might be easier to use OpenAL