瀏覽代碼

Merge branch 'transaction_teacher'

Joburgess 4 年之前
父節點
當前提交
2c27e17eea
共有 1 個文件被更改,包括 10 次插入34 次删除
  1. 10 34
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundServiceImpl.java

+ 10 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundServiceImpl.java

@@ -50,8 +50,6 @@ public class SoundServiceImpl implements SoundService {
     @Autowired
     private SysMusicScoreDao sysMusicScoreDao;
     @Autowired
-    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
-    @Autowired
     private IdGeneratorService idGeneratorService;
 
     /**
@@ -74,27 +72,6 @@ public class SoundServiceImpl implements SoundService {
         return times;
     }
 
-    private List<Double> rootMeanSquareExtractor(byte[] bytes, String url) throws UnsupportedAudioFileException {
-        List<Double> rootMeans = new ArrayList<>();
-        int size = 2048;
-        int overlap = 0;
-        AudioDispatcher dispatcher = StringUtils.isBlank(url)?getFromByteArray(bytes, size, overlap):getFromFile(url, size, overlap);
-
-        dispatcher.addAudioProcessor(new AudioProcessor() {
-            @Override
-            public void processingFinished() {
-            }
-
-            @Override
-            public boolean process(AudioEvent audioEvent) {
-                rootMeans.add(audioEvent.getRMS());
-                return true;
-            }
-        });
-        dispatcher.run();
-        return rootMeans;
-    }
-
     /**
      * @describe 音频分贝信息提取
      * @author Joburgess
@@ -218,7 +195,7 @@ public class SoundServiceImpl implements SoundService {
             float sameTimes = 0;
             for (Double time1 : times_s) {
                 for (Double time2 : times_r) {
-                    if(Math.abs(time2-time1)<1.5){
+                    if(Math.abs(time2-time1)<1.3){
                         sameTimes++;
                         break;
                     }
@@ -232,14 +209,13 @@ public class SoundServiceImpl implements SoundService {
             }
             cadence = new BigDecimal(cadence_d).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
 
-            integrity = new BigDecimal(0);
-            if(l_r.compareTo(BigDecimal.ZERO)<=0||l_s.compareTo(BigDecimal.ZERO)<=0){
-
-            }else if(l_r.compareTo(l_s)<0){
-                integrity = l_r.divide(l_s, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
-            }else{
-                integrity = new BigDecimal(100);
+            //完整度
+            BigDecimal time_s = new BigDecimal(times_s.size());
+            BigDecimal time_r = new BigDecimal(times_r.size());
+            if(time_s.compareTo(time_r)<0){
+                time_r = time_s;
             }
+            integrity = time_r.divide(time_s, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHandred).setScale(0, BigDecimal.ROUND_HALF_UP);
 
             score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), 0, BigDecimal.ROUND_HALF_UP);
 
@@ -252,9 +228,9 @@ public class SoundServiceImpl implements SoundService {
             if(f!=null){
                 f.delete();
             }
-//            if(f_r!=null){
-//                f_r.delete();
-//            }
+            if(f_r!=null){
+                f_r.deleteOnExit();
+            }
         }
 
         result.put("score", score);