Skip to content

Commit 59ec2bf

Browse files
committed
补充修改变调commit
Change-Id: I20f39ba57be8cafe5dfc72308fcbe61366ef7ddc
1 parent b702906 commit 59ec2bf

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

sdk/video-link-android/src/main/java/com/tencent/iot/video/link/util/audio/AudioRecordUtil.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AudioRecordUtil implements EncoderListener, FLVListener {
3636
private int channel;
3737
private int bitDepth;
3838
private int channelCount; //声道数
39-
private int pitch; //变调【-12~12】
39+
private int pitch = 0; //变调【-12~12】
4040

4141
private boolean isRecord = false;
4242
private final ExecutorService executor = Executors.newSingleThreadExecutor();
@@ -60,10 +60,6 @@ public AudioRecordUtil(Context ctx, String id, int sampleRate, int channel, int
6060
deviceId = id;
6161
this.pitch = pitch;
6262
init(sampleRate, channel, bitDepth);
63-
64-
if (st == null) {
65-
st = new SoundTouch(0,channelCount,sampleRate,bitDepth,1.0f, pitch);
66-
}
6763
}
6864

6965
private void init(int sampleRate, int channel, int bitDepth) {
@@ -105,6 +101,9 @@ public void recordSpeakFlv(boolean isRecord) {
105101
*/
106102
public void start() {
107103
reset();
104+
if (st == null) {
105+
st = new SoundTouch(0,channelCount,sampleRate,bitDepth,1.0f, pitch);
106+
}
108107
recorderState = true;
109108
audioRecord.startRecording();
110109
new RecordThread().start();
@@ -173,7 +172,7 @@ private class RecordThread extends Thread {
173172
public void run() {
174173
while (recorderState) {
175174
int read = audioRecord.read(buffer, 0, buffer.length);
176-
if (st != null) {
175+
if (pitch != 0 && st != null) {
177176
st.putBytes(buffer);
178177
int bytesReceived = st.getBytes(buffer);
179178
}

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface
137137
presenter.getEventsData(Date())
138138
tv_event_status.visibility = View.VISIBLE
139139
tv_event_status.setText(R.string.loading)
140-
audioRecordUtil = AudioRecordUtil(this, "${it.productId}/${presenter.getDeviceName()}", 16000)
140+
// audioRecordUtil = AudioRecordUtil(this, "${it.productId}/${presenter.getDeviceName()}", 16000)
141141
// //变调可以传入pitch参数
142-
// audioRecordUtil = AudioRecordUtil(this, "${it.productId}/${presenter.getDeviceName()}", 16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, -6)
142+
audioRecordUtil = AudioRecordUtil(this, "${it.productId}/${presenter.getDeviceName()}", 16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, -6)
143143
audioRecordUtil.recordSpeakFlv(true)
144144
}
145145

0 commit comments

Comments
 (0)