Code example for AudioTrack

Methods: getStatereleasesetLoopPointswrite

        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;
        //--------    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);
                track.setLoopPoints(10, dataSizeInFrames+20, 2) == AudioTrack.ERROR_BAD_VALUE);
        //-------- tear down      -------------- 
    //Test case 8: setLoopPoints() fails with start beyond what can be written for the track 
    public void testSetLoopPointsStartTooFar() throws Exception { 
        // constants for test 
Stop searching for code, let great code find you!  Add Codota to your java IDE