Browse Source

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

Joburgess 4 years ago
parent
commit
d464ac4ed1

+ 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 float validDb = (float) -65;
+    public int validDb = 20;
     /**
     /**
      * @describe 有效频率
      * @describe 有效频率
      */
      */

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

@@ -290,7 +290,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
     public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
     public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
         int timeStamp = (int) (measureStartTime + audioEvent.getTimeStamp()*1000);
         int timeStamp = (int) (measureStartTime + audioEvent.getTimeStamp()*1000);
         float pitch = pitchDetectionResult.getPitch();
         float pitch = pitchDetectionResult.getPitch();
-        double decibel = silenceDetector.currentSPL();
+        int decibel = (int) (100 - Math.abs(silenceDetector.currentSPL()));
         //初始化偏移时间
         //初始化偏移时间
         if(offsetTime == -1 && decibel>SoundCompareHandler.soundCompareConfig.validDb){
         if(offsetTime == -1 && decibel>SoundCompareHandler.soundCompareConfig.validDb){
             offsetTime = timeStamp;
             offsetTime = timeStamp;
@@ -309,11 +309,13 @@ public class SoundCompareHelper implements PitchDetectionHandler {
             }
             }
         }
         }
 
 
-        SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
-
-        if(decibel < SoundCompareHandler.soundCompareConfig.validDb){
+        if(decibel <= SoundCompareHandler.soundCompareConfig.validDb){
             pitch = -1;
             pitch = -1;
+            decibel = 0;
         }
         }
+
+        SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
+
 //        if(pitch==-1){
 //        if(pitch==-1){
 //            decibel = SoundCompareHandler.soundCompareConfig.validDb;
 //            decibel = SoundCompareHandler.soundCompareConfig.validDb;
 //        }
 //        }