Code example for AudioTrack

Methods: play

0
    { 
    	int format = findFormatFromChannels(numChannels);
    	int minSize = AudioTrack.getMinBufferSize(sampleRate, format, AudioFormat.ENCODING_PCM_16BIT);        
        track = new AudioTrack( AudioManager.STREAM_MUSIC, sampleRate, 
            format, AudioFormat.ENCODING_PCM_16BIT, 
            minSize*4, AudioTrack.MODE_STREAM);
        track.play();        
    }	    
 
    public void flush() 
    { 
        track.flush();
    } 
 
    public void writeSamples(byte[] samples, int length) 
    { 
        track.write( samples, 0, length);
    } 
 
}