Browse Source

feat:云教练音准与节奏计算逻辑调整

Joburgess 3 years ago
parent
commit
c9774b3e94

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/config/SoundCompareConfig.java

@@ -35,7 +35,7 @@ public class SoundCompareConfig {
     /**
     /**
      * @describe 有效分贝大小
      * @describe 有效分贝大小
      */
      */
-    public int validDb = 40;
+    public int validDb = 30;
     /**
     /**
      * @describe 有效频率
      * @describe 有效频率
      */
      */

+ 3 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SoundCompareHelper.java

@@ -323,11 +323,10 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         float pitch = pitchDetectionResult.getPitch();
         float pitch = pitchDetectionResult.getPitch();
         int decibel = (int) (100 - Math.abs(silenceDetector.currentSPL()));
         int decibel = (int) (100 - Math.abs(silenceDetector.currentSPL()));
 
 
-        int byteIndex = (int) (audioEvent.getTimeStamp()*(SoundCompareHandler.soundCompareConfig.audioFormat.getFrameSize()*SoundCompareHandler.soundCompareConfig.audioFormat.getFrameRate()));
-        byte byteOne = audioEvent.getByteBuffer()[byteIndex];
-        byte byteTwo = audioEvent.getByteBuffer()[byteIndex + 1];
+        byte byteOne = audioEvent.getByteBuffer()[0];
+        byte byteTwo = audioEvent.getByteBuffer()[1];
 
 
-        double amplitude = ((byteOne&0x000000FF)|(byteTwo<<8));
+        double amplitude = Math.abs(((byteOne&0x000000FF)|(byteTwo<<8)));
 
 
         if(decibel <= SoundCompareHandler.soundCompareConfig.validDb){
         if(decibel <= SoundCompareHandler.soundCompareConfig.validDb){
             pitch = -1;
             pitch = -1;