|
|
@@ -15,7 +15,6 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.sound.sampled.AudioFormat;
|
|
|
|
|
|
-import com.yonge.audio.analysis.AudioFloatConverter;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -28,7 +27,6 @@ import com.yonge.netty.entity.MusicXmlBasicInfo;
|
|
|
import com.yonge.netty.entity.MusicXmlNote;
|
|
|
import com.yonge.netty.entity.MusicXmlSection;
|
|
|
import com.yonge.netty.server.processor.WaveformWriter;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* 用户通道上下文
|
|
|
@@ -48,7 +46,7 @@ public class UserChannelContext {
|
|
|
|
|
|
private String user;
|
|
|
|
|
|
- private double standardFrequecy = 442;
|
|
|
+ private double standardFrequecy = 440;
|
|
|
|
|
|
private float offsetMS;
|
|
|
|
|
|
@@ -91,35 +89,40 @@ public class UserChannelContext {
|
|
|
|
|
|
NotePlayResult result = new NotePlayResult();
|
|
|
|
|
|
+ if (Math.round(xmlNote.getFrequency()) == Math.round(playFrequency)) {
|
|
|
+ result.setStatus(0);
|
|
|
+ result.setDeviationRate(0);
|
|
|
+ result.setDeviationValue(0);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
int status;
|
|
|
- double migrationRate = 0;
|
|
|
+ double deviationRate = 0;
|
|
|
+ double deviationValue = 0;
|
|
|
+
|
|
|
+ NoteFrequencyRange noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, xmlNote.getFrequency());
|
|
|
|
|
|
- if (Math.round(xmlNote.getFrequency()) == Math.round(playFrequency)) {
|
|
|
- status = 0;
|
|
|
- migrationRate = 0;
|
|
|
+ if (noteFrequencyRange.getMinFrequency() > playFrequency ) {
|
|
|
+ status = 1;//偏低
|
|
|
+ } else if( playFrequency > noteFrequencyRange.getMaxFrequency()){
|
|
|
+ status = 2;//偏高
|
|
|
} else {
|
|
|
- NoteFrequencyRange noteFrequencyRange = new NoteFrequencyRange(standardFrequecy, xmlNote.getFrequency());
|
|
|
|
|
|
- if (noteFrequencyRange.getMinFrequency() > playFrequency ) {
|
|
|
- status = 1;
|
|
|
- } else if( playFrequency > noteFrequencyRange.getMaxFrequency()){
|
|
|
- status = 2;
|
|
|
- } else {
|
|
|
-
|
|
|
- status = 0;
|
|
|
+ status = 0;
|
|
|
|
|
|
- if (Math.round(playFrequency) < Math.round(xmlNote.getFrequency())) {
|
|
|
- double min = Math.abs(xmlNote.getFrequency() - noteFrequencyRange.getMinFrequency()) / 2;
|
|
|
- migrationRate = Math.abs(playFrequency - xmlNote.getFrequency()) / min;
|
|
|
- } else {
|
|
|
- double max = Math.abs(xmlNote.getFrequency() - noteFrequencyRange.getMaxFrequency()) / 2;
|
|
|
- migrationRate = Math.abs(playFrequency - xmlNote.getFrequency()) / max;
|
|
|
- }
|
|
|
+ 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.setMigrationRate(migrationRate);
|
|
|
+ result.setDeviationRate(deviationRate);
|
|
|
|
|
|
return result;
|
|
|
}
|