|
@@ -39,17 +39,22 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketHandler.class);
|
|
|
|
|
|
- //存储客户端链接
|
|
|
+ /**
|
|
|
+ * @describe 存储客户端链接
|
|
|
+ */
|
|
|
public static final Map<String, WebSocketClientDetail> WS_CLIENTS = new ConcurrentHashMap<>();
|
|
|
|
|
|
private BigDecimal oneHundred = new BigDecimal(100);
|
|
|
|
|
|
private final String tmpDir = FileUtils.getTempDirectoryPath() + "/soundCompare/";
|
|
|
|
|
|
- //用户对应评分信息
|
|
|
+ /**
|
|
|
+ * @describe 用户对应评分信息
|
|
|
+ */
|
|
|
private Map<String, SoundCompareHelper> userSoundInfoMap = new ConcurrentHashMap<>();
|
|
|
-
|
|
|
- //音频处理参数
|
|
|
+ /**
|
|
|
+ * @describe 音频处理参数
|
|
|
+ */
|
|
|
private SoundCompareConfig soundCompareConfig = new SoundCompareConfig();
|
|
|
|
|
|
@Autowired
|
|
@@ -155,7 +160,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
}
|
|
|
|
|
|
AudioDispatcher dispatcher = AudioDispatcherFactory.fromByteArray(message.getPayload().array(), soundCompareConfig.audioFormat, soundCompareConfig.simpleSize, soundCompareConfig.overlap);
|
|
|
- dispatcher.addAudioProcessor(soundCompareConfig.silenceDetecor);
|
|
|
+ dispatcher.addAudioProcessor(soundCompareConfig.silenceDetector);
|
|
|
dispatcher.addAudioProcessor(new PitchProcessor(soundCompareConfig.algo, soundCompareConfig.simpleRate, soundCompareConfig.simpleSize, (pitchDetectionResult, audioEvent) -> {
|
|
|
int timeStamp = (int) (userSoundInfoMap.get(phone).getMeasureStartTime() + audioEvent.getTimeStamp()*1000);
|
|
|
float pitch = pitchDetectionResult.getPitch();
|
|
@@ -163,11 +168,11 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
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);
|
|
|
}
|
|
|
- if(soundCompareConfig.silenceDetecor.currentSPL()<soundCompareConfig.validDb){
|
|
|
+ if(soundCompareConfig.silenceDetector.currentSPL()<soundCompareConfig.validDb){
|
|
|
pitch = -1;
|
|
|
}
|
|
|
// LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, silenceDetecor.currentSPL());
|
|
|
- userSoundInfoMap.get(phone).getRecordMeasurePithInfo().add(new MusicPitchDetailDto(timeStamp, pitch, soundCompareConfig.silenceDetecor.currentSPL()));
|
|
|
+ userSoundInfoMap.get(phone).getRecordMeasurePithInfo().add(new MusicPitchDetailDto(timeStamp, pitch, soundCompareConfig.silenceDetector.currentSPL()));
|
|
|
}));
|
|
|
dispatcher.run();
|
|
|
if(Objects.isNull(userSoundInfoMap.get(phone).getAccessFile())){
|