|
@@ -378,11 +378,31 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //非正常频率次数
|
|
|
|
+ int errPitchNum = 0;
|
|
|
|
+
|
|
if(CollectionUtils.isEmpty(musicalNotesPitchs)){
|
|
if(CollectionUtils.isEmpty(musicalNotesPitchs)){
|
|
userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(musicXmlInfo.getMusicalNotesIndex(), (float) 0);
|
|
userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(musicXmlInfo.getMusicalNotesIndex(), (float) 0);
|
|
}else{
|
|
}else{
|
|
Map<Integer, Long> collect = musicalNotesPitchs.stream().collect(Collectors.groupingBy(Integer::intValue, Collectors.counting()));
|
|
Map<Integer, Long> collect = musicalNotesPitchs.stream().collect(Collectors.groupingBy(Integer::intValue, Collectors.counting()));
|
|
|
|
+ //出现次数最多的频率
|
|
Integer pitch = collect.entrySet().stream().max(Comparator.comparing(e -> e.getValue())).get().getKey();
|
|
Integer pitch = collect.entrySet().stream().max(Comparator.comparing(e -> e.getValue())).get().getKey();
|
|
|
|
+ boolean ing = false;
|
|
|
|
+ int dnum = 0;
|
|
|
|
+ for (Integer musicalNotesPitch : musicalNotesPitchs) {
|
|
|
|
+ if (!ing && Math.abs(musicalNotesPitch - pitch) <= 20){
|
|
|
|
+ ing = true;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (ing && Math.abs(musicalNotesPitch - pitch) > 20){
|
|
|
|
+ dnum++;
|
|
|
|
+ }
|
|
|
|
+ if (dnum>=2){
|
|
|
|
+ dnum = 0;
|
|
|
|
+ errPitchNum++;
|
|
|
|
+ ing = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(musicXmlInfo.getMusicalNotesIndex(), (float) pitch);
|
|
userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(musicXmlInfo.getMusicalNotesIndex(), (float) pitch);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -392,6 +412,10 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
float intonationDuty = recordValidIntonationNum/compareNum;
|
|
float intonationDuty = recordValidIntonationNum/compareNum;
|
|
//有效节奏占比
|
|
//有效节奏占比
|
|
float cadenceDuty = cadenceValidNum/compareNum;
|
|
float cadenceDuty = cadenceValidNum/compareNum;
|
|
|
|
+ //如果错误频率达到一定数值,则当前小节无效
|
|
|
|
+ if(errPitchNum>=3){
|
|
|
|
+ cadenceDuty = 0;
|
|
|
|
+ }
|
|
//节奏
|
|
//节奏
|
|
if(cadenceDuty>=cadenceValidDuty){
|
|
if(cadenceDuty>=cadenceValidDuty){
|
|
cadenceNum++;
|
|
cadenceNum++;
|