我似乎这个问题被卡住,的Android AudioRecord MP3编码AudioFormat.CHANNEL_IN_STEREO
我试图让 https://github.com/yhirano/SimpleLameLibForAndroid 对channelConfig AudioFormat.CHANNEL_IN_STEREO模式下工作。
下面的代码完美地工作,如果我用channelConfig = AudioFormat.CHANNEL_IN_MONO调用它,但不能用STEREO调用它。
我已经打得四处
short[] buffer = new short[mSampleRate * (16/8) * nChannels * 5]
byte[] mp3buffer = new byte[(int) (7200 + buffer.length * 2 * 1.25)];
BU似乎无法得到它的工作。我的意思是它的工作原理,但录制的声音非常慢。听这个例子https://dl.dropboxusercontent.com/u/1465252/1381762795295.mp3
似乎还有另一个类似的问题在Lame encoded mp3 audio slowed down - Android没有解决方案。
任何人都可以帮忙吗?
下面是代码:
new Mp3Audio(MediaRecorder.AudioSource.MIC, 44100, AudioFormat.CHANNEL_IN_STEREO, A udioFormat.ENCODING_PCM_16BIT, 128);
public Mp3Audio(int audioSource, int sampleRate, int channelConfig, int audioFormat, int bitRate) {
if (sampleRate <= 0) {
throw new InvalidParameterException(
"Invalid sample rate specified.");
}
mSampleRate = sampleRate;
mBitRate = bitRate;
if (channelConfig == AudioFormat.CHANNEL_IN_MONO) {
nChannels = 1;
} else {
nChannels = 2;
}
builder = new Builder(mSampleRate, nChannels, mSampleRate, mBitRate);
//builder = new Builder(44100, 1, 44100, 128);
builder.quality(6);
mEncoder = builder.create();
cAmplitude = 0;
payloadSize = 0;
aFormat = audioFormat;
aSource = audioSource;
mChannelConfig = channelConfig;
}
public void start() {
final int minBufferSize = AudioRecord.getMinBufferSize(mSampleRate, mChannelConfig, aFormat) * mBufferSizeFactor;
if (minBufferSize < 0) {
AppHelper.Log(tag, "MSG_ERROR_GET_MIN_BUFFERSIZE");
return;
}
AppHelper.Log(tag, "minBufferSize: " + AppHelper.humanReadableByteCount(minBufferSize, true));
aRecorder = new AudioRecord(
aSource,
mSampleRate,
mChannelConfig,
aFormat,
minBufferSize);
short[] buffer = new short[mSampleRate * (16/8) * nChannels * 5]; // SampleRate[Hz] * 16bit * Mono * 5sec
AppHelper.Log(tag, "buffer: " + AppHelper.humanReadableByteCount(buffer.length, true));
byte[] mp3buffer = new byte[(int) (7200 + buffer.length * 2 * 1.25)];
AppHelper.Log(tag, "mp3buffer: " + AppHelper.humanReadableByteCount(mp3buffer.length, true));
...... .......
您需要包括您对您的问题LAME库的调用。 – Michael