yonge hai 5 meses
pai
achega
8c2434c05c

+ 8 - 2
audio-analysis/src/main/java/com/yonge/netty/dto/UserChannelContext.java

@@ -373,9 +373,9 @@ public class UserChannelContext {
 		// YINPitchDetector frequencyDetector = new YINPitchDetector(samples.length , audioFormat.getSampleRate());
 		// int playFrequency = (int) frequencyDetector.getFrequency(samples);
 
-		int playFrequency = -1;
+		float playFrequency = -1;
 		if (StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
-			playFrequency = (int) detector.getPitch(samples).getPitch();
+			playFrequency = detector.getPitch(samples).getPitch();
 		}
 
 		double splDb = 0;
@@ -691,6 +691,7 @@ public class UserChannelContext {
 	private int computeTempoWithFrequency(MusicXmlNote musicXmlNote, NoteAnalysis noteAnalysis, List<ChunkAnalysis> chunkAnalysisList) {
 		
 		if (chunkAnalysisList == null || chunkAnalysisList.size() == 0 || musicXmlNote.getDontEvaluating()) {
+			noteAnalysis.setMusicalErrorType(NoteErrorType.NOT_PLAY);
 			return -1;
 		}
 		
@@ -714,6 +715,7 @@ public class UserChannelContext {
 		}
 		
 		if(frequencyRhythmMap.size() > 1) {
+			noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
 			LOGGER.debug("根据音高检测到[{}]个断点,分别在[{}]", frequencyRhythmMap.size(), frequencyRhythmMap.values().stream().map(value -> value).map(Object::toString).collect(Collectors.joining(",")));
 			return 0;
 		}
@@ -730,11 +732,14 @@ public class UserChannelContext {
 			
 			if ((firstBeatTime - firstChunkAnalysis.getStartTime()) * 100 / musicXmlNote.getDuration() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(),
 					musicXmlNote.getDuration()) * 2) {
+				noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
 				LOGGER.debug("节奏错误原因:进入时间点[{}]太晚", firstBeatTime);
 				return 0;
 			}
+			noteAnalysis.setMusicalErrorType(NoteErrorType.RIGHT);
 			LOGGER.debug("找到节奏点StartTime:{}", firstBeatTime);
 		} else {
+			noteAnalysis.setMusicalErrorType(NoteErrorType.NOT_PLAY);
 			LOGGER.debug("没有找到节奏点");
 			return 0;
 		}
@@ -783,6 +788,7 @@ public class UserChannelContext {
 	private int computeTempoWithAmplitude(MusicXmlNote musicXmlNote, NoteAnalysis noteAnalysis, List<ChunkAnalysis> chunkAnalysisList) {
 
 		if (chunkAnalysisList == null || chunkAnalysisList.size() == 0 || musicXmlNote.getDontEvaluating()) {
+			noteAnalysis.setMusicalErrorType(NoteErrorType.NOT_PLAY);
 			return 0;
 		}