|
@@ -58,10 +58,10 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
@ApiModelProperty(value = "播放速度")
|
|
|
private int speed = 90;
|
|
|
|
|
|
- @ApiModelProperty(value = "小节xml信息字典")
|
|
|
+ @ApiModelProperty(value = "xml中每个小节的音符详情")
|
|
|
private Map<Integer, List<MusicPitchDetailDto>> measureXmlInfoMap = new HashMap<>();
|
|
|
|
|
|
- @ApiModelProperty(value = "小节结束时间字典")
|
|
|
+ @ApiModelProperty(value = "xml中每小节开始时间、结束时间")
|
|
|
private Map<Integer, MusicPitchDetailDto> measureEndTime = new HashMap<>();
|
|
|
|
|
|
// @ApiModelProperty(value = "录音音频信息")
|
|
@@ -72,7 +72,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
|
|
|
private Map<Integer, Map<String, Object>> userMeasureScoreMap = new HashMap<>();
|
|
|
|
|
|
- @ApiModelProperty(value = "音符频率字典")
|
|
|
+ @ApiModelProperty(value = "xml中每个音符频率")
|
|
|
private Map<Integer, Float> musicalNotePitchMap = new HashMap<>();
|
|
|
|
|
|
@ApiModelProperty(value = "每个音符评测结果")
|
|
@@ -81,10 +81,13 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
@ApiModelProperty(value = "偏移时间量,解决客户端录音播放不同步导致的声音留白")
|
|
|
private int offsetTime = -1;
|
|
|
|
|
|
+ /** xml中每个音符详情 */
|
|
|
private List<MusicPitchDetailDto> musicXmlInfos;
|
|
|
|
|
|
+ /** 第一个音符前有多少个字节 */
|
|
|
private long firstMeasureStartBytes = 0;
|
|
|
|
|
|
+ /** 文件的总字节数长度 */
|
|
|
private long recordBytes = 0;
|
|
|
|
|
|
private String clientId;
|
|
@@ -109,10 +112,18 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
*/
|
|
|
public SilenceDetector silenceDetector = new SilenceDetector();
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每个音符详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<MusicPitchDetailDto> getMusicXmlInfos() {
|
|
|
return musicXmlInfos;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每个音符详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setMusicXmlInfos(List<MusicPitchDetailDto> musicXmlInfos) {
|
|
|
this.musicXmlInfos = musicXmlInfos;
|
|
|
}
|
|
@@ -213,6 +224,10 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
this.musicScoreId = musicScoreId;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 录音文件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public RandomAccessFile getAccessFile() {
|
|
|
return accessFile;
|
|
|
}
|
|
@@ -233,6 +248,10 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
this.recordFilePath = recordFilePath;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 录音文件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setAccessFile(RandomAccessFile accessFile) {
|
|
|
this.accessFile = accessFile;
|
|
|
}
|
|
@@ -253,58 +272,114 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
this.measureStartTime = measureStartTime;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每个小节的音符详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Map<Integer, List<MusicPitchDetailDto>> getMeasureXmlInfoMap() {
|
|
|
return measureXmlInfoMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每个小节的音符详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setMeasureXmlInfoMap(Map<Integer, List<MusicPitchDetailDto>> measureXmlInfoMap) {
|
|
|
this.measureXmlInfoMap = measureXmlInfoMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每小节开始时间、结束时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Map<Integer, MusicPitchDetailDto> getMeasureEndTime() {
|
|
|
return measureEndTime;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * xml中每小节开始时间、结束时间
|
|
|
+ * @param measureEndTime
|
|
|
+ */
|
|
|
public void setMeasureEndTime(Map<Integer, MusicPitchDetailDto> measureEndTime) {
|
|
|
this.measureEndTime = measureEndTime;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 每个音符的评测结果
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<MusicalNotesPlayStatDto> getMusicalNotesPlayStats() {
|
|
|
return musicalNotesPlayStats;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 每个音符的评测结果
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setMusicalNotesPlayStats(List<MusicalNotesPlayStatDto> musicalNotesPlayStats) {
|
|
|
this.musicalNotesPlayStats = musicalNotesPlayStats;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小节累积得分(节奏、音准、完整度)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Map<String, BigDecimal> getUserScoreMap() {
|
|
|
return userScoreMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小节累积得分(节奏、音准、完整度)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setUserScoreMap(Map<String, BigDecimal> userScoreMap) {
|
|
|
this.userScoreMap = userScoreMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 第一个音符前有多少个字节
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public long getFirstMeasureStartBytes() {
|
|
|
return firstMeasureStartBytes;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 第一个音符前有多少个字节
|
|
|
+ * @param firstMeasureStartBytes
|
|
|
+ */
|
|
|
public void setFirstMeasureStartBytes(long firstMeasureStartBytes) {
|
|
|
this.firstMeasureStartBytes = firstMeasureStartBytes;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 文件的总字节数长度
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public long getRecordBytes() {
|
|
|
return recordBytes;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 文件的总字节数长度
|
|
|
+ * @param recordBytes
|
|
|
+ */
|
|
|
public void setRecordBytes(long recordBytes) {
|
|
|
this.recordBytes = recordBytes;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小节得分结果
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Map<Integer, Map<String, Object>> getUserMeasureScoreMap() {
|
|
|
return userMeasureScoreMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小节得分结果
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public void setUserMeasureScoreMap(Map<Integer, Map<String, Object>> userMeasureScoreMap) {
|
|
|
this.userMeasureScoreMap = userMeasureScoreMap;
|
|
|
}
|
|
@@ -330,6 +405,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
|
|
|
SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
|
|
|
|
|
|
+ //上次的频率与本次的频率相差10hz或分贝相差10
|
|
|
if(currPitchInfos.size()>0&&(Math.abs(currPitchInfos.get(currPitchInfos.size()-1).getFrequency()-pitch)>10||Math.abs(currPitchInfos.get(currPitchInfos.size()-1).getDecibel()-decibel)>10)){
|
|
|
Double avgPitch = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getFrequency));
|
|
|
Double avgDb = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getDecibel));
|
|
@@ -355,7 +431,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- musicXmlInfos.forEach(e->e.setTimeStamp(e.getTimeStamp()+offsetTime));
|
|
|
+ musicXmlInfos.forEach(e->e.setTimeStamp(e.getTimeStamp()+offsetTime));//??????
|
|
|
for (Map.Entry<Integer, MusicPitchDetailDto> musicPitchDetailDtoEntry : measureEndTime.entrySet()) {
|
|
|
musicPitchDetailDtoEntry.getValue().setTimeStamp(musicPitchDetailDtoEntry.getValue().getTimeStamp() + offsetTime);
|
|
|
musicPitchDetailDtoEntry.getValue().setEndTimeStamp(musicPitchDetailDtoEntry.getValue().getEndTimeStamp() + offsetTime);
|