|
@@ -169,7 +169,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
if (pitch > 0) {
|
|
|
cents = PitchConverter.hertzToAbsoluteCent(pitch);
|
|
|
}
|
|
|
- LOGGER.info("时间:{}, 频率:{}, 分贝:{}, 音分:{}", timeStamp, pitch, silenceDetecor.currentSPL(), cents);
|
|
|
+// LOGGER.info("时间:{}, 频率:{}, 分贝:{}, 音分:{}", timeStamp, pitch, silenceDetecor.currentSPL(), cents);
|
|
|
// if (silenceDetecor.currentSPL() <= -60){
|
|
|
// pitch = -1;
|
|
|
// }
|
|
@@ -414,34 +414,34 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
//节奏
|
|
|
if(cadenceDuty>=cadenceValidDuty){
|
|
|
cadenceNum++;
|
|
|
- //音准
|
|
|
- if (!CollectionUtils.isEmpty(musicalNotesPitchs)){
|
|
|
- Double avgPitch = musicalNotesPitchs.stream().filter(pitch -> Math.abs((pitch-musicXmlInfo.getFrequency()))<5).collect(Collectors.averagingDouble(pitch -> pitch));
|
|
|
- //音分
|
|
|
- double recordCents = 0;
|
|
|
- if (avgPitch > 0){
|
|
|
- recordCents = PitchConverter.hertzToAbsoluteCent(avgPitch);
|
|
|
- }
|
|
|
- double cents = PitchConverter.hertzToAbsoluteCent(musicXmlInfo.getFrequency());
|
|
|
- double score = 100 - Math.round(Math.abs(cents - recordCents)) + 3;
|
|
|
- if (score < 0){
|
|
|
- score = 0;
|
|
|
- }else if(score > 100){
|
|
|
- score = 100;
|
|
|
- }
|
|
|
- intonationScore += score;
|
|
|
- musicXmlInfo.setAvgFrequency(avgPitch.floatValue());
|
|
|
- }
|
|
|
- //完成度
|
|
|
- if(integrityValidNum>0){
|
|
|
- integrityValidNum = integrityValidNum + (float) (compareNum * 0.05);
|
|
|
+ }
|
|
|
+ //音准
|
|
|
+ if (!CollectionUtils.isEmpty(musicalNotesPitchs)){
|
|
|
+ Double avgPitch = musicalNotesPitchs.stream().filter(pitch -> Math.abs((pitch-musicXmlInfo.getFrequency()))<5).collect(Collectors.averagingDouble(pitch -> pitch));
|
|
|
+ //音分
|
|
|
+ double recordCents = 0;
|
|
|
+ if (avgPitch > 0){
|
|
|
+ recordCents = PitchConverter.hertzToAbsoluteCent(avgPitch);
|
|
|
}
|
|
|
- if(integrityValidNum > compareNum){
|
|
|
- integrityValidNum = compareNum;
|
|
|
+ double cents = PitchConverter.hertzToAbsoluteCent(musicXmlInfo.getFrequency());
|
|
|
+ double score = 100 - Math.round(Math.abs(cents - recordCents)) + 3;
|
|
|
+ if (score < 0){
|
|
|
+ score = 0;
|
|
|
+ }else if(score > 100){
|
|
|
+ score = 100;
|
|
|
}
|
|
|
- float integrityDuty = integrityValidNum/compareNum;
|
|
|
- integrityScore += integrityDuty;
|
|
|
+ intonationScore += score;
|
|
|
+ musicXmlInfo.setAvgFrequency(avgPitch.floatValue());
|
|
|
}
|
|
|
+ //完成度
|
|
|
+ if(integrityValidNum>0){
|
|
|
+ integrityValidNum = integrityValidNum + (float) (compareNum * 0.05);
|
|
|
+ }
|
|
|
+ if(integrityValidNum > compareNum){
|
|
|
+ integrityValidNum = compareNum;
|
|
|
+ }
|
|
|
+ float integrityDuty = integrityValidNum/compareNum;
|
|
|
+ integrityScore += integrityDuty;
|
|
|
}
|
|
|
|
|
|
BigDecimal measureNum = new BigDecimal(totalCompareNum);
|