L3. LAB 3: ANDROID AUDIO SIGNAL SAMPLING 69
private native int GetFrameCount();
en, declare the thread for updating TextView every second and outputting the number
of frames processed as follows:
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while(true) {
try{
sleep(1000);
runOnUiThread(new Runnable() {
@Override
public void run() {
mainActivityTv.setText("Number of frames
processed: " + GetFrameCount()+ " frames");
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
In this code, the read starts a timer that runs every second using the sleep function and
updates TextView in the GUI in real-time.
After the thread is created, it can be started by declaring its start method in the last line
of the onCreate function noted below
thread.start();
After doing the above, run the project. On the GUI, the total number of frames is displayed.
is shows that the GUI can get updated while running the audio processing on a separate or
different thread.
70 4. ANALOG-TO-DIGITAL SIGNAL CONVERSION
L3.8 MULTI-RATE SIGNAL PROCESSING
Latency is the delay between the time an audio signal is captured and the time it is outputted.
e time required to collect samples in a frame and the time to process these samples affect
the amount of latency. Apps with low audio latency are desired for many audio applications.
Excessive latency causes mismatches between the utterance of words and hearing them. In many
audio application, it is desired to keep latency low, say below 15 ms.
For Android smartphones, the audio latency varies from device to device due to different
i/o hardware used. e ADC (Analog to Digital Converter) hardware in modern smartphones
provides the lowest audio latency at 48 kHz sampling rate. However, since much of the audio
signal processing is done at a 16 kHz sampling rate or lower, one needs to synchronize the
audio i/o hardware and the audio processing software in order to have the lowest latency that a
typical smartphone offers. is synchronization can be achieved by multi-rate signal processing
as illustrated in Figure L3.3.
Down-Sampling
by Decimation
Decimated Audio (16 kHZ) Processed Audio (16 kHZ)
Audio Output (48 kHZ)
Audio Input (48 kHZ)
Up-Sampling
by Interpolation
Audio Processing
(FIR Filter)
Figure L3.3: Multi-rate processing.
For low-latency operation, the audio needs to be captured from the smartphone micro-
phone at a 48 kHz sampling rate and by using the frame size that is recommended by the
manufacturer of a particular Android smartphone. Circular buffers are used to achieve the rec-
ommended frame size for input and output. For audio processing modules, the captured frames
are down-sampled to 16 kHz to match with the rate at which audio processing modules operate.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.7.7