Browse Source

feat:优惠券

Joburgess 4 years ago
parent
commit
5dfaa2c906

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

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

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

@@ -292,7 +292,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         float pitch = pitchDetectionResult.getPitch();
         double decibel = silenceDetector.currentSPL();
         //初始化偏移时间
-        if(offsetTime == -1 && !DeviceTypeEnum.IOS.equals(deviceType) && pitch>0){
+        if(offsetTime == -1 && decibel>SoundCompareHandler.soundCompareConfig.validDb){
             offsetTime = timeStamp;
             for (MusicPitchDetailDto musicXmlInfo : musicXmlInfos) {
                 if(!musicXmlInfo.getDontEvaluating()){
@@ -312,10 +312,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
 
         if(decibel < SoundCompareHandler.soundCompareConfig.validDb){
-            decibel = SoundCompareHandler.soundCompareConfig.validDb;
             pitch = -1;
-        }else{
-            decibel = 0;
         }
 //        if(pitch==-1){
 //            decibel = SoundCompareHandler.soundCompareConfig.validDb;
@@ -324,6 +321,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
 
         Double avgPitch = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getFrequency));
         Double avgDb = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getDecibel));
+
         long count = currPitchInfos.stream().filter(p -> p.getFrequency() < 0).count();
         if(currPitchInfos.size()>0&&count/currPitchInfos.size()<0.5){
             avgPitch = currPitchInfos.stream().skip(1).filter(p->p.getFrequency()>0).collect(Collectors.averagingDouble(MusicPitchDetailDto::getFrequency));

+ 6 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundCompareHandler.java

@@ -180,10 +180,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 createHeader(phone, false);
                 break;
             case SoundSocketService.PROXY_MESSAGE:
-                if(DeviceTypeEnum.IOS.equals(userSoundInfoMap.get(phone).getDeviceType())&&bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
-                    int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
-                    calOffsetTime(phone, offsetTime);
-                }
+//                if(DeviceTypeEnum.IOS.equals(userSoundInfoMap.get(phone).getDeviceType())&&bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
+//                    int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
+//                    calOffsetTime(phone, offsetTime);
+//                }
                 break;
             case VIDEO_UPDATE:
                 if(bodyObject.containsKey("filePath")){
@@ -354,7 +354,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 int startTimeStamp = musicXmlInfo.getTimeStamp();
                 int endTimeStamp = musicXmlInfo.getTimeStamp() + musicXmlInfo.getDuration();
 
-                int ot5 = (int) (musicXmlInfo.getDuration()*0.3);
+                int ot5 = (int) (musicXmlInfo.getDuration()*0.23);
 
                 List<MusicPitchDetailDto> recordPitchs = userSoundInfoMap.get(phone).getRecordMeasurePitchInfos().stream().filter(m -> m.getTimeStamp()>=startTimeStamp-ot5 && m.getTimeStamp() < endTimeStamp-ot5).collect(Collectors.toList());
 
@@ -368,7 +368,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 }
                 integrityDuty = scoreMapping(integrityDuty, userSoundInfoMap.get(phone).getHeardLevel().getIntegrityRange(), 1);
                 //节奏
-                if(recordPitchs.size()>0&&(Math.abs(recordPitchs.get(0).getTimeStamp()-startTimeStamp)<ot5)&&(recordPitchs.size()<2)){
+                if(recordPitchs.size()==1){
                     cadenceNum++;
                     cadenceRight = true;
                 }