Added dynamic buffer size calculation and increased raw buffer size

Latest changes to audio code.