Android:Playing bigger size audio wav sound file produces crash
<p>I am trying to play the bigger size audio wav file(which is >20 mb) using the following code(AudioTrack) on my Android 1.6 HTC device which basically has less memory. But i found device crash as soon as it executes reading, writing and play. But the same code works fine and plays the lesser size audio wav files(10kb, 20 kb files etc) very well. 
P.S: I should play PCM(.wav) buffer sound, the reason behind why i use AudioTrack here.</p>

<p>Though my device has lesser memory, how would i read bigger audio files bytes by bytes and play the sound to avoid crashing due to memory constraints.</p>

<pre><code>private void AudioTrackPlayPCM() throws IOException
</code></pre>

<p>{</p>

<p>String filePath = "/sdcard/myWav.wav"; // 8 kb file</p>

<p>byte[] byteData = null;<br>
File file = null; </p>

<p>file = new File(filePath);</p>

<p>byteData = new byte[(int) file.length()];</p>

<p>FileInputStream in = null;</p>

<p>try {
in = new FileInputStream( file );
in.read( byteData );
in.close(); </p>

<p>} catch (FileNotFoundException e) 
{</p>

<p>// TODO Auto-generated catch block
e.printStackTrace();</p>

<p>}</p>

<p>int intSize = android.media.AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_8BIT);     </p>

<p>AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_8BIT, intSize, AudioTrack.MODE_STREAM);        </p>

<p>at.play();</p>

<p>at.write(byteData, 0, byteData.length);<br>
at.stop();</p>

<p>at.release();</p>

<p>}</p>

<p>Could someone guide me please to play the AudioTrack code for bigger size wav files?</p>
