CN105005478A - Volume measurement method based on Android platform mobile equipment - Google Patents

Volume measurement method based on Android platform mobile equipment Download PDF

Info

Publication number
CN105005478A
CN105005478A CN201510449292.1A CN201510449292A CN105005478A CN 105005478 A CN105005478 A CN 105005478A CN 201510449292 A CN201510449292 A CN 201510449292A CN 105005478 A CN105005478 A CN 105005478A
Authority
CN
China
Prior art keywords
volume
value
buffer
audiorecord
android platform
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510449292.1A
Other languages
Chinese (zh)
Inventor
王树兵
张浩尘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Technology (nanjing) Ltd By Share Ltd
Original Assignee
Technology (nanjing) Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Technology (nanjing) Ltd By Share Ltd filed Critical Technology (nanjing) Ltd By Share Ltd
Priority to CN201510449292.1A priority Critical patent/CN105005478A/en
Publication of CN105005478A publication Critical patent/CN105005478A/en
Pending legal-status Critical Current

Links

Landscapes

  • Telephone Function (AREA)

Abstract

The invention discloses a volume measurement method based on Android platform mobile equipment. The volume measurement method comprises the following steps: 1) utilizing Android AudioRecord APIs (Application Program Interface) to obtain audio data; 2) taking out buffer content which stores the audio data to carry out quadratic sum operation; 3) dividing a quadratic sum by the total length of the data to obtain volume; and 4) comparing the obtained volume with a standard value. Equipment used by the method is simple, and the method can be finished by the traditional Android platform mobile equipment including mobile phones, tablet computers and the like. A measurement process is simple, a measurement result is accurate, and a noise warn can be effectively provided.

Description

A kind of volume measuring method based on Android platform mobile device
Technical field
The present invention relates to volume field of measuring technique, specifically a kind of volume measuring method based on Android platform mobile device.
Background technology
Noise pollution has been a large persistent ailment of modern society environment.No matter be that prevention or noise control pollute, all first must measure volume.By measuring volume, provide foundation for taking the measure such as sound insulation or noise reduction.Measured equipment all more complicated and costlinesses of volume in the past.
Android multimedia framework includes capturing and the support of audio frequency of coding multiple format.Voice data can be obtained by the AudioRecord APIs using Android to provide on the basis of hardware supported.Android supports following audio format encoding and decoding:
Summary of the invention
The problem to be solved in the present invention is to provide a kind of volume measuring method based on Android platform mobile device, and use the volume based on Android platform mobile device measuring and calculating surrounding environment, equipment is simple, with low cost.
A kind of volume measuring method based on Android platform mobile device of the present invention, comprises the following steps:
1) Android AudioRecord APIs is utilized to obtain voice data;
2) the buffer content of stores audio data is taken out, carry out quadratic sum computing;
3) quadratic sum is again divided by data total length, draws volume;
4) volume obtained above and standard value are compared, when volume is more than or equal to standard value, give a warning.。
Utilize Android AudioRecord APIs to obtain voice data, preferred method is:
11) a newly-built AudioRecord object:
111) statement also initialization Int type audio sample rate base value SAMPLE_RATE_IN_HZ=8000;
112) according to the spatial cache value initialization Int type variable BUFFER_SIZE of the stores audio data of AudioRecord acquisition, the method needs to import following parameter into: audio sample rate base value, sound channel form, voice-coding format.
12) AudioRecord object acquisition voice data is utilized:
121) a newly-built sound collector object, for sound source data collection, needs to import following parameter into: include the description of equipment of sound, audio sample rate base value, sound channel form, voice-coding format, spatial cache sizes values;
122) utilize step 112) BUFFER_SIZE variate-value as the buffer Buffer Pool of the newly-built structure of arrays of array length, for depositing voice data;
123) statement also initialization Int type variable r, initial value is 0;
124) step 121 is utilized) the sound collector object acquisition voice data that creates be assigned to the Int type variable r of step 123.
Described step 2) the buffer content of stores audio data to be taken out, the process of carrying out quadratic sum computing comprises:
211) statement also initialization long type variable v, initial value is 0;
212) traversal step 122) buffer Buffer Pool data, and each quadratic sum be added after be added to 7 steps definition variable v on, be v assignment.
Described step 3) quadratic sum, again divided by data total length, show that the process of volume is:
221) state a double type variable mean, and the value after variable v is divided exactly variable r is assigned to variable mean;
222) state a double type variable volume, and to get with 10 after the variable mean of 9 steps is carried out 10 powers be the truth of a matter, and logarithm value is assigned to volume.
In described step 4), institute's accepted standard value is 85 decibels, is normal lower than 85 decibels, is equal to or higher than 85 decibels then for abnormal, carries out alarm prompting time abnormal to user.
Volume measuring method based on Android platform mobile device of the present invention, the equipment of use is simple, and can utilize existing Android platform mobile device, such as mobile phone, panel computer etc. complete.Measuring process is also comparatively simple, and measurement result is accurate, can effectively provide noise to warn.The field of application is extensive, such as, the volume value of environment residing for monitoring children under guardianship, reflect whether the current residing environment of children under guardianship exists potential safety hazard, thus facilitate guardian to take measures in time guarantee children under guardianship healthy and safe of maximum possible, under the prerequisite ensureing effectively monitor the decibel value of environment residing for children under guardianship, cost-saving to greatest extent.
Embodiment
Below a kind of volume measuring method based on Android platform mobile device that the present invention proposes is described in detail.
A kind of volume measuring method based on Android platform mobile device of the present invention, comprises the following steps:
The first step, utilize Android AudioRecord APIs obtain voice data:
11, a newly-built AudioRecord object.
A newly-built AudioRecord object comprises following process:
111, statement also initialization Int type audio sample rate base value SAMPLE_RATE_IN_HZ=8000;
112, according to the spatial cache value initialization Int type variable BUFFER_SIZE of the stores audio data of AudioRecord acquisition, the method needs to import following parameter into: audio sample rate base value, sound channel form, voice-coding format.
12, AudioRecord object acquisition voice data is utilized.
AudioRecord object acquisition voice data is utilized to comprise following process:
121, a newly-built sound collector object, for sound source data collection, needs to import following parameter into: include the description of equipment of sound, audio sample rate base value, sound channel form, voice-coding format, spatial cache sizes values;
122, utilize the BUFFER_SIZE variate-value of step 112 as the buffer Buffer Pool of the newly-built structure of arrays of array length, for depositing voice data;
123, statement also initialization Int type variable r, initial value is 0;
124, the sound collector object acquisition voice data utilizing step 121 to create also is assigned to the Int type variable r of step 123.
Realize utilizing the program code of Android AudioRecord APIs acquisition voice data as follows:
static final int SAMPLE_RATE_IN_HZ = 8000;
static final int BUFFER_SIZE = AudioRecord.getMinBufferSize(SAMPLE_RATE_IN_HZ, AudioFormat.CHANNEL_IN_DEFAULT, AudioFormat.ENCODING_PCM_16BIT);
(BUFFER_SIZE: for storing the cache size of the voice data of collection;
SAMPLE_RATE_IN_HZ: audio sample rate, in units of hertz;
The audio channel of AudioFormat.CHANNEL_IN_DEFAULT:Android acquiescence;
AudioFormat.ENCODING_PCM_16BIT: the coded format that voice data is adopted.
AudioRecorder recorder = new AudioRecorder(MediaRecorder.AudioSource. MIC, SAMPLE_RATE_IN_HZ, AudioFormat.CHANNEL_IN_DEFAULT, AudioFormat.ENCODING_PCM_16BIT, BUFFER_SIZE,);
MediaRecorder.AudioSource. MIC: microphone
short[] buffer = new short[BUFFER_SIZE];
int r = 0;
r = mAudioRecord.read(buffer, 0, BUFFER_SIZE);
Second step, voice data to be processed:
21, the buffer content of stores audio data is taken out, carries out quadratic sum computing:
211, statement also initialization long type variable v, initial value is 0;
212, the buffer Buffer Pool data of traversal step 122, and be added to after each quadratic sum is added on the variable v of 7 step definition, be v assignment.
22, quadratic sum is again divided by data total length, draws volume, and unit is decibel:
221, state a double type variable mean, and the value after variable v is divided exactly variable r is assigned to variable mean;
222, state a double type variable volume, and to get with 10 after the variable mean of 9 steps is carried out 10 powers be the truth of a matter, and logarithm value is assigned to volume.
Realize the code that second step processes voice data as follows:
long v = 0;
for (int i = 0; i < buffer.length; i++) {
v += buffer[i] * buffer[i]}
double mean = v / (double) r;
double volume = 10 * Math.log10(mean);
3rd step: the volume obtained above and standard value are compared
31, volume variate-value step 222 obtained and Int value 85 compare, if volume>85, then and announcement server alarm, otherwise, proceed to measure.Namely the technical program selects 85 decibels for standard value, is normal lower than 85 decibels, is equal to or higher than 85 decibels then for abnormal, now will carries out alarm prompting to user.
Code of illustrating be only a kind of form realizing said method, can also with other codes implement said methods.
The workflow of service routine codes implement method of the present invention is:
One, application program is write according to the inventive method;
Two, disposing application program is to Android device;
Three, the server of receiving alarm information is disposed;
Four, runtime server receiving end, the application program of in opening steps two, Android device being installed in advance;
Five, when step 2) testing of equipment when being greater than 85 to the volume value of residing environment, feed back to server warning information;
Six, server end does respective handling according to warning information.
Above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit protection scope of the present invention.Within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., it all should be encompassed in the middle of right of the present invention.

Claims (7)

1., based on a volume measuring method for Android platform mobile device, it is characterized in that, comprise the following steps:
1) Android AudioRecord APIs is utilized to obtain voice data;
2) the buffer content of stores audio data is taken out, carry out quadratic sum computing;
3) quadratic sum is again divided by data total length, draws volume;
4) volume obtained above and standard value are compared, when volume is more than or equal to standard value, give a warning.
2. the volume measuring method based on Android platform mobile device according to claim 1 is characterized in that, the process utilizing Android AudioRecord APIs to obtain voice data is:
11) a newly-built AudioRecord object;
12) AudioRecord object acquisition voice data is utilized.
3. the volume measuring method based on Android platform mobile device according to claim 2 is characterized in that, the newly-built AudioRecord object of described step 11) comprises following process:
111) statement also initialization Int type audio sample rate base value SAMPLE_RATE_IN_HZ=8000;
112) according to the spatial cache value initialization Int type variable BUFFER_SIZE of the stores audio data of AudioRecord acquisition, the method needs to import following parameter into: audio sample rate base value, sound channel form, voice-coding format.
4. the volume measuring method based on Android platform mobile device according to claim 1 is characterized in that, described step 12) utilizes AudioRecord object acquisition voice data to comprise following process:
121) a newly-built sound collector object, for sound source data collection, needs to import following parameter into: include the description of equipment of sound, audio sample rate base value, sound channel form, voice-coding format, spatial cache sizes values;
122) utilize step 112) BUFFER_SIZE variate-value as the buffer Buffer Pool of the newly-built structure of arrays of array length, for depositing voice data;
123) statement also initialization Int type variable r, initial value is 0;
124) step 121 is utilized) the sound collector object acquisition voice data that creates be assigned to the Int type variable r of step 123.
5. the volume measuring method based on Android platform mobile device according to claim 1 is characterized in that, described step 2) the buffer content of stores audio data to be taken out, the process of carrying out quadratic sum computing comprises:
211) statement also initialization long type variable v, initial value is 0;
212) traversal step 122) buffer Buffer Pool data, and each quadratic sum be added after be added to 7 steps definition variable v on, be v assignment.
6. the volume measuring method based on Android platform mobile device according to claim 1 is characterized in that, described step 3) quadratic sum, again divided by data total length, show that the process of volume is:
221) state a double type variable mean, and the value after variable v is divided exactly variable r is assigned to variable mean;
222) state a double type variable volume, and to get with 10 after the variable mean of 9 steps is carried out 10 powers be the truth of a matter, and logarithm value is assigned to volume.
7. the volume measuring method based on Android platform mobile device according to claim 1 is characterized in that, in step 4), institute's accepted standard value is 85 decibels, be normal lower than 85 decibels, be equal to or higher than 85 decibels then for abnormal, time abnormal, carry out alarm prompting to user.
CN201510449292.1A 2015-07-28 2015-07-28 Volume measurement method based on Android platform mobile equipment Pending CN105005478A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510449292.1A CN105005478A (en) 2015-07-28 2015-07-28 Volume measurement method based on Android platform mobile equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510449292.1A CN105005478A (en) 2015-07-28 2015-07-28 Volume measurement method based on Android platform mobile equipment

Publications (1)

Publication Number Publication Date
CN105005478A true CN105005478A (en) 2015-10-28

Family

ID=54378159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510449292.1A Pending CN105005478A (en) 2015-07-28 2015-07-28 Volume measurement method based on Android platform mobile equipment

Country Status (1)

Country Link
CN (1) CN105005478A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107743279A (en) * 2017-10-09 2018-02-27 维沃移动通信有限公司 A kind of earphone noise-reduction method, earphone and mobile terminal

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1575036A (en) * 2003-06-23 2005-02-02 Lg电子株式会社 System and method of controlling a speaker volume for a mobile terminal
CN1783786A (en) * 2004-11-30 2006-06-07 雅马哈株式会社 Music delivering apparatus and music reproducing apparatus
CN1830141A (en) * 2003-07-28 2006-09-06 皇家飞利浦电子股份有限公司 Audio conditioning apparatus, method and computer program product

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1575036A (en) * 2003-06-23 2005-02-02 Lg电子株式会社 System and method of controlling a speaker volume for a mobile terminal
CN1830141A (en) * 2003-07-28 2006-09-06 皇家飞利浦电子股份有限公司 Audio conditioning apparatus, method and computer program product
CN1783786A (en) * 2004-11-30 2006-06-07 雅马哈株式会社 Music delivering apparatus and music reproducing apparatus

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JUNJIE: "Android中实时获取音量分贝值详解", 《脚本之家》 *
小米的博客: "Android实时获取音量", 《CSDN》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107743279A (en) * 2017-10-09 2018-02-27 维沃移动通信有限公司 A kind of earphone noise-reduction method, earphone and mobile terminal
CN107743279B (en) * 2017-10-09 2019-11-19 维沃移动通信有限公司 A kind of earphone noise-reduction method, earphone and mobile terminal

Similar Documents

Publication Publication Date Title
CN106164845B (en) Dynamic audio frequency horizontal adjustment based on concern
US8489403B1 (en) Apparatuses, methods and systems for sparse sinusoidal audio processing and transmission
CN105027200A (en) Transforming spherical harmonic coefficients
CN106448686B (en) A kind of adaptive audio airspace steganography method
CN110830437B (en) Data compression method, device, equipment and storage medium for high-frequency service data
CN111903144B (en) Objective quality metric for ambient stereo spatial audio
US10783884B2 (en) Electronic device-awakening method and apparatus, device and computer-readable storage medium
CN111683317B (en) Prompting method and device applied to earphone, terminal and storage medium
CN106445451B (en) Audio volume gain method and device
US20120053937A1 (en) Generalizing text content summary from speech content
CN105005478A (en) Volume measurement method based on Android platform mobile equipment
CN115424629A (en) Vehicle internal and external communication method and system based on vehicle-mounted entertainment system and vehicle
KR20170019257A (en) Adaptive processing of audio data
CN108829370B (en) Audio resource playing method and device, computer equipment and storage medium
CN113111233B (en) Regular expression-based alarm receiving text residence address extraction method and device
US20220212108A1 (en) Audio frequency signal processing method and apparatus, terminal and storage medium
CN112466337A (en) Audio data emotion detection method and device, electronic equipment and storage medium
WO2023025294A1 (en) Signal processing method and apparatus for audio rendering, and electronic device
CN111326159A (en) Voice recognition method, device and system
CN115512479B (en) Method for managing reception information and back-end equipment
US20150142444A1 (en) Audio rendering order for text sources
CN107783866A (en) The method of testing and device of a kind of multimedia equipment
US11631416B1 (en) Audio content validation via embedded inaudible sound signal
Tatlas et al. On the effect of compression on the complexity characteristics of wireless acoustic sensor network signals
CN110458743B (en) Community management method, device, equipment and storage medium based on big data analysis

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20151028

RJ01 Rejection of invention patent application after publication