A small hint: try to understand the source code in the audio library. If you have specific questions, ask on this forum.