|
@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.HeardLevelEnum;
|
|
|
import com.ym.mec.biz.service.impl.SoundCompareHandler;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.RandomAccessFile;
|
|
@@ -308,14 +309,17 @@ 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;
|
|
|
- }
|
|
|
-// SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
|
|
|
+// if(pitch==-1){
|
|
|
+// decibel = SoundCompareHandler.soundCompareConfig.validDb;
|
|
|
+// }
|
|
|
// recordMeasurePithInfo.add(new MusicPitchDetailDto(timeStamp, pitch, silenceDetector.currentSPL()));
|
|
|
|
|
|
Double avgPitch = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getFrequency));
|
|
@@ -332,11 +336,11 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
}
|
|
|
|
|
|
if(obviousChangeNum>1){
|
|
|
-// SoundCompareHandler.LOGGER.info("----------------------------{}----{}", avgPitch, recordMeasurePitchInfos.size());
|
|
|
-// SoundCompareHandler.LOGGER.info("----------------------------{}", JSON.toJSONString(currPitchInfos.stream().map(MusicPitchDetailDto::getFrequency).collect(Collectors.toList())));
|
|
|
-// SoundCompareHandler.LOGGER.info("----------------------------{}", JSON.toJSONString(currTmpPitchInfos.stream().map(MusicPitchDetailDto::getFrequency).collect(Collectors.toList())));
|
|
|
+ SoundCompareHandler.LOGGER.info("----------------------------{}---{}----{}", avgPitch, avgDb, recordMeasurePitchInfos.size());
|
|
|
+ SoundCompareHandler.LOGGER.info("----------------------------{}", JSON.toJSONString(currPitchInfos.stream().map(MusicPitchDetailDto::getFrequency).collect(Collectors.toList())));
|
|
|
+ SoundCompareHandler.LOGGER.info("----------------------------{}", JSON.toJSONString(currTmpPitchInfos.stream().map(MusicPitchDetailDto::getFrequency).collect(Collectors.toList())));
|
|
|
|
|
|
- if(avgPitch>0&&currPitchInfos.size()>2){
|
|
|
+ if(!CollectionUtils.isEmpty(currPitchInfos)&&(avgPitch>0||avgDb>SoundCompareHandler.soundCompareConfig.validDb)){
|
|
|
MusicPitchDetailDto measureDetail = new MusicPitchDetailDto(currPitchInfos.get(0).getTimeStamp(), avgPitch.floatValue(), avgDb);
|
|
|
measureDetail.setEndTimeStamp(currTmpPitchInfos.get(0).getTimeStamp());
|
|
|
measureDetail.setDuration(measureDetail.getEndTimeStamp()-measureDetail.getTimeStamp());
|