Code example for AudioTrack

Methods: playsetNotificationMarkerPositionsetPlaybackPositionUpdateListenerwrite

    // Actually plays the sound 
    void playSound(){ 
    	// I should really set the volume at this point 
    	final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, 
				 AudioFormat.ENCODING_PCM_16BIT, generatedSnd.length,
    	audioTrack.write(generatedSnd, 0, generatedSnd.length);
    	audioTrack.setPlaybackPositionUpdateListener(new OnPlaybackPositionUpdateListener() {
    		public void onPeriodicNotification(AudioTrack t){
    			// This is to notify when multiples of the notification period? 
    		public void onMarkerReached(AudioTrack t){
    			// Called when the marker is hit 
    			Log.d("main:playSound", "ReachedMarker");
    	// I can't figure out why this number is a good spot for the marker. 
    	// I can't figure out how many frames there are! 
    	if (testing){
    		audioTrack.setNotificationMarkerPosition((generatedSnd.length/2) - 1000);
Experience pair programming with AI  Get Codota for Java