|
@@ -346,8 +346,10 @@ public class UserChannelContext {
|
|
}
|
|
}
|
|
|
|
|
|
int splDb = (int) Signals.soundPressureLevel(samples);
|
|
int splDb = (int) Signals.soundPressureLevel(samples);
|
|
- int power = (int) Signals.power(samples);
|
|
|
|
- int amplitude = 0;
|
|
|
|
|
|
+ float power = Signals.power(samples);
|
|
|
|
+ int amplitude = (int) Signals.norm(samples);
|
|
|
|
+
|
|
|
|
+ int decibels = (int) Signals.decibels(samples);
|
|
if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.AMPLITUDE.getCode())) {
|
|
if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.AMPLITUDE.getCode())) {
|
|
amplitude = (int) Signals.norm(samples);
|
|
amplitude = (int) Signals.norm(samples);
|
|
}else if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.DECIBELS.getCode())){
|
|
}else if(StringUtils.equalsIgnoreCase(evaluationCriteria, EvaluationCriteriaEnum.DECIBELS.getCode())){
|
|
@@ -377,7 +379,7 @@ public class UserChannelContext {
|
|
|
|
|
|
if (noteAnalysis.getMusicalNotesIndex() >= 0 && noteAnalysis.getMusicalNotesIndex() <= getTotalMusicNoteIndex(null)) {
|
|
if (noteAnalysis.getMusicalNotesIndex() >= 0 && noteAnalysis.getMusicalNotesIndex() <= getTotalMusicNoteIndex(null)) {
|
|
|
|
|
|
- LOGGER.debug("user:{} delayProcessed:{} dynamicOffset:{} Frequency:{} splDb:{} amplitude:{} time:{}", user, delayProcessed, dynamicOffset, playFrequency, splDb, amplitude, playTime);
|
|
|
|
|
|
+ LOGGER.debug("user:{} delayProcessed:{} dynamicOffset:{} Frequency:{} splDb:{} power:{} amplitude:{} decibels:{} time:{}", user, delayProcessed, dynamicOffset, playFrequency, splDb, power, amplitude, decibels, playTime);
|
|
|
|
|
|
ChunkAnalysis chunkAnalysis = new ChunkAnalysis(playTime - durationTime, playTime, playFrequency, splDb, power, amplitude);
|
|
ChunkAnalysis chunkAnalysis = new ChunkAnalysis(playTime - durationTime, playTime, playFrequency, splDb, power, amplitude);
|
|
|
|
|
|
@@ -792,66 +794,56 @@ public class UserChannelContext {
|
|
totalTimes = chunkList.size();
|
|
totalTimes = chunkList.size();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
if (maxTimes * 100 / totalTimes < hardLevel.getIntegrityRange()) {
|
|
if (maxTimes * 100 / totalTimes < hardLevel.getIntegrityRange()) {
|
|
- tempo = false;
|
|
|
|
LOGGER.debug("节奏错误原因:信号分堆后的最大数量不足指定的完成比例");
|
|
LOGGER.debug("节奏错误原因:信号分堆后的最大数量不足指定的完成比例");
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- for (int i = 0; i < chunkList.size(); i++) {
|
|
|
|
- chunkAnalysis = chunkList.get(i);
|
|
|
|
- if (chunkAnalysis != null) {
|
|
|
|
- if (chunkAnalysis.getFrequency() > MIN_FREQUECY) {
|
|
|
|
-
|
|
|
|
- tempo = true;
|
|
|
|
- if (firstPeakIndex == -1) {
|
|
|
|
- firstPeakIndex = i;
|
|
|
|
- noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, chunkAnalysis.getFrequency());
|
|
|
|
- } else if (noteFrequencyRange.getMinFrequency() > chunkAnalysis.getFrequency()
|
|
|
|
- || chunkAnalysis.getFrequency() > noteFrequencyRange.getMaxFrequency()) {// 判断是否是同一个音
|
|
|
|
- //是否是低八度或高八度
|
|
|
|
- if(!((noteFrequencyRange.getMinFrequency() < chunkAnalysis.getFrequency() * 2 && chunkAnalysis.getFrequency() * 2 < noteFrequencyRange.getMaxFrequency())
|
|
|
|
- || (noteFrequencyRange.getMinFrequency() < chunkAnalysis.getFrequency() / 2 && chunkAnalysis.getFrequency() / 2 < noteFrequencyRange.getMaxFrequency()))){
|
|
|
|
- tempo = false;
|
|
|
|
- LOGGER.debug("节奏错误原因:不是同一个音[{}]:{}-{}", chunkAnalysis.getFrequency(), noteFrequencyRange.getMinFrequency(), noteFrequencyRange.getMaxFrequency());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (isContinue == false) {
|
|
|
|
- if ((i + 1) / chunkAnalysisList.size() < hardLevel.getIntegrityRange()) {
|
|
|
|
- if (unplayedSize > 0) {
|
|
|
|
- tempo = false;
|
|
|
|
- LOGGER.debug("节奏错误原因:信号不连续");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (tempo == true) {
|
|
|
|
- isContinue = false;
|
|
|
|
- unplayedSize++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
|
|
|
|
- if (tempo) {
|
|
|
|
- // 判断进入时间点
|
|
|
|
- if(firstPeakIndex * 100 /chunkList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration())){
|
|
|
|
- tempo = false;
|
|
|
|
- LOGGER.debug("节奏错误原因:进入时间点太晚");
|
|
|
|
- }else{
|
|
|
|
- //判断是否与上一个音延续下来的
|
|
|
|
|
|
+ // 判断进入时间点
|
|
|
|
+ if(firstPeakIndex * 100 /chunkList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration())){
|
|
|
|
+ LOGGER.debug("节奏错误原因:进入时间点太晚");
|
|
|
|
+ return false;
|
|
|
|
+ }else{
|
|
|
|
+ //判断是否与上一个音延续下来的
|
|
|
|
+ if(correctedStartTime == musicXmlNote.getTimeStamp() + dynamicOffset) {
|
|
if(firstChunkAnalysis.getFrequency() > MIN_FREQUECY && lastChunkAnalysis.getFrequency() > MIN_FREQUECY){
|
|
if(firstChunkAnalysis.getFrequency() > MIN_FREQUECY && lastChunkAnalysis.getFrequency() > MIN_FREQUECY){
|
|
tempo = new NoteFrequencyRange(standardFrequecy, firstChunkAnalysis.getFrequency()).equals(new NoteFrequencyRange(standardFrequecy, lastChunkAnalysis.getFrequency())) == false;
|
|
tempo = new NoteFrequencyRange(standardFrequecy, firstChunkAnalysis.getFrequency()).equals(new NoteFrequencyRange(standardFrequecy, lastChunkAnalysis.getFrequency())) == false;
|
|
if(tempo == false){
|
|
if(tempo == false){
|
|
LOGGER.debug("节奏错误原因:上一个音[{}]延续下来导致的", lastChunkAnalysis.getFrequency());
|
|
LOGGER.debug("节奏错误原因:上一个音[{}]延续下来导致的", lastChunkAnalysis.getFrequency());
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //判断过程中声音是否有起伏
|
|
|
|
+ float minValue = 0;
|
|
|
|
+ int depth = 0;
|
|
|
|
+
|
|
|
|
+ for (int i = 1; i < chunkList.size(); i++) {
|
|
|
|
+
|
|
|
|
+ if(i == 1) {
|
|
|
|
+ minValue = chunkList.get(i - 1).getSplDb();
|
|
|
|
+ }
|
|
|
|
+ if (Math.abs(minValue - chunkList.get(i).getSplDb()) >= 6) {
|
|
|
|
+ LOGGER.debug("范围内查询到音波信号,correctedStartTime:{}", chunkList.get(i).getStartTime());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ minValue = Math.min(minValue , chunkList.get(i).getSplDb());
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ if (depth >= 2 && Math.max(chunkList.get(i - 1).getPower(), chunkList.get(i).getPower()) / Math.min(chunkList.get(i - 1).getPower(), chunkList.get(i).getPower()) >= 2) {
|
|
|
|
+ tempo = false;
|
|
|
|
+ depth++;
|
|
|
|
+ LOGGER.debug("节奏错误原因:声波不稳定[{}]", chunkList.get(i).getEndTime());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+ }
|
|
|
|
+
|
|
return tempo;
|
|
return tempo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -999,17 +991,38 @@ public class UserChannelContext {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ double startTime = 0;
|
|
|
|
+ float minValue = 0;
|
|
|
|
+ for (int i = 1; i < chunkAnalysisList.size(); i++) {
|
|
|
|
+
|
|
|
|
+ if(i == 1) {
|
|
|
|
+ minValue = chunkAnalysisList.get(i - 1).getSplDb();
|
|
|
|
+ }
|
|
|
|
+ if (Math.abs(minValue - chunkAnalysisList.get(i).getSplDb()) >= 6) {
|
|
|
|
+ LOGGER.debug("范围内查询到音波信号,correctedStartTime:{}", chunkAnalysisList.get(i).getStartTime());
|
|
|
|
+ startTime = chunkAnalysisList.get(i).getStartTime();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ minValue = Math.min(minValue , chunkAnalysisList.get(i).getSplDb());
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ if (Math.max(chunkAnalysisList.get(i - 1).getPower(), chunkAnalysisList.get(i).getPower()) / Math.min(chunkAnalysisList.get(i - 1).getPower(), chunkAnalysisList.get(i).getPower()) >= 2) {
|
|
|
|
+ LOGGER.debug("范围内查询到音波信号,correctedStartTime:{}", chunkAnalysisList.get(i).getStartTime());
|
|
|
|
+ startTime = chunkAnalysisList.get(i).getStartTime();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+ }
|
|
|
|
+
|
|
//判断是否与上一个音是同一个音符
|
|
//判断是否与上一个音是同一个音符
|
|
if(musicXmlNote.getMusicalNotesIndex() > 0){
|
|
if(musicXmlNote.getMusicalNotesIndex() > 0){
|
|
MusicXmlNote preMusicXmlNote = getCurrentMusicNote(null, musicXmlNote.getMusicalNotesIndex() - 1);
|
|
MusicXmlNote preMusicXmlNote = getCurrentMusicNote(null, musicXmlNote.getMusicalNotesIndex() - 1);
|
|
if((int)preMusicXmlNote.getFrequency() == (int)musicXmlNote.getFrequency()){
|
|
if((int)preMusicXmlNote.getFrequency() == (int)musicXmlNote.getFrequency()){
|
|
Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= MIN_FREQUECY).findFirst();
|
|
Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= MIN_FREQUECY).findFirst();
|
|
if(optional.isPresent()){
|
|
if(optional.isPresent()){
|
|
- LOGGER.debug("与上一个音同音,有断开,correctedStartTime:{}", optional.get().getStartTime());
|
|
|
|
- return optional.get().getEndTime();
|
|
|
|
- }else{
|
|
|
|
- LOGGER.debug("与上一个音同音,未断开,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
|
- return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
|
|
|
+ LOGGER.debug("与上一个音同音,有断开,correctedStartTime:{}", optional.get().getEndTime());
|
|
|
|
+ return Math.max(optional.get().getEndTime(), startTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1021,15 +1034,17 @@ public class UserChannelContext {
|
|
for (ChunkAnalysis ca : chunkAnalysisList) {
|
|
for (ChunkAnalysis ca : chunkAnalysisList) {
|
|
noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, ca.getFrequency());
|
|
noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, ca.getFrequency());
|
|
if (standardNote.equals(noteFrequencyRange)) {
|
|
if (standardNote.equals(noteFrequencyRange)) {
|
|
- LOGGER.debug("范围内查询到信号,correctedStartTime:{}", ca.getStartTime());
|
|
|
|
- return ca.getStartTime();
|
|
|
|
|
|
+ LOGGER.debug("范围内查询到音高信号,correctedStartTime:{}", ca.getStartTime());
|
|
|
|
+ return Math.max(ca.getStartTime(), startTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.debug("范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
|
|
|
+ if(startTime == 0) {
|
|
|
|
+ LOGGER.debug("范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
|
+ }
|
|
|
|
|
|
//return chunkAnalysisList.get(chunkAnalysisList.size() - 1).getEndTime();
|
|
//return chunkAnalysisList.get(chunkAnalysisList.size() - 1).getEndTime();
|
|
- return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
|
|
|
+ return Math.max(musicXmlNote.getTimeStamp() + dynamicOffset, startTime);
|
|
}
|
|
}
|
|
|
|
|
|
private void reduceNoise(List<ChunkAnalysis> chunkAnalysisList, EvaluationCriteriaEnum criteria) {
|
|
private void reduceNoise(List<ChunkAnalysis> chunkAnalysisList, EvaluationCriteriaEnum criteria) {
|