Get the Microphone sound level ( Decibel level) in Android
Im quite new to android and i have searched about this for quite a while. I would like to build an application that is something like a decibel meter. In realtime it shows the sound level. It there is much noise in the room, there will be something indicating that, if its quiet something will indicate that!.
I don't have any idea at all how to do this. Could anyone explain what the basics of the microphone-sound-level application? If its possible, maybe provide some code?
Thanks!
java android
add a comment |
Im quite new to android and i have searched about this for quite a while. I would like to build an application that is something like a decibel meter. In realtime it shows the sound level. It there is much noise in the room, there will be something indicating that, if its quiet something will indicate that!.
I don't have any idea at all how to do this. Could anyone explain what the basics of the microphone-sound-level application? If its possible, maybe provide some code?
Thanks!
java android
add a comment |
Im quite new to android and i have searched about this for quite a while. I would like to build an application that is something like a decibel meter. In realtime it shows the sound level. It there is much noise in the room, there will be something indicating that, if its quiet something will indicate that!.
I don't have any idea at all how to do this. Could anyone explain what the basics of the microphone-sound-level application? If its possible, maybe provide some code?
Thanks!
java android
Im quite new to android and i have searched about this for quite a while. I would like to build an application that is something like a decibel meter. In realtime it shows the sound level. It there is much noise in the room, there will be something indicating that, if its quiet something will indicate that!.
I don't have any idea at all how to do this. Could anyone explain what the basics of the microphone-sound-level application? If its possible, maybe provide some code?
Thanks!
java android
java android
asked Aug 25 '11 at 22:05
SebSeb
2613813
2613813
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
There's a great app in the marketplace called Audalyzer
http://code.google.com/p/moonblink/wiki/Audalyzer
Also check this discussion..
Android: sample microphone without recording to get live amplitude/level?
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
add a comment |
This question has been addressed generally for Java, and the required classes are available in Android.
The basic idea is to sample the data line for the microphone, and calculate the level from the returned buffer.
How to calculate the level/amplitude/db of audio signal in java?
You can also have a look at the Visualizer class which does FFT frequency analysis, however the permissions for microphone may not be consistent across various devices. You may also have to connect it to the Equalizer class to access the mic.
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
add a comment |
You can use MediaRecorder.getMaxAmplitude()
.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new StringManifest.permission.RECORD_AUDIO,
RECORD_AUDIO);
Get the noise level using the MediaRecorder,
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try
mRecorder.prepare();
catch (IllegalStateException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
mRecorder.start();Start the MediaRecorder,
private Runnable mSleepTask = new Runnable()
public void run()
//Log.i("Noise", "runnable mSleepTask");
mSensor.start();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
//Noise monitoring start
// Runnable(mPollTask) will execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;Create Runnable Thread to check the noise level frequently,
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
Convert the Amplitude to decibel using the following formula,
return 20 * Math.log10(mRecorder.getMaxAmplitude() / 2700.0);
Monitoring the Voice and Alert for the Louder Noise.
// Create runnable thread to Monitor Voice
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
updateDisplay("Monitoring Voice...", amp);
if ((amp > mThreshold))
callForHelp(amp);
//Log.i("Noise", "==== onCreate ===");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7197798%2fget-the-microphone-sound-level-decibel-level-in-android%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There's a great app in the marketplace called Audalyzer
http://code.google.com/p/moonblink/wiki/Audalyzer
Also check this discussion..
Android: sample microphone without recording to get live amplitude/level?
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
add a comment |
There's a great app in the marketplace called Audalyzer
http://code.google.com/p/moonblink/wiki/Audalyzer
Also check this discussion..
Android: sample microphone without recording to get live amplitude/level?
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
add a comment |
There's a great app in the marketplace called Audalyzer
http://code.google.com/p/moonblink/wiki/Audalyzer
Also check this discussion..
Android: sample microphone without recording to get live amplitude/level?
There's a great app in the marketplace called Audalyzer
http://code.google.com/p/moonblink/wiki/Audalyzer
Also check this discussion..
Android: sample microphone without recording to get live amplitude/level?
edited May 23 '17 at 12:32
Community♦
11
11
answered Nov 24 '11 at 14:54
timemirrortimemirror
476411
476411
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
add a comment |
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
1
1
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
This is not the answer, the guy is clearly asking how to build the app. He's not looking for apps
– chntgomez
Sep 2 '17 at 16:49
add a comment |
This question has been addressed generally for Java, and the required classes are available in Android.
The basic idea is to sample the data line for the microphone, and calculate the level from the returned buffer.
How to calculate the level/amplitude/db of audio signal in java?
You can also have a look at the Visualizer class which does FFT frequency analysis, however the permissions for microphone may not be consistent across various devices. You may also have to connect it to the Equalizer class to access the mic.
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
add a comment |
This question has been addressed generally for Java, and the required classes are available in Android.
The basic idea is to sample the data line for the microphone, and calculate the level from the returned buffer.
How to calculate the level/amplitude/db of audio signal in java?
You can also have a look at the Visualizer class which does FFT frequency analysis, however the permissions for microphone may not be consistent across various devices. You may also have to connect it to the Equalizer class to access the mic.
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
add a comment |
This question has been addressed generally for Java, and the required classes are available in Android.
The basic idea is to sample the data line for the microphone, and calculate the level from the returned buffer.
How to calculate the level/amplitude/db of audio signal in java?
You can also have a look at the Visualizer class which does FFT frequency analysis, however the permissions for microphone may not be consistent across various devices. You may also have to connect it to the Equalizer class to access the mic.
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
This question has been addressed generally for Java, and the required classes are available in Android.
The basic idea is to sample the data line for the microphone, and calculate the level from the returned buffer.
How to calculate the level/amplitude/db of audio signal in java?
You can also have a look at the Visualizer class which does FFT frequency analysis, however the permissions for microphone may not be consistent across various devices. You may also have to connect it to the Equalizer class to access the mic.
https://developer.android.com/reference/android/media/audiofx/Visualizer.html
answered Nov 4 '17 at 23:41
Dominic CerisanoDominic Cerisano
1,4351831
1,4351831
add a comment |
add a comment |
You can use MediaRecorder.getMaxAmplitude()
.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new StringManifest.permission.RECORD_AUDIO,
RECORD_AUDIO);
Get the noise level using the MediaRecorder,
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try
mRecorder.prepare();
catch (IllegalStateException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
mRecorder.start();Start the MediaRecorder,
private Runnable mSleepTask = new Runnable()
public void run()
//Log.i("Noise", "runnable mSleepTask");
mSensor.start();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
//Noise monitoring start
// Runnable(mPollTask) will execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;Create Runnable Thread to check the noise level frequently,
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
Convert the Amplitude to decibel using the following formula,
return 20 * Math.log10(mRecorder.getMaxAmplitude() / 2700.0);
Monitoring the Voice and Alert for the Louder Noise.
// Create runnable thread to Monitor Voice
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
updateDisplay("Monitoring Voice...", amp);
if ((amp > mThreshold))
callForHelp(amp);
//Log.i("Noise", "==== onCreate ===");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
add a comment |
You can use MediaRecorder.getMaxAmplitude()
.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new StringManifest.permission.RECORD_AUDIO,
RECORD_AUDIO);
Get the noise level using the MediaRecorder,
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try
mRecorder.prepare();
catch (IllegalStateException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
mRecorder.start();Start the MediaRecorder,
private Runnable mSleepTask = new Runnable()
public void run()
//Log.i("Noise", "runnable mSleepTask");
mSensor.start();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
//Noise monitoring start
// Runnable(mPollTask) will execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;Create Runnable Thread to check the noise level frequently,
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
Convert the Amplitude to decibel using the following formula,
return 20 * Math.log10(mRecorder.getMaxAmplitude() / 2700.0);
Monitoring the Voice and Alert for the Louder Noise.
// Create runnable thread to Monitor Voice
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
updateDisplay("Monitoring Voice...", amp);
if ((amp > mThreshold))
callForHelp(amp);
//Log.i("Noise", "==== onCreate ===");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
add a comment |
You can use MediaRecorder.getMaxAmplitude()
.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new StringManifest.permission.RECORD_AUDIO,
RECORD_AUDIO);
Get the noise level using the MediaRecorder,
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try
mRecorder.prepare();
catch (IllegalStateException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
mRecorder.start();Start the MediaRecorder,
private Runnable mSleepTask = new Runnable()
public void run()
//Log.i("Noise", "runnable mSleepTask");
mSensor.start();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
//Noise monitoring start
// Runnable(mPollTask) will execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;Create Runnable Thread to check the noise level frequently,
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
Convert the Amplitude to decibel using the following formula,
return 20 * Math.log10(mRecorder.getMaxAmplitude() / 2700.0);
Monitoring the Voice and Alert for the Louder Noise.
// Create runnable thread to Monitor Voice
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
updateDisplay("Monitoring Voice...", amp);
if ((amp > mThreshold))
callForHelp(amp);
//Log.i("Noise", "==== onCreate ===");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
You can use MediaRecorder.getMaxAmplitude()
.
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new StringManifest.permission.RECORD_AUDIO,
RECORD_AUDIO);
Get the noise level using the MediaRecorder,
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
try
mRecorder.prepare();
catch (IllegalStateException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
mRecorder.start();Start the MediaRecorder,
private Runnable mSleepTask = new Runnable()
public void run()
//Log.i("Noise", "runnable mSleepTask");
mSensor.start();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
//Noise monitoring start
// Runnable(mPollTask) will execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;Create Runnable Thread to check the noise level frequently,
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
Convert the Amplitude to decibel using the following formula,
return 20 * Math.log10(mRecorder.getMaxAmplitude() / 2700.0);
Monitoring the Voice and Alert for the Louder Noise.
// Create runnable thread to Monitor Voice
private Runnable mPollTask = new Runnable()
public void run()
double amp = mSensor.getAmplitude();
//Log.i("Noise", "runnable mPollTask");
updateDisplay("Monitoring Voice...", amp);
if ((amp > mThreshold))
callForHelp(amp);
//Log.i("Noise", "==== onCreate ===");
// Runnable(mPollTask) will again execute after POLL_INTERVAL
mHandler.postDelayed(mPollTask, POLL_INTERVAL);
;
edited Dec 21 '18 at 3:59
Simon Corcos
334219
334219
answered Aug 13 '18 at 4:16
Tung DuongTung Duong
745216
745216
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7197798%2fget-the-microphone-sound-level-decibel-level-in-android%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown