|
@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import be.tarsos.dsp.pitch.FastYin;
|
|
|
|
|
|
import com.yonge.audio.analysis.Signals;
|
|
|
-import com.yonge.audio.analysis.detector.YINPitchDetector;
|
|
|
import com.yonge.netty.dto.NoteAnalysis.NoteErrorType;
|
|
|
import com.yonge.netty.entity.MusicXmlBasicInfo;
|
|
|
import com.yonge.netty.entity.MusicXmlNote;
|
|
@@ -38,17 +37,13 @@ public class UserChannelContext {
|
|
|
//打击乐
|
|
|
private final static List<Integer> percussionList = Arrays.asList(23, 113);
|
|
|
|
|
|
- private final static int MIN_FREQUECY = 100;
|
|
|
-
|
|
|
- private final static int MAX_FREQUECY = 2000;
|
|
|
-
|
|
|
private FastYin detector;
|
|
|
|
|
|
private String user;
|
|
|
|
|
|
private double standardFrequecy = 440;
|
|
|
|
|
|
- private float offsetMS;
|
|
|
+ private float deviceDelayTimeMS;
|
|
|
|
|
|
private double dynamicOffset;
|
|
|
|
|
@@ -60,7 +55,7 @@ public class UserChannelContext {
|
|
|
|
|
|
private float beatDuration;
|
|
|
|
|
|
- private boolean delayProcessed;
|
|
|
+ private boolean startProcessed;
|
|
|
|
|
|
// 曲目与musicxml对应关系
|
|
|
private ConcurrentHashMap<Long, MusicXmlBasicInfo> songMusicXmlMap = new ConcurrentHashMap<Long, MusicXmlBasicInfo>();
|
|
@@ -92,14 +87,12 @@ public class UserChannelContext {
|
|
|
if (Math.round(xmlNote.getFrequency()) == Math.round(playFrequency)) {
|
|
|
result.setStatus(0);
|
|
|
result.setDeviationRate(0);
|
|
|
- result.setDeviationValue(0);
|
|
|
+ result.setDeviationCentValue(0);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- int status;
|
|
|
- double deviationRate = 0;
|
|
|
- double deviationValue = 0;
|
|
|
+ int status = 0;
|
|
|
|
|
|
NoteFrequencyRange noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, xmlNote.getFrequency());
|
|
|
|
|
@@ -107,34 +100,41 @@ public class UserChannelContext {
|
|
|
status = 1;//偏低
|
|
|
} else if( playFrequency > noteFrequencyRange.getMaxFrequency()){
|
|
|
status = 2;//偏高
|
|
|
- } else {
|
|
|
-
|
|
|
- status = 0;
|
|
|
-
|
|
|
- if (Math.round(playFrequency) < Math.round(xmlNote.getFrequency())) {
|
|
|
- double min = Math.abs(xmlNote.getFrequency() - noteFrequencyRange.getMinFrequency()) / 2;
|
|
|
- deviationRate = Math.abs(playFrequency - xmlNote.getFrequency()) / min;
|
|
|
- //deviationValue =
|
|
|
- } else {
|
|
|
- double max = Math.abs(xmlNote.getFrequency() - noteFrequencyRange.getMaxFrequency()) / 2;
|
|
|
- deviationRate = Math.abs(playFrequency - xmlNote.getFrequency()) / max;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
result.setStatus(status);
|
|
|
- result.setDeviationRate(deviationRate);
|
|
|
+ result.setDeviationCentValue(getCents(playFrequency, xmlNote.getFrequency()));
|
|
|
+ result.setDeviationHertzValue(playFrequency - xmlNote.getFrequency());
|
|
|
+ result.setDeviationRate(result.getDeviationCentValue()/(17*100));
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public void init(String platform, String heardLevel, int subjectId, float beatDuration,float sampleRate, int bufferSize) {
|
|
|
- this.platform = platform;
|
|
|
- this.subjectId = subjectId;
|
|
|
- this.beatDuration = beatDuration;
|
|
|
- hardLevel = HardLevelEnum.valueOf(heardLevel);
|
|
|
+ /**
|
|
|
+ * 获取2个频率之间的音分差值
|
|
|
+ * @param srcFrequency
|
|
|
+ * @param targetFrequency
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private double getCents(double srcFrequency, double targetFrequency) {
|
|
|
+ if (targetFrequency < 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if(srcFrequency < 0){
|
|
|
+ return 17 * 10;
|
|
|
+ }
|
|
|
+ return Math.log(srcFrequency / targetFrequency) / Math.log(2) * 1200;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void init(MusicXmlBasicInfo musicXmlBasicInfo,float sampleRate, int bufferSize) {
|
|
|
+ this.platform = musicXmlBasicInfo.getPlatform();
|
|
|
+ this.subjectId = musicXmlBasicInfo.getSubjectId();
|
|
|
+ this.beatDuration = musicXmlBasicInfo.getBeatLength() + musicXmlBasicInfo.getReactionTimeMs();
|
|
|
+ hardLevel = HardLevelEnum.valueOf(musicXmlBasicInfo.getHeardLevel());
|
|
|
if(detector == null){
|
|
|
detector = new FastYin(sampleRate, bufferSize);
|
|
|
}
|
|
|
+ this.standardFrequecy = musicXmlBasicInfo.getHertz();
|
|
|
}
|
|
|
|
|
|
public void setUser(String user) {
|
|
@@ -157,12 +157,12 @@ public class UserChannelContext {
|
|
|
this.handlerSwitch = handlerSwitch;
|
|
|
}
|
|
|
|
|
|
- public float getOffsetMS() {
|
|
|
- return offsetMS;
|
|
|
+ public float getDeviceDelayTimeMS() {
|
|
|
+ return deviceDelayTimeMS;
|
|
|
}
|
|
|
|
|
|
- public void setOffsetMS(float offsetMS) {
|
|
|
- this.offsetMS = offsetMS;
|
|
|
+ public void setDeviceDelayTimeMS(float deviceDelayTimeMS) {
|
|
|
+ this.deviceDelayTimeMS = deviceDelayTimeMS;
|
|
|
}
|
|
|
|
|
|
public float getBeatDuration() {
|
|
@@ -215,10 +215,11 @@ public class UserChannelContext {
|
|
|
totalChunkAnalysisList = new ArrayList<ChunkAnalysis>();
|
|
|
recordId = null;
|
|
|
playTime = 0;
|
|
|
- delayProcessed = false;
|
|
|
- offsetMS = 0;
|
|
|
+ startProcessed = false;
|
|
|
+ deviceDelayTimeMS = 0;
|
|
|
dynamicOffset = 0;
|
|
|
handlerSwitch = false;
|
|
|
+ standardFrequecy = 440;
|
|
|
}
|
|
|
|
|
|
public MusicXmlBasicInfo getMusicXmlBasicInfo(Integer songId){
|
|
@@ -364,7 +365,7 @@ public class UserChannelContext {
|
|
|
|
|
|
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:{} startProcessed:{} dynamicOffset:{} Frequency:{} splDb:{} amplitude:{} time:{}", user, startProcessed, dynamicOffset, playFrequency, splDb, amplitude, playTime);
|
|
|
|
|
|
ChunkAnalysis chunkAnalysis = new ChunkAnalysis(playTime - durationTime, playTime, playFrequency, splDb, power, amplitude);
|
|
|
|
|
@@ -379,17 +380,17 @@ public class UserChannelContext {
|
|
|
if(percussionList.contains(subjectId)){
|
|
|
flag = chunkAnalysis.getAmplitude() > hardLevel.getAmplitudeThreshold();
|
|
|
}else{
|
|
|
- flag = chunkAnalysis.getFrequency() > MIN_FREQUECY && chunkAnalysis.getFrequency() < MAX_FREQUECY;
|
|
|
+ flag = chunkAnalysis.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch() && chunkAnalysis.getFrequency() < MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMaxPitch();
|
|
|
}
|
|
|
|
|
|
- if(delayProcessed == false && flag){
|
|
|
+ if(startProcessed == false && flag){
|
|
|
|
|
|
- delayProcessed = true;
|
|
|
+ startProcessed = true;
|
|
|
|
|
|
//计算延迟偏移值
|
|
|
//playTime = musicXmlNote.getTimeStamp() + durationTime;
|
|
|
dynamicOffset = chunkAnalysis.getStartTime() - musicXmlNote.getTimeStamp();
|
|
|
- if(100 * dynamicOffset / musicXmlNote.getDuration() > (100 - hardLevel.getTempoEffectiveRange(musicXmlNote.getDenominator()))){
|
|
|
+ if(100 * dynamicOffset / musicXmlNote.getDuration() > hardLevel.getIntegrityRange()){
|
|
|
dynamicOffset = 0;
|
|
|
}
|
|
|
}
|
|
@@ -570,7 +571,7 @@ public class UserChannelContext {
|
|
|
|
|
|
if (noteAnalysis.getFrequency() == -1) {// 休止符
|
|
|
|
|
|
- playDurationTime = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= MIN_FREQUECY).mapToDouble(t -> t.getDurationTime()).sum();
|
|
|
+ playDurationTime = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch()).mapToDouble(t -> t.getDurationTime()).sum();
|
|
|
|
|
|
if (noteAnalysis.getTempo() != 0) {
|
|
|
noteAnalysis.setMusicalErrorType(setMusicalErrorTempo(noteAnalysis.getTempo()));
|
|
@@ -582,7 +583,7 @@ public class UserChannelContext {
|
|
|
noteAnalysis.setMusicalErrorType(NoteErrorType.RIGHT);
|
|
|
}
|
|
|
} else {
|
|
|
- playDurationTime = chunkAnalysisList.stream().filter(t -> t.getFrequency() > MIN_FREQUECY && t.getFrequency() < MAX_FREQUECY)
|
|
|
+ playDurationTime = chunkAnalysisList.stream().filter(t -> t.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch() && t.getFrequency() < MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMaxPitch())
|
|
|
.mapToDouble(t -> t.getDurationTime()).sum();
|
|
|
|
|
|
if (playDurationTime * 100 / durationTime < hardLevel.getNotPlayRange()) {
|
|
@@ -605,8 +606,8 @@ 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(20)).divide(new BigDecimal(17), BigDecimal.ROUND_UP)
|
|
|
+ double cents = getCents(noteAnalysis.getPlayFrequency(), noteAnalysis.getFrequency());
|
|
|
+ int intonationScore = 100 - new BigDecimal(Math.abs(cents)).multiply(new BigDecimal(10)).divide(new BigDecimal(17), BigDecimal.ROUND_UP)
|
|
|
.setScale(0, BigDecimal.ROUND_UP).intValue();
|
|
|
if (intonationScore < 0) {
|
|
|
intonationScore = 0;
|
|
@@ -669,7 +670,7 @@ public class UserChannelContext {
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
|
|
|
|
- LOGGER.debug("------------TimeStamp:{} Duration:{} floatingRange:{} StartTime:{} EndTime:{}------------", musicXmlNote.getTimeStamp(), musicXmlNote.getDuration(), floatingRange, startTime, endTime);
|
|
|
+ LOGGER.debug("------Pitch------standard start time:{} floatingRange:{} modified [ {} - {} ]------------", musicXmlNote.getTimeStamp(), floatingRange, startTime, endTime);
|
|
|
|
|
|
List<ChunkAnalysis> chunkAnalysisList = totalChunkAnalysisList.stream().filter(t -> Double.doubleToLongBits(t.getStartTime()) >= Double.doubleToLongBits(startTime) && Double.doubleToLongBits(t.getEndTime()) <= Double.doubleToLongBits(endTime)).collect(Collectors.toList());
|
|
|
|
|
@@ -678,8 +679,6 @@ 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());
|
|
|
|
|
|
- LOGGER.debug("------------ correctedStartTime:{} correctedEndTime:{}------------", correctedStartTime, correctedEndTime);
|
|
|
-
|
|
|
//根据完整度取部分有效信号
|
|
|
int elementSize = chunkAnalysisList.size() * hardLevel.getIntegrityRange() / 100;
|
|
|
chunkAnalysisList = chunkAnalysisList.subList(0, elementSize);
|
|
@@ -689,12 +688,12 @@ public class UserChannelContext {
|
|
|
|
|
|
ChunkAnalysis firstChunkAnalysis = chunkAnalysisList.get(0);
|
|
|
|
|
|
- LOGGER.debug("-------startTime:{} endTime:{}------", firstChunkAnalysis.getStartTime(), chunkAnalysisList.get(chunkAnalysisList.size() - 1)
|
|
|
+ LOGGER.debug("------Pitch------startTime:{} endTime:{}------", firstChunkAnalysis.getStartTime(), chunkAnalysisList.get(chunkAnalysisList.size() - 1)
|
|
|
.getEndTime());
|
|
|
|
|
|
List<ChunkAnalysis> chunkList = new ArrayList<ChunkAnalysis>(chunkAnalysisList);
|
|
|
|
|
|
- List<Integer> chunkFrequencyList = chunkList.stream().map(t -> t.getFrequency()).filter(t -> t.doubleValue() > MIN_FREQUECY && t.doubleValue() < MAX_FREQUECY)
|
|
|
+ List<Integer> chunkFrequencyList = chunkList.stream().map(t -> t.getFrequency()).filter(t -> t.doubleValue() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch() && t.doubleValue() < MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMaxPitch())
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
if (chunkFrequencyList.size() == 0) {
|
|
@@ -726,10 +725,11 @@ 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() * hardLevel.getIntegrityRange() / 100;
|
|
|
|
|
|
- int startIndex = (chunkAnalysisList.size() - elementSize) / 2 - 1;
|
|
|
+ //int startIndex = (chunkAnalysisList.size() - elementSize) / 2 - 1;
|
|
|
+ int startIndex = 0;
|
|
|
startIndex = startIndex < 1 ? 0 : startIndex;
|
|
|
List<ChunkAnalysis> chunkList = chunkAnalysisList.subList(startIndex, elementSize + startIndex);
|
|
|
|
|
@@ -738,7 +738,7 @@ public class UserChannelContext {
|
|
|
}
|
|
|
|
|
|
if (musicXmlNote.getFrequency() == -1) {// 休止符
|
|
|
- return chunkList.stream().filter(t -> t.getFrequency() > MIN_FREQUECY).count() <= 1? 0:1;
|
|
|
+ return chunkList.stream().filter(t -> t.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch()).count() <= 1? 0:1;
|
|
|
}
|
|
|
|
|
|
ChunkAnalysis firstChunkAnalysis = chunkAnalysisList.get(0);
|
|
@@ -746,7 +746,7 @@ public class UserChannelContext {
|
|
|
List<ChunkAnalysis> ignoreHeaderList = chunkAnalysisList.subList(0, startIndex);
|
|
|
if(ignoreHeaderList != null && ignoreHeaderList.size() > 0){
|
|
|
for(ChunkAnalysis ca : ignoreHeaderList){
|
|
|
- if(ca.getFrequency() < MIN_FREQUECY){
|
|
|
+ if(ca.getFrequency() < MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch()){
|
|
|
firstChunkAnalysis.setFrequency(-1);
|
|
|
break;
|
|
|
}
|
|
@@ -785,7 +785,7 @@ public class UserChannelContext {
|
|
|
for (int i = 0; i < chunkList.size(); i++) {
|
|
|
chunkAnalysis = chunkList.get(i);
|
|
|
if (chunkAnalysis != null) {
|
|
|
- if (chunkAnalysis.getFrequency() > MIN_FREQUECY || firstPeakIndex > -1) {
|
|
|
+ if (chunkAnalysis.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch() || firstPeakIndex > -1) {
|
|
|
|
|
|
if (firstPeakIndex == -1) {
|
|
|
firstPeakIndex = i;
|
|
@@ -815,10 +815,10 @@ public class UserChannelContext {
|
|
|
totalTimes = chunkList.size();
|
|
|
}
|
|
|
|
|
|
- if (maxTimes * 100 / totalTimes < hardLevel.getIntegrityRange()) {
|
|
|
+ /*if (maxTimes * 100 / totalTimes < hardLevel.getIntegrityRange()) {
|
|
|
tempo = 1;
|
|
|
LOGGER.debug("节奏错误原因:信号分堆后的最大数量不足指定的完成比例");
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
for (int i = 0; i < chunkList.size(); i++) {
|
|
@@ -867,7 +867,7 @@ public class UserChannelContext {
|
|
|
LOGGER.debug("节奏错误原因:进入时间点太晚");
|
|
|
}else{
|
|
|
//判断是否与上一个音延续下来的
|
|
|
- if(firstChunkAnalysis.getFrequency() > MIN_FREQUECY && lastChunkAnalysis.getFrequency() > MIN_FREQUECY){
|
|
|
+ if(firstChunkAnalysis.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch() && lastChunkAnalysis.getFrequency() > MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch()){
|
|
|
tempo = new NoteFrequencyRange(standardFrequecy, firstChunkAnalysis.getFrequency()).equals(new NoteFrequencyRange(standardFrequecy, lastChunkAnalysis.getFrequency())) == false?0:1;
|
|
|
if(tempo == 1){
|
|
|
LOGGER.debug("节奏错误原因:上一个音[{}]延续下来导致的", lastChunkAnalysis.getFrequency());
|
|
@@ -886,7 +886,7 @@ public class UserChannelContext {
|
|
|
double endTime = musicXmlNote.getTimeStamp() + dynamicOffset + floatingRange;
|
|
|
double startTime = musicXmlNote.getTimeStamp() + dynamicOffset - floatingRange;
|
|
|
|
|
|
- LOGGER.debug("------------TimeStamp:{} floatingRange:{} StartTime:{} EndTime:{}------------", musicXmlNote.getTimeStamp(), floatingRange, startTime, endTime);
|
|
|
+ LOGGER.debug("------Tempo------standard start time:{} floatingRange:{} modified [ {} - {} ]------------", musicXmlNote.getTimeStamp(), floatingRange, startTime, endTime);
|
|
|
|
|
|
List<ChunkAnalysis> chunkAnalysisList = totalChunkAnalysisList.stream().filter(t -> Double.doubleToLongBits(t.getStartTime()) >= Double.doubleToLongBits(startTime) && Double.doubleToLongBits(t.getEndTime()) <= Double.doubleToLongBits(endTime)).collect(Collectors.toList());
|
|
|
|
|
@@ -905,12 +905,12 @@ public class UserChannelContext {
|
|
|
|
|
|
ChunkAnalysis firstChunkAnalysis = chunkAnalysisList.get(0);
|
|
|
|
|
|
- LOGGER.debug("-------startTime:{} endTime:{}------", firstChunkAnalysis.getStartTime(), chunkList.get(chunkList.size() - 1)
|
|
|
+ LOGGER.debug("------Tempo------startTime:{} endTime:{}------", firstChunkAnalysis.getStartTime(), chunkList.get(chunkList.size() - 1)
|
|
|
.getEndTime());
|
|
|
|
|
|
if (musicXmlNote.getFrequency() == -1) {// 休止符
|
|
|
|
|
|
- LOGGER.debug("--Amplitude:{} Denominator:{}",chunkList.stream().map(t -> t).collect(Collectors.toList()), musicXmlNote.getDenominator());
|
|
|
+ LOGGER.debug("--pause note Amplitude:{} Denominator:{}",chunkList.stream().map(t -> t).collect(Collectors.toList()), musicXmlNote.getDenominator());
|
|
|
return chunkList.stream().filter(t -> t.getAmplitude() > hardLevel.getAmplitudeThreshold()).count() <= 0 ? 0:1;
|
|
|
}
|
|
|
|
|
@@ -979,17 +979,17 @@ public class UserChannelContext {
|
|
|
private double queryFirstNoteStartTime(List<ChunkAnalysis> chunkAnalysisList, MusicXmlNote musicXmlNote) {
|
|
|
|
|
|
if(chunkAnalysisList == null || chunkAnalysisList.size() == 0){
|
|
|
- LOGGER.debug("找不到数据,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
+ LOGGER.debug("[查询第一个音]找不到数据,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
}
|
|
|
|
|
|
if (percussionList.contains(subjectId)) {
|
|
|
Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getAmplitude() > hardLevel.getAmplitudeThreshold()).findFirst();
|
|
|
if(optional.isPresent()){
|
|
|
- LOGGER.debug("范围内查询到信号,correctedStartTime:{}", optional.get().getStartTime());
|
|
|
+ LOGGER.debug("[查询第一个音]范围内查询到信号,correctedStartTime:{}", optional.get().getStartTime());
|
|
|
return optional.get().getStartTime();
|
|
|
}else{
|
|
|
- LOGGER.debug("范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
+ LOGGER.debug("[查询第一个音]范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
}
|
|
|
}
|
|
@@ -998,12 +998,12 @@ public class UserChannelContext {
|
|
|
if(musicXmlNote.getMusicalNotesIndex() > 0){
|
|
|
MusicXmlNote preMusicXmlNote = getCurrentMusicNote(null, musicXmlNote.getMusicalNotesIndex() - 1);
|
|
|
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() <= MusicalInstrumentsPitchRange.get(subjectId, standardFrequecy).getMinPitch()).findFirst();
|
|
|
if(optional.isPresent()){
|
|
|
- LOGGER.debug("与上一个音同音,有断开,correctedStartTime:{}", optional.get().getStartTime());
|
|
|
+ LOGGER.debug("[查询第一个音]与上一个音同音,有断开,correctedStartTime:{}", optional.get().getEndTime());
|
|
|
return optional.get().getEndTime();
|
|
|
}else{
|
|
|
- LOGGER.debug("与上一个音同音,未断开,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
+ LOGGER.debug("[查询第一个音]与上一个音同音,未断开,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
|
}
|
|
|
}
|
|
@@ -1016,12 +1016,12 @@ public class UserChannelContext {
|
|
|
for (ChunkAnalysis ca : chunkAnalysisList) {
|
|
|
noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, ca.getFrequency());
|
|
|
if (standardNote.equals(noteFrequencyRange)) {
|
|
|
- LOGGER.debug("范围内查询到信号,correctedStartTime:{}", ca.getStartTime());
|
|
|
+ LOGGER.debug("[查询第一个音]范围内查询到信号,correctedStartTime:{}", ca.getStartTime());
|
|
|
return ca.getStartTime();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- LOGGER.debug("范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
+ LOGGER.debug("[查询第一个音]范围内未查询到信号,correctedStartTime:{}", musicXmlNote.getTimeStamp() + dynamicOffset);
|
|
|
|
|
|
//return chunkAnalysisList.get(chunkAnalysisList.size() - 1).getEndTime();
|
|
|
return musicXmlNote.getTimeStamp() + dynamicOffset;
|
|
@@ -1036,7 +1036,8 @@ public class UserChannelContext {
|
|
|
midi[x] = new BigDecimal(standardPitch).multiply(new BigDecimal(Math.pow(2, new BigDecimal(x-69).divide(new BigDecimal(12),6,BigDecimal.ROUND_HALF_UP).doubleValue()))).doubleValue();
|
|
|
System.out.println("x=" + x +" "+ midi[x]);
|
|
|
}
|
|
|
-
|
|
|
+ UserChannelContext test= new UserChannelContext();
|
|
|
+ System.out.println(test.getCents(440, 442));
|
|
|
}
|
|
|
|
|
|
}
|