Android analog signal oscilloscope example code

Last time, I briefly introduced the use of audiorecord and audiotrack. This time, I will implement an Android mobile phone analog signal oscilloscope in combination with surfaceview. Recently, the Internet of things has been very popular. As a mobile phone software developer, how to realize the combination with third-party sensors without modifying the mobile phone hardware circuit? The microphone is a good ADC interface. By combining the microphone with a third-party sensor and processing the analog signal in the software, we can provide richer sensing applications.

Let's take a look at the effect picture of the program running in this article (the screen recording speed is slow, and the real machine will actually run more smoothly):

The program in this paper uses a sampling rate of 8000 Hz and has high requirements for the real-time performance of x-axis drawing. If the resolution of x-axis is not reduced, the real-time performance of the program is poor. Therefore, the program reduces the range of x-axis data to 8 ~ 16 times. Due to 16 bit sampling, the height of y-axis data is also larger than that of mobile phone screen, and the program also reduces the y-axis data, with an interval of 1 ~ 10 times. In the ontouchlistener method of surfaceview, the position adjustment of waveform baseline is added. Directly touch on the surfaceview control to control the upper or lower display of the overall waveform.

main. The XML source code is as follows:

XML / HTML code

ClsOscilloscope. Java is a class library for realizing oscilloscope, including the implementation of audiorecord operation thread and surfaceview drawing thread. The two threads operate synchronously. The code is as follows:

testOscilloscope. Java is the main program, which controls the UI and clssoscilloscope. The code is as follows:

The above is a detailed explanation of the implementation of analog signal oscilloscope in Android. We will continue to supplement relevant knowledge in the future. Thank you for your support for this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>