|
@@ -71,7 +71,7 @@ public class UserChannelContext {
|
|
|
this.subjectId = subjectId;
|
|
|
this.beatDuration = beatDuration;
|
|
|
this.beatByteLength = WaveformWriter.SAMPLE_RATE * WaveformWriter.BITS_PER_SAMPLE / 8 * beatDuration / 1000;
|
|
|
- //hardLevel = HardLevelEnum.valueOf(heardLevel);
|
|
|
+ hardLevel = HardLevelEnum.valueOf(heardLevel);
|
|
|
}
|
|
|
|
|
|
public byte[] skipHeader(byte[] datas) {
|
|
@@ -314,16 +314,16 @@ public class UserChannelContext {
|
|
|
|
|
|
//判断节奏(音符持续时间内有不间断的音高,就节奏正确)
|
|
|
boolean tempo = true;
|
|
|
- if (musicXmlNote.getFrequency() == -1) {// 休止符
|
|
|
- if (subjectId == 23) {
|
|
|
+ if (subjectId == 23) {
|
|
|
+ if (musicXmlNote.getFrequency() == -1) {// 休止符
|
|
|
tempo = chunkAnalysisList.stream().filter(t -> t.getAmplitude() > hardLevel.getAmplitudeThreshold()).count() <= 0;
|
|
|
}else{
|
|
|
- tempo = chunkAnalysisList.stream().filter(t -> t.getFrequency() > 100).count() <= 1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (subjectId == 23) {
|
|
|
tempo = computeTempoWithAmplitude2(chunkAnalysisList, lastChunkAnalysis);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (musicXmlNote.getFrequency() == -1) {// 休止符
|
|
|
+ tempo = chunkAnalysisList.stream().filter(t -> t.getFrequency() > 100).count() <= 1;
|
|
|
+ }else{
|
|
|
tempo = computeTempoWithFrequency(chunkAnalysisList, lastChunkAnalysis);
|
|
|
}
|
|
|
}
|
|
@@ -461,10 +461,22 @@ public class UserChannelContext {
|
|
|
double playDurationTime = 0;
|
|
|
|
|
|
if (subjectId == 23) {
|
|
|
- if (!noteAnalysis.isTempo()) {
|
|
|
- noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
|
|
|
- } else {
|
|
|
- noteAnalysis.setMusicalErrorType(NoteErrorType.RIGHT);
|
|
|
+ if (noteAnalysis.getFrequency() == -1) {// 休止符
|
|
|
+ if (!noteAnalysis.isTempo()) {
|
|
|
+ noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
|
|
|
+ } else {
|
|
|
+ noteAnalysis.setMusicalErrorType(NoteErrorType.RIGHT);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ int beatTimes = (int) chunkAnalysisList.stream().filter(t -> t.getAmplitude() > hardLevel.getAmplitudeThreshold()).count();
|
|
|
+
|
|
|
+ if(beatTimes == 0){
|
|
|
+ noteAnalysis.setMusicalErrorType(NoteErrorType.NOT_PLAY);
|
|
|
+ }else if (!noteAnalysis.isTempo()) {
|
|
|
+ noteAnalysis.setMusicalErrorType(NoteErrorType.CADENCE_WRONG);
|
|
|
+ } else {
|
|
|
+ noteAnalysis.setMusicalErrorType(NoteErrorType.RIGHT);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
if (noteAnalysis.getFrequency() == -1) {// 休止符
|
|
@@ -502,7 +514,7 @@ public class UserChannelContext {
|
|
|
int tempoScore = 0;
|
|
|
int integrityScore = 0;
|
|
|
int intonationScore = 100 - new BigDecimal(Math.abs(YINPitchDetector.hertzToAbsoluteCent(noteAnalysis.getPlayFrequency())
|
|
|
- - YINPitchDetector.hertzToAbsoluteCent(noteAnalysis.getFrequency()))).multiply(new BigDecimal(10)).divide(new BigDecimal(17), 2)
|
|
|
+ - YINPitchDetector.hertzToAbsoluteCent(noteAnalysis.getFrequency()))).multiply(new BigDecimal(10)).divide(new BigDecimal(17), BigDecimal.ROUND_UP)
|
|
|
.setScale(0, BigDecimal.ROUND_UP).intValue();
|
|
|
if (intonationScore < 0) {
|
|
|
intonationScore = 0;
|