AudioTrack setLoopPoints - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AudioTrack setLoopPoints method.

This code example shows how to use the following methods:getState, release, setLoopPoints, write
        final int TEST_MODE = AudioTrack.MODE_STATIC;
        final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
         
        //-------- initialization -------------- 
        int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
        AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF, TEST_FORMAT, 
                minBuffSize, TEST_MODE);
        byte data[] = new byte[minBuffSize];
        int dataSizeInFrames = minBuffSize/2;//16bit data
        //--------    test        -------------- 
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_NO_STATIC_DATA);
        track.write(data, 0, data.length);
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_INITIALIZED);
        assertTrue(TEST_NAME, 
                track.setLoopPoints(dataSizeInFrames+20, dataSizeInFrames+50, 2) 
                    == AudioTrack.ERROR_BAD_VALUE);
        //-------- tear down      -------------- 
        track.release();
    } 
 

7
CodeRank
This code example shows how to use the following methods:play, setLoopPoints, setPlaybackHeadPosition, write
			 
			 
			// ie for 500ms 44100*4 / 2 = 88100  bytes for stereo playing).  
			 
			 
	        AudioTrack track = new AudioTrack(
	        		AudioManager.STREAM_MUSIC,
	        		sr,
	        		AudioFormat.CHANNEL_OUT_STEREO,
	        		AudioFormat.ENCODING_PCM_16BIT,
	        		size,
	        		AudioTrack.MODE_STATIC);
 
	        Log.v(TAG, "loop end " + sr*l);
	         
	        int start = buffer.length / ch / 2 / 2;
	        int stop = buffer.length / ch / 2 / 2 + 16000;
	        track.setLoopPoints(
	        		start,
	        		stop,

6
CodeRank
This code example shows how to use the following methods:getState, release, setLoopPoints, write
        final int TEST_MODE = AudioTrack.MODE_STATIC;
        final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
         
        //-------- initialization -------------- 
        int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
        AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF, TEST_FORMAT, 
                minBuffSize, TEST_MODE);
        byte data[] = new byte[minBuffSize];
        int dataSizeInFrames = minBuffSize/2;//16bit data
        //--------    test        -------------- 
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_NO_STATIC_DATA);
        track.write(data, 0, data.length);
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_INITIALIZED);
        assertTrue(TEST_NAME, 
                track.setLoopPoints(dataSizeInFrames+20, dataSizeInFrames+50, 2) 
                    == AudioTrack.ERROR_BAD_VALUE);
        //-------- tear down      -------------- 
        track.release();
    } 
 

5
CodeRank
This code example shows how to use the following methods:getState, release, setLoopPoints, write
        final int TEST_MODE = AudioTrack.MODE_STREAM;
        final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
         
        //-------- initialization -------------- 
        int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
        AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF, TEST_FORMAT, 
                2*minBuffSize, TEST_MODE);
        byte data[] = new byte[minBuffSize];
        //--------    test        -------------- 
        track.write(data, 0, data.length);
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_INITIALIZED);
        assertTrue(TEST_NAME, track.setLoopPoints(2, 50, 2) == AudioTrack.ERROR_INVALID_OPERATION);
        //-------- tear down      -------------- 
        track.release();
    } 
     
    //Test case 6: setLoopPoints() fails start > end 
    @LargeTest 
    public void testSetLoopPointsStartAfterEnd() throws Exception { 
        // constants for test 
4
CodeRank
setLoopPoints Method Overview
Sets the loop points and the loop count.
See Code Examples for other Android AudioTrack Methods: