Creating a WAV file from raw PCM data using the Android SDK

OK, I’ve got this figured out. This post was crucial in helping me: http://computermusicblog.com/blog/2008/08/29/reading-and-writing-wav-files-in-java Basically, I used ByteArrayOutputStream to write the raw PCM data from AudioRecord, which then lets me get the byte array and its size when the process is done. I can then use that data in conjunction with the SampleRate, BitRate, and … Read more

PCM -> AAC (Encoder) -> PCM(Decoder) in real-time with correct optimization

After testing this is what I came up with from modifying your code: package com.example.app; import android.app.Activity; import android.media.AudioManager; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Bundle; import android.media.AudioFormat; import android.media.AudioRecord; import android.media.AudioTrack; import android.media.MediaCodec; import android.media.MediaRecorder.AudioSource; import android.util.Log; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; public class MainActivity extends … Read more

How to adjust microphone sensitivity while recording audio in android

As I understand you don’t want any automatic adjustments, only manual from the UI. There is no built-in functionality for this in Android, instead you have to modify your data manually. Suppose you use read (short[] audioData, int offsetInShorts, int sizeInShorts) for reading the stream. So you should just do something like this: float gain … Read more

Live Audio Recording and Playing in Android and Thread & callback handling

If your requirement is while it is recording it should play(means looping back audio), In your while loop thread, you are storing the recorded data (audioData bufer), there itself you can copy it to player object with in the while loop (player.write(audioData, 0, numShortsRead);). You said like your UI thread is stuck, it might be … Read more

Android AudioRecord class – process live mic audio quickly, set up callback function

After experimenting lots with the notifications and a bunch of other techniques I settled on this code: private class AudioIn extends Thread { private boolean stopped = false; private AudioIn() { start(); } @Override public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); AudioRecord recorder = null; short[][] buffers = new short[256][160]; int ix = 0; try { // … Read more