本文整理了Java中android.media.MediaRecorder.getMaxAmplitude()
方法的一些代码示例,展示了MediaRecorder.getMaxAmplitude()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaRecorder.getMaxAmplitude()
方法的具体详情如下:
包路径:android.media.MediaRecorder
类名称:MediaRecorder
方法名:getMaxAmplitude
暂无
代码示例来源:origin: stackoverflow.com
int x = recorder.getMaxAmplitude();
代码示例来源:origin: stackoverflow.com
return mediaRecorder.getMaxAmplitude();
代码示例来源:origin: Piasy/RxAndroidAudio
public synchronized int getMaxAmplitude() {
if (mState != STATE_RECORDING) {
return 0;
}
return mRecorder.getMaxAmplitude();
}
代码示例来源:origin: stackoverflow.com
return mRecorder.getMaxAmplitude();
else
return 0;
代码示例来源:origin: q422013/IMChat
public double getAmplitude() {
if (mRecorder != null)
return (mRecorder.getMaxAmplitude() / 2700.0);
else
return 0;
}
代码示例来源:origin: newchenxf/audiorecord
/**
* 获得录音的音量,范围 0-32767, 归一化到0 ~ 1
* @return
*/
public float getMaxAmplitude() {
if(recordStatus == RecordStatus.START) {
return mediaRecorder.getMaxAmplitude() * 1.0f / 32768;
}
return 0;
}
代码示例来源:origin: cbchena/android_examples
public double getAmplitude() {
if (_mRecorder != null)
return (_mRecorder.getMaxAmplitude() / 2700.0);
else
return 0;
}
代码示例来源:origin: baiyuliang/QRobot
public double getAmplitude() {
if (recorder != null) {
return (recorder.getMaxAmplitude());
} else
return 0;
}
}
代码示例来源:origin: cn.leancloud.android/avoscloud-push
/**
* Returns the maximum absolute amplitude that was sampled since the last
* call to this method. Call this only after the start().
*
* @return the maximum absolute amplitude measured since the last call, or
* 0 when called for the first time
* @throws IllegalStateException if it is called before
* the audio source has been set.
*/
public int getMaxAmplitude() {
if (null == recorder) {
return 0;
}
return recorder.getMaxAmplitude();
}
代码示例来源:origin: easemob/kefu-android-demo
public int getVoiceLevel(@SuppressWarnings("SameParameterValue") int maxLevel) {
if (isPrepared) {
/*maxLevel:取值:1~7*/
try {
/**
* mMediaRecorder.getMaxAmplitude();振幅 值范围:1~32767
* mMediaRecorder.getMaxAmplitude()/32768 在0~1之间
* 7*mMediaRecorder.getMaxAmplitude()/32768 在0~7之间,但最大只能取到6,所以加1
*/
return maxLevel * mMediaRecorder.getMaxAmplitude() / 32768 + 1;
} catch (Exception ignored) {
}
}
return 1;
}
代码示例来源:origin: dongorigin/AndroidDemo
public int getVoiceLevel(int maxLevel) {
if (isRecording) {
try {
// getMaxAmplitude 的范围为 0-32767
return maxLevel * mMediaRecorder.getMaxAmplitude() / 32768 + 1;
} catch (IllegalStateException e) {
e.printStackTrace();
return 1;
}
}
return 1;
}
代码示例来源:origin: eliotstocker/Light-Controller
private int getInputVolume() {
try {
//mr.getMaxAmplitude();
int amplitude = mr.getMaxAmplitude();
fd.flush();
return amplitude;
} catch(Exception e) {
e.printStackTrace();
}
return 0;
}
}
代码示例来源:origin: UCodeUStory/RecordVoiceView
private void updateMicStatus() {
if (mMediaRecorder != null) {
// int vuSize = 10 * mMediaRecorder.getMaxAmplitude() / 32768;
int ratio = mMediaRecorder.getMaxAmplitude() / BASE;
int db = 0;// 分贝
if (ratio > 1)
db = (int) (20 * Math.log10(ratio));
mHandler.postDelayed(mUpdateMicStatusTimer, SPACE);
Message msg = Message.obtain();
msg.arg1 = db;
mHandler.sendMessage(msg);
}
}
代码示例来源:origin: XiqingLiu/RecordView
private void updateMicStatus() {
if (mMediaRecorder != null) {
// int vuSize = 10 * mMediaRecorder.getMaxAmplitude() / 32768;
int ratio = mMediaRecorder.getMaxAmplitude() / BASE;
int db = 0;// 分贝
if (ratio > 1)
db = (int) (20 * Math.log10(ratio));
mHandler.postDelayed(mUpdateMicStatusTimer, SPACE);
Message msg = Message.obtain();
msg.arg1 = db;
mHandler.sendMessage(msg);
}
}
代码示例来源:origin: YiChat/android_YiChat_Lite
@Override
public void run() {
try {
while (isRecording) {
android.os.Message msg = new android.os.Message();
msg.what = recorder.getMaxAmplitude() * 13 / 0x7FFF;
handler.sendMessage(msg);
SystemClock.sleep(100);
}
} catch (Exception e) {
// from the crash report website, found one NPE crash from
// one android 4.0.4 htc phone
// maybe handler is null for some reason
}
}
}).start();
代码示例来源:origin: Meiqia/MeiqiaSDK-Android
public int getVoiceLevel(int maxLevel) {
if (mIsPrepared) {
try {
return Math.max(Math.min((int) (25 * Math.log10(mMediaRecorder.getMaxAmplitude() / 500)) / 4, maxLevel), 1);
// 没有设置音频源之前获取声音振幅会报IllegalStateException,直接返回1
} catch (Exception e) {
e.printStackTrace();
}
}
return 1;
}
代码示例来源:origin: jackuhan/Android_WaveLine
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
double ratio = (double) mMediaRecorder.getMaxAmplitude() / 100;
double db = 0;// 分贝
if (ratio > 1)
db = 30 * Math.log10(ratio);
voiceLineView.setVolume((int) (db));
}
};
代码示例来源:origin: easemob/livestream_demo_android
@Override
public void run() {
try {
while (isRecording) {
android.os.Message msg = new android.os.Message();
msg.what = recorder.getMaxAmplitude() * 13 / 0x7FFF;
handler.sendMessage(msg);
SystemClock.sleep(100);
}
} catch (Exception e) {
// from the crash report website, found one NPE crash from
// one android 4.0.4 htc phone
// maybe handler is null for some reason
EMLog.e("voice", e.toString());
}
}
}).start();
代码示例来源:origin: lzan13/EaseUICustomer
@Override
public void run() {
try {
while (isRecording) {
android.os.Message msg = new android.os.Message();
msg.what = recorder.getMaxAmplitude() * 13 / 0x7FFF;
handler.sendMessage(msg);
SystemClock.sleep(100);
}
} catch (Exception e) {
// from the crash report website, found one NPE crash from
// one android 4.0.4 htc phone
// maybe handler is null for some reason
EMLog.e("voice", e.toString());
}
}
}).start();
代码示例来源:origin: stackoverflow.com
// Start recording but don't store data
MediaRecorder mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setOutputFile("/dev/null");
mediaRecorder.prepare();
mediaRecorder.start();
// Obtain maximum amplitude since last call of getMaxAmplitude()
while(someCondition) {
int amplitude = mediaRecorder.getMaxAmplitude();
}
// Don't forget to release
mediaRecorder.reset();
mediaRecorder.release();
内容来源于网络,如有侵权,请联系作者删除!