|
@@ -391,7 +391,7 @@ public class UserChannelContext {
|
|
|
//计算延迟偏移值
|
|
|
//playTime = musicXmlNote.getTimeStamp() + durationTime;
|
|
|
dynamicOffset = chunkAnalysis.getStartTime() - musicXmlNote.getTimeStamp();
|
|
|
- if(100 * dynamicOffset / musicXmlNote.getDuration() > (100 - hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()))){
|
|
|
+ if(100 * dynamicOffset / musicXmlNote.getDuration() > (100 - hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()))){
|
|
|
dynamicOffset = 0;
|
|
|
}
|
|
|
}
|
|
@@ -532,7 +532,7 @@ public class UserChannelContext {
|
|
|
|
|
|
public void evaluateForNote(MusicXmlNote musicXmlNote, NoteAnalysis noteAnalysis) {
|
|
|
|
|
|
- double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()) / 100;
|
|
|
+ double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()) / 100;
|
|
|
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
@@ -641,7 +641,7 @@ public class UserChannelContext {
|
|
|
|
|
|
private int computeFrequency(MusicXmlNote musicXmlNote) {
|
|
|
|
|
|
- double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()) / 100;
|
|
|
+ double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()) / 100;
|
|
|
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
@@ -691,7 +691,7 @@ public class UserChannelContext {
|
|
|
*/
|
|
|
private boolean computeTempoWithFrequency(MusicXmlNote musicXmlNote){
|
|
|
|
|
|
- double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()) / 100;
|
|
|
+ double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()) / 100;
|
|
|
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
@@ -838,7 +838,7 @@ public class UserChannelContext {
|
|
|
|
|
|
if (tempo) {
|
|
|
// 判断进入时间点
|
|
|
- if(firstPeakIndex * 100 /chunkList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator())){
|
|
|
+ if(firstPeakIndex * 100 /chunkList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration())){
|
|
|
tempo = false;
|
|
|
LOGGER.debug("节奏错误原因:进入时间点太晚");
|
|
|
}else{
|
|
@@ -857,7 +857,7 @@ public class UserChannelContext {
|
|
|
|
|
|
private boolean computeTempoWithAmplitude2(MusicXmlNote musicXmlNote) {
|
|
|
|
|
|
- double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()) / 100;
|
|
|
+ double floatingRange = musicXmlNote.getDuration() * hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()) / 100;
|
|
|
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
@@ -872,7 +872,7 @@ public class UserChannelContext {
|
|
|
chunkAnalysisList = totalChunkAnalysisList.stream().filter(t -> Double.doubleToLongBits(t.getStartTime()) >= Double.doubleToLongBits(correctedStartTime) && Double.doubleToLongBits(t.getEndTime()) <= Double.doubleToLongBits(correctedEndTime)).collect(Collectors.toList());
|
|
|
|
|
|
//根据完整度取部分有效信号
|
|
|
- int elementSize = chunkAnalysisList.size() * (100 - hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator())) / 100;
|
|
|
+ int elementSize = chunkAnalysisList.size() * (100 - hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration())) / 100;
|
|
|
List<ChunkAnalysis> chunkList = chunkAnalysisList.subList(0, elementSize);
|
|
|
|
|
|
if(chunkList == null || chunkList.size() == 0){
|
|
@@ -908,11 +908,31 @@ public class UserChannelContext {
|
|
|
|
|
|
// 检测是否有多个波峰
|
|
|
boolean tempo = false;
|
|
|
- boolean isContinue = true;
|
|
|
+ boolean isContinue = false;
|
|
|
int firstPeakIndex = -1;
|
|
|
+ int firstPeakValue = 0;
|
|
|
int peakSize = 0;
|
|
|
-
|
|
|
+
|
|
|
for (int i = 1; i < chunkAmplitudeList.size(); i++) {
|
|
|
+ if (chunkAmplitudeList.get(i - 1) + hardLevel.getAmplitudeThreshold() >= chunkAmplitudeList.get(i)) {
|
|
|
+ isContinue = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isContinue == false && chunkAmplitudeList.get(i - 1) + hardLevel.getAmplitudeThreshold() < chunkAmplitudeList.get(i)){
|
|
|
+ isContinue = true;
|
|
|
+ peakSize++;
|
|
|
+
|
|
|
+ if(firstPeakIndex == -1){
|
|
|
+ firstPeakIndex = i;
|
|
|
+ firstPeakValue = chunkAmplitudeList.get(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LOGGER.debug("PeakSize:" + peakSize + " FirstPeakIndex:" + firstPeakIndex + " FirstPeakValue:" + firstPeakValue);
|
|
|
+
|
|
|
+ /*for (int i = 1; i < chunkAmplitudeList.size(); i++) {
|
|
|
if (Math.abs(chunkAmplitudeList.get(i) - chunkAmplitudeList.get(i - 1)) < hardLevel.getAmplitudeThreshold()) {
|
|
|
continue;
|
|
|
}
|
|
@@ -932,7 +952,7 @@ public class UserChannelContext {
|
|
|
isContinue = false;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
if(peakSize == 0){
|
|
|
tempo = lastChunkAnalysis.isPeak();
|
|
@@ -945,7 +965,7 @@ public class UserChannelContext {
|
|
|
|
|
|
if (tempo) {
|
|
|
// 判断进入时间点
|
|
|
- if((firstPeakIndex - 1) * 100 /chunkAmplitudeList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()) * 2){
|
|
|
+ if((firstPeakIndex - 1) * 100 /chunkAmplitudeList.size() > hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator(), musicXmlNote.getDuration()) * 2){
|
|
|
LOGGER.debug("超过范围:{}", (firstPeakIndex - 1) * 100 /chunkAmplitudeList.size());
|
|
|
tempo = false;
|
|
|
}
|
|
@@ -1018,3 +1038,4 @@ public class UserChannelContext {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|