|
@@ -55,7 +55,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
/**
|
|
|
* @describe 音频处理参数
|
|
|
*/
|
|
|
- private SoundCompareConfig soundCompareConfig = new SoundCompareConfig();
|
|
|
+ public static final SoundCompareConfig soundCompareConfig = new SoundCompareConfig();
|
|
|
|
|
|
@Autowired
|
|
|
private SysMusicCompareRecordService sysMusicCompareRecordService;
|
|
@@ -110,6 +110,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
musicPitchDetailDto.setDontEvaluating(dc == userMeasureXmlInfoEntry.getValue().size());
|
|
|
userSoundInfoMap.get(phone).getMeasureEndTime().put(userMeasureXmlInfoEntry.getKey(), musicPitchDetailDto);
|
|
|
}
|
|
|
+
|
|
|
break;
|
|
|
case SoundSocketService.RECORD_START:
|
|
|
if(!userSoundInfoMap.containsKey(phone)){
|
|
@@ -161,19 +162,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
|
|
|
AudioDispatcher dispatcher = AudioDispatcherFactory.fromByteArray(message.getPayload().array(), soundCompareConfig.audioFormat, soundCompareConfig.simpleSize, soundCompareConfig.overlap);
|
|
|
dispatcher.addAudioProcessor(userSoundInfoMap.get(phone).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();
|
|
|
- if(pitch>0 && userSoundInfoMap.get(phone).getOffsetTime() == -1){
|
|
|
- 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(userSoundInfoMap.get(phone).silenceDetector.currentSPL()<soundCompareConfig.validDb){
|
|
|
- pitch = -1;
|
|
|
- }
|
|
|
-// LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, silenceDetecor.currentSPL());
|
|
|
- userSoundInfoMap.get(phone).getRecordMeasurePithInfo().add(new MusicPitchDetailDto(timeStamp, pitch, userSoundInfoMap.get(phone).silenceDetector.currentSPL()));
|
|
|
- }));
|
|
|
+ dispatcher.addAudioProcessor(new PitchProcessor(soundCompareConfig.algo, soundCompareConfig.simpleRate, soundCompareConfig.simpleSize, userSoundInfoMap.get(phone)));
|
|
|
dispatcher.run();
|
|
|
if(Objects.isNull(userSoundInfoMap.get(phone).getAccessFile())){
|
|
|
return;
|