|
@@ -46,17 +46,14 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
public static final Map<String, WebSocketSession> WS_CLIENTS = new ConcurrentHashMap<>();
|
|
|
|
|
|
private final BigDecimal oneHundred = new BigDecimal(100);
|
|
|
-
|
|
|
- //检测偏移时长的最终时间
|
|
|
- private final int endCheckOffsetTime = 500;
|
|
|
-
|
|
|
- private final float simpleRate = 44100;
|
|
|
- private int simpleSize = 512;
|
|
|
+ private final float simpleRate = 44200;
|
|
|
+ private final int simpleSize = 512;
|
|
|
+ private final int overlap = 256;
|
|
|
|
|
|
private final AudioFormat audioFormat = new AudioFormat(simpleRate, 16, 1, true, false);
|
|
|
private static final PitchProcessor.PitchEstimationAlgorithm algo = PitchProcessor.PitchEstimationAlgorithm.FFT_YIN;
|
|
|
|
|
|
- private static final String tmpDir = FileUtils.getTempDirectoryPath() + "/soundCompare/";
|
|
|
+ private final String tmpDir = FileUtils.getTempDirectoryPath() + "/soundCompare/";
|
|
|
|
|
|
//用户对应评分信息
|
|
|
private Map<String, SoundCompareHelper> userSoundInfoMap = new ConcurrentHashMap<>();
|
|
@@ -160,7 +157,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
}
|
|
|
|
|
|
List<MusicPitchDetailDto> recordInfo = new ArrayList<>();
|
|
|
- AudioDispatcher dispatcher = AudioDispatcherFactory.fromByteArray(message.getPayload().array(), audioFormat, simpleSize, 256);
|
|
|
+ AudioDispatcher dispatcher = AudioDispatcherFactory.fromByteArray(message.getPayload().array(), audioFormat, simpleSize, overlap);
|
|
|
dispatcher.addAudioProcessor(new PitchProcessor(algo, simpleRate, simpleSize, (pitchDetectionResult, audioEvent) -> {
|
|
|
int timeStamp = (int) (userSoundInfoMap.get(phone).getMeasureStartTime() + audioEvent.getTimeStamp()*1000);
|
|
|
float pitch = pitchDetectionResult.getPitch();
|