java audiorecord_Java AudioRecord.setRecordPositionUpdateListener方法代码示例

import android.media.AudioRecord; //导入方法依赖的package包/类

/**

*

*

* Default constructor

*

* Instantiates a new recorder, in case of compressed recording the

* parameters can be left as 0. In case of errors, no exception is thrown,

* but the state is set to ERROR

*

*/

@SuppressWarnings("deprecation")

public ExtAudioRecorder(boolean uncompressed, int audioSource,

int sampleRate, int channelConfig, int audioFormat) {

try {

rUncompressed = uncompressed;

if (rUncompressed) { // RECORDING_UNCOMPRESSED

if (audioFormat == AudioFormat.ENCODING_PCM_16BIT) {

bSamples = 16;

} else {

bSamples = 8;

}

if (channelConfig == AudioFormat.CHANNEL_CONFIGURATION_MONO) {

nChannels = 1;

} else {

nChannels = 2;

}

aSource = audioSource;

sRate = sampleRate;

aFormat = audioFormat;

framePeriod = sampleRate * TIMER_INTERVAL / 1000;

bufferSize = framePeriod * 2 * bSamples * nChannels / 8;

if (bufferSize < AudioRecord.getMinBufferSize(sampleRate,

channelConfig, audioFormat)) { // Check to make sure

// buffer size is not

// smaller than the

// smallest allowed one

bufferSize = AudioRecord.getMinBufferSize(sampleRate,

channelConfig, audioFormat);

// Set frame period and timer interval accordingly

framePeriod = bufferSize / (2 * bSamples * nChannels / 8);

Log.w(ExtAudioRecorder.class.getName(),

"Increasing buffer size to "

+ Integer.toString(bufferSize));

}

audioRecorder = new AudioRecord(audioSource, sampleRate,

channelConfig, audioFormat, bufferSize);

if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED)

throw new Exception("AudioRecord initialization failed");

audioRecorder.setRecordPositionUpdateListener(updateListener);

audioRecorder.setPositionNotificationPeriod(framePeriod);

} else { // RECORDING_COMPRESSED

mediaRecorder = new MediaRecorder();

mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

mediaRecorder

.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

mediaRecorder

.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

}

cAmplitude = 0;

filePath = null;

state = State.INITIALIZING;

} catch (Exception e) {

if (e.getMessage() != null) {

Log.e(ExtAudioRecorder.class.getName(), e.getMessage());

} else {

Log.e(ExtAudioRecorder.class.getName(),

"Unknown error occured while initializing recording");

}

state = State.ERROR;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这些文件是与音频处理相关的代码文件,属于Android系统中的音频相关模块。下面简单介绍一下每个文件的作用: - alsa_config_parameters.c:alsa驱动的配置参数管理。 - alsa_manager.c:alsa驱动的管理,包括打开、关闭、读写等操作。 - aml_audio_delay.c:音频延迟的处理。 - aml_audio_dev2mix_process.c:音频设备到混音器的音频数据处理。 - aml_audio_ease.c:音频的平滑处理。 - aml_audio_hal_avsync.c:音频硬件同步的处理。 - aml_audio_mixer.c、amlAudioMixer.c、sub_mixing_factory.c:音频混音的处理。 - aml_audio_ms12_bypass.c、aml_audio_ms12_render.c、aml_audio_ms12_sync.c:Dolby MS12音频的处理。 - aml_audio_nonms12_render.c:非Dolby MS12音频的处理。 - aml_audio_scaletempo.c:音频的变速变调处理。 - aml_audio_spdifout.c:SPDIF音频输出的处理。 - aml_audio_stream.c:音频流的处理。 - aml_audio_timer.c:音频定时器的处理。 - aml_avsync_tuning.c:音视频同步的调节。 - aml_config_data.c、aml_config_parser.c:音频相关配置数据的处理。 - aml_dtvsync.c:DTV同步的处理。 - aml_hfp.c:音频头戴式设备的处理。 - aml_mmap_audio.c:音频内存映射的处理。 - aml_vad_wakeup.c:语音唤醒的处理。 - audio_aec.c:音频回声消除的处理。 - audio_bt_sco.c:蓝牙SCO音频的处理。 - audio_dtv_utils.c:DTV音频的处理。 - audio_format_parse.c:音频格式解析的处理。 - audio_hdmi_util.c:HDMI音频的处理。 - audio_hw.c、audio_hw_dtv.c、audio_hw_ms12.c、audio_hw_ms12_common.c、audio_hw_ms12_v2.c、audio_hw_profile.c:音频硬件相关的处理。 - audio_hwsync.c、audio_hwsync_wrap.c:音频硬件同步的处理。 - audio_hw_utils.c:音频硬件工具类的处理。 - audio_kara.c:卡拉OK音频的处理。 - audio_mediasync_wrap.c:媒体同步的处理。 - audio_policy.c:音频策略的处理。 - audio_port.c:音频端口的管理。 - audio_post_process.c:音频后处理的处理。 - audio_tsync_wrap.c:时间同步的处理。 - audio_usb_hal.c:USB音频的处理。 - audio_virtual_buf.c:虚拟音频缓冲的处理。 - dolby_lib_api.c:Dolby音频库的API。 - earc_utils.c:EARC音频的处理。 - hw_avsync.c、hw_avsync_callbacks.c:硬件音视频同步的处理。 - karaoke_manager.c:卡拉OK管理的处理。 - spdif_encoder_api.c:SPDIF编码的API。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值