
Vidyodaya J. of Sci. (2016) Vol. 20 PP 17-25 Android Application: Sound Pressure Level Meter and Frequency Spectrum Analyzer N. D. N. C. Bandara and W. K. I. L. Wanniarachchi* Department of Physics, University of Sri Jayewardenepura, Nugegoda, Sri Lanka *Corresponding author E mail : [email protected] Abstract In this paper we present the development of Sound Pressure Level Meter and Frequency Spectrum Analyzer application for Android based devices. The developed application can visualize real time waveform and frequency spectrum of an input audio signal in both linear and dB scale. The GPS location, current date and time are also embedded to the application for convenience. A comparison was carried out with currently available smartphone apps of similar type and the results are in good agreement with the app developed in this project. The current version of the app is capable of capturing signal of maximum frequency up to 4000Hz. Therefore, analysis of frequency spectrum of the voice transmission which range between 300Hz to 3400Hz can be carried out successfully. 17 N. D. N. C. Bandara and W. K. I. L. Wanniarachchi Introduction The introduction of smart phones has replaced many individual items in daily use such as, clock, calendars, camera, etc. Currently, the market share is dominated by Android, Apple iOS, and Blackberry based smartphones [1]. Since Google offers Android as open source, it has won hearts and minds of many mobile application developers. Consequently, there is a wide variety of Android apps to select for consumers compared to any other smartphone running platform. The microphone in a smartphone can be used to capture sound waves and with the use of an appropriate mobile app, the smartphone can be used as a sound level meter. This method of sound analysis is much cheaper compared to commercial sound level meters for everyday applications such as measurement of sound pollution due to recreational activities, factory sound level detection or for music composers. Most of the sound level detection apps currently available in the market are focused on detection of sound level only (eg. Sound meter by ABC apps, Decibel meter by Tacotty apps). However, if such a sound level monitoring app to be used in field work such as detecting sound levels in a city, finding the location requires additional apps such as GPS locators. Therefore, this project is focused on developing a mobile app with sound level pressure meter with ability to detect the GPS location, date and time, 2D wave plotter, and 2D real time frequency spectrum of an audio signal. Audio Sound Capture and Signal Processing Sound is created when a vibrating object causes ripples of varying air pressure. The pressure change is propagated by the collision of air molecules. These varying pressure cause the eardrum to move back and forth. Similar to the way the human ear works, an audio signal is captured using a microphone in a smartphone. This captures the air pressure variations and transformed them into electrical signals in the range of +1V to - 1V. To store a sound wave in a computer, samples of the wave are taken and it is represented by a binary number consisting of a number of bits. The number of samples are taken for each channel per second is defined as the sampling rate. According to the Nyquist theorem, sampling rate should be at least twice as the maximum frequency value of the input signal [2-4]. The number of bits used to represent a single sample determines the resolution of the digitized sound. This process of digitization of the sound is called ―pulse code modulation‖ (PCM). In this work 16-bit analog to digital conversion was used. 18 Android Application: Sound Pressure Level Meter and Frequency Spectrum Analyzer Audio hardware in latest smartphones consist of high quality analog to digital converters of 16-bit data width [4]. The audio hardware also support higher sampling rates for quality audio recording even at 44.1 kHz, which allows capturing audible frequency range 20 Hz to 20 kHz. Diaphragm Analog to Electrical signal Digital Converter [-1V, +1V] Pressure Disturbance Microphone Individual samples 16bit, single channel [-32,768, +32,767] Empty Buffer Application Audio Addresses Controller Memory Direct memory buffer allocation access Android OS Main Memory Figure 1: Digital audio recording in a smart phone As shown in Figure 1, in smart phones, the analog to digital converter is connected to the audio control hardware. The Android application is responsible for sending commands to the audio controller and allocating memory for audio data in to a buffer. The audio controller then transfers buffered audio data directly to RAM where data can be further processed. Fourier transform plays a major role in this process. It converts time-domain based real functions to frequencies (e.g. sound waves). Fourier transform of X(t) is X(w). It converts time space to frequency space. The time and frequency domains contain signals made up of several complex points which have a real part and the imaginary part. The FFT decomposes an N point time domain signal into N time domain signals each consists of a single point. After the N frequency spectra corresponding to these N time domain signals is calculated. Lastly, the N spectra are synthesized into a single frequency spectrum. 19 N. D. N. C. Bandara and W. K. I. L. Wanniarachchi Methodology Audio Recording Process and App Features In this android app development, ―AudioRecord‖, ―AudioFormat‖ and ―MeadiaRecorder‖ classes are used to record the audio signal [5,6]. These classes are used to create an ―AudioRecord‖ object to be used as the recorder. This is the place that the sampling rate, resolution, and the channel configuration are defined. Using this recorder, sound is digitized and the relevant calculation is done continuously while the calculated data are plotted using the ―GraphView‖ library [7]. In this library GraphView class is used to plot a series on two axes. The developed app can produce real time waveform and the real time frequency spectrum of the input signal. Both graphs have some special features. Graph can be start or stop at any time. The y axis is automatically adjusted for different y values. The user can obtain the amplitude value by touching the desired location of the graph. Switch between two graphs is possible. The developed app also has the capability to access the GPS of the smartphone as well. That feature is useful when taking sound level at a particular location by the user. The date and time is displayed in the format of ―yyyy, mm, dd, hh:mm:ss‖. Flow chart of the waveform and the frequency spectrum process is shown in Figure 1 below. In waveform, rms amplitudes are calculated and in frequency spectrum, FFT coefficients are calculated. RMS Amplitude Record to MIC Buffer Calculate FFT Calculate Waveform dB Frequency Append Data Set Value Spectrum to Graph Point Figure 2: Flow chart of the waveform and frequency spectrum plotting process 20 Android Application: Sound Pressure Level Meter and Frequency Spectrum Analyzer The waveform graph plots amplitude (signal level) vs time. The graph is scrollable and scalable for the ease of use. Initially the sound values are reading into a buffer sized 256 with the sampling rate of 8000 Hz and the resolution of 16 bits. The RMS amplitude [8] was calculated as follows in equation (1). Convert to the decibel using log scale. Decibel scale can be different depending on the reference value. It is a relative unit which is based on the loudness of the sound wave. Here the reference value used as 1.0 value. This has been done because human ear is sensitive to relative differences (ratio between two values) rather than absolute differences [9, 10]. This app displays the maximum Amplitude value in ―dB‖ units as well. Frequency spectrum plots the amplitude (signal level) against the frequency in Hz. The amplitude scale can be dynamically changed in to decibel scale or the linear scale. To convert the signal values in to the frequency components, the Discrete Fourier Transformation (DFT) techniques can be used [11-13]. DFT translate data from the time domain to the frequency domain. Fast Fourier Transformation (FFT) library was used to get the frequency domain data in this work. Results Snap shots of developed app interfaces taken within ―Emulator‖ are listed below. Emulator is a virtual device that comes with the Android Studio which can be run in the development operating system as a real device. Basic functions of the app and the uses of buttons which have been used are also explained. Figure 6-8 show the main interface of a wave graph and the frequency spectrum graph. It has buttons for ―start‖, ―frequency spectrum‖, ―Location‖, ―Date and time‖ and a text view of ―Touch graph to see value‖. After the ―Start‖ button is pressed, button name will change to ―Stop‖ and graph plotting will be started and it shows the maximum amplitude value. 21 N. D. N. C. Bandara and W. K. I. L. Wanniarachchi Figure 3: Working Wave Figure 4: Working Figure 5: Working graph dB scale graph Frequency Spectrum ―Frequency Spectrum linear scale graph dB scale graph Comparison with Other Applications Four sound level meter applications were chosen from the Google Play Store for the purposes of study and compare the results with the developed app. The chosen apps and their associated names are shown in Table 1. Particular sound level meter apps were chosen based on the 3+ rating app on Google Play Store, as of 15-10-2015. Android tablet was held by hand at the same location with their microphone oriented towards the speaker of another android phone and the sound level values were recorded.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-