ソースを参照

修改调音器音频采集参数

Pq 1 年間 前
コミット
f8696273be

+ 3 - 0
musictuner/src/main/java/com/cooleshow/musictuner/MusicTunerActivity.java

@@ -175,6 +175,9 @@ public class MusicTunerActivity extends BaseActivity<ActivityMusicTunerLayoutBin
 
     @Override
     protected void onDestroy() {
+        if (viewBinding != null) {
+            viewBinding.viewDashBoard.release();
+        }
         super.onDestroy();
         if (mMusicTunerHelper != null) {
             mMusicTunerHelper.release();

+ 3 - 2
musictuner/src/main/java/com/cooleshow/musictuner/utils/MusicTunerHelper.java

@@ -22,7 +22,8 @@ public class MusicTunerHelper {
     }
 
     public void start() {
-        mDispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 2048, 0);
+        mDispatcher = AudioDispatcherFactory.fromDefaultMicrophone(44100, 6144, 0);
+//        mDispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 2048, 0);
         PitchDetectionHandler pdh = new PitchDetectionHandler() {
             @Override
             public void handlePitch(PitchDetectionResult res, AudioEvent e) {
@@ -33,7 +34,7 @@ public class MusicTunerHelper {
                 }
             }
         };
-        AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN, 22050, 2048, pdh);
+        AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN, 44100, 6144, pdh);
         mDispatcher.addAudioProcessor(p);
         mThread = new Thread(mDispatcher, "Audio Dispatcher");
         mThread.start();

+ 7 - 0
musictuner/src/main/java/com/cooleshow/musictuner/widget/DashBoardView.java

@@ -359,4 +359,11 @@ public class DashBoardView extends View {
         }
         mAnimator.start();
     }
+
+    public void release() {
+        if (mAnimator != null) {
+            mAnimator.cancel();
+            mAnimator = null;
+        }
+    }
 }