|
@@ -2,6 +2,7 @@ package com.yonge.netty.dto;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -36,7 +37,7 @@ public class UserChannelContext {
|
|
|
private final static Logger LOGGER = LoggerFactory.getLogger(UserChannelContext.class);
|
|
|
|
|
|
//打击乐
|
|
|
- //private final static List<Integer> percussionList = Arrays.asList(23, 113, 121);
|
|
|
+ private final static List<Integer> percussionList = Arrays.asList(23, 113, 121);
|
|
|
|
|
|
private final static int MIN_FREQUECY = 43;
|
|
|
|
|
@@ -330,14 +331,14 @@ public class UserChannelContext {
|
|
|
//int playFrequency = (int) frequencyDetector.getFrequency(samples);
|
|
|
|
|
|
int playFrequency = -1;
|
|
|
- if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())){
|
|
|
+ if(!percussionList.contains(subjectId) || StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())){
|
|
|
playFrequency = (int)detector.getPitch(samples).getPitch();
|
|
|
}
|
|
|
|
|
|
int splDb = (int) Signals.soundPressureLevel(samples);
|
|
|
int power = (int) Signals.power(samples);
|
|
|
int amplitude = 0;
|
|
|
- if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.AMPLITUDE.getCode())) {
|
|
|
+ if(percussionList.contains(subjectId) || StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.AMPLITUDE.getCode())) {
|
|
|
amplitude = (int) Signals.norm(samples);
|
|
|
}else if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.DECIBELS.getCode())){
|
|
|
amplitude = (int) Signals.decibels(samples) >= 38 ? 10 : 1;
|
|
@@ -377,7 +378,7 @@ public class UserChannelContext {
|
|
|
totalChunkAnalysisList.add(chunkAnalysis);
|
|
|
|
|
|
boolean flag = false; //是否收到有效信号
|
|
|
- if(!StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())){
|
|
|
+ if(percussionList.contains(subjectId) || !StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())){
|
|
|
flag = chunkAnalysis.getAmplitude() > hardLevel.getAmplitudeThreshold();
|
|
|
}else{
|
|
|
flag = chunkAnalysis.getFrequency() > MIN_FREQUECY && chunkAnalysis.getFrequency() < MAX_FREQUECY;
|
|
@@ -403,7 +404,7 @@ public class UserChannelContext {
|
|
|
|
|
|
//判断节奏(音符持续时间内有不间断的音高,就节奏正确)
|
|
|
boolean tempo = true;
|
|
|
- if (!StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
+ if (percussionList.contains(subjectId) || !StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
noteAnalysis.setPlayFrequency(-1);
|
|
|
tempo = computeTempoWithAmplitude2(musicXmlNote);
|
|
|
}else{
|
|
@@ -547,7 +548,7 @@ public class UserChannelContext {
|
|
|
|
|
|
double playDurationTime = 0;
|
|
|
|
|
|
- if (!StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
+ if (percussionList.contains(subjectId) || !StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
if (noteAnalysis.getFrequency() == -1) {// 休止符
|
|
|
if (!noteAnalysis.isTempo()) {
|
|
|
noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
|
|
@@ -630,7 +631,7 @@ public class UserChannelContext {
|
|
|
noteAnalysis.setIntegrityScore(integrityScore);
|
|
|
}
|
|
|
noteAnalysis.setIntonationScore(intonationScore);
|
|
|
- if (!StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
+ if (percussionList.contains(subjectId) || !StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
noteAnalysis.setScore(tempoScore);
|
|
|
} else {
|
|
|
noteAnalysis.setScore(new BigDecimal(intonationScore + tempoScore + integrityScore).divide(new BigDecimal(3), 2).setScale(0, BigDecimal.ROUND_UP)
|
|
@@ -958,7 +959,7 @@ public class UserChannelContext {
|
|
|
return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
}
|
|
|
|
|
|
- if (!StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
+ if (percussionList.contains(subjectId) || !StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.FREQUENCY.getCode())) {
|
|
|
Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getAmplitude() > hardLevel.getAmplitudeThreshold()).findFirst();
|
|
|
if(optional.isPresent()){
|
|
|
LOGGER.debug("范围内查询到信号,correctedStartTime:{}", optional.get().getStartTime());
|