Joburgess 4 лет назад
Родитель
Сommit
da63b275e4

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/handler/WebSocketHandler.java

@@ -166,7 +166,8 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
             int timeStamp = (int) (userSoundInfoMap.get(phone).getMeasureStartTime() + audioEvent.getTimeStamp()*1000);
             float pitch = pitchDetectionResult.getPitch();
             if(pitch>0 && userSoundInfoMap.get(phone).getOffsetTime() == -1){
-                calOffsetTime(phone, (int) (CollectionUtils.isEmpty(userSoundInfoMap.get(phone).getRecordMeasurePithInfo())?0:userSoundInfoMap.get(phone).getRecordMeasurePithInfo().get(userSoundInfoMap.get(phone).getRecordMeasurePithInfo().size()-1).getTimeStamp()));
+                int preTimeStamp = CollectionUtils.isEmpty(userSoundInfoMap.get(phone).getRecordMeasurePithInfo())?0:userSoundInfoMap.get(phone).getRecordMeasurePithInfo().get(userSoundInfoMap.get(phone).getRecordMeasurePithInfo().size()-1).getTimeStamp();
+                calOffsetTime(phone, timeStamp - (timeStamp - preTimeStamp)/2);
             }
 //            LOGGER.info("时间:{}, 频率:{}, 分贝:{}, 音分:{}", timeStamp, pitch, silenceDetecor.currentSPL(), cents);
             userSoundInfoMap.get(phone).getRecordMeasurePithInfo().add(new MusicPitchDetailDto(timeStamp, pitch, silenceDetecor.currentSPL()));