|  | @@ -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
 | 
	
	
		
			
				|  | @@ -144,6 +121,9 @@ public class SoundServiceImpl implements SoundService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public HttpResponseResult compare(MultipartFile record, Integer musicScoreId) {
 | 
	
		
			
				|  |  | +        if(record.getSize()<1024){
 | 
	
		
			
				|  |  | +            throw new BizException("录音时间太短");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          SysMusicScore sysMusicScore = sysMusicScoreDao.get(musicScoreId);
 | 
	
		
			
				|  |  |          if(Objects.isNull(sysMusicScore)|| StringUtils.isBlank(sysMusicScore.getUrl())){
 | 
	
		
			
				|  |  |              throw new BizException("伴奏信息错误");
 | 
	
	
		
			
				|  | @@ -162,7 +142,7 @@ public class SoundServiceImpl implements SoundService {
 | 
	
		
			
				|  |  |              f = new File(filePath);
 | 
	
		
			
				|  |  |              FileUtils.copyURLToFile(url, f);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            LOGGER.info("文件名:{},伴奏编号:{},源文件:{}", record.getOriginalFilename(), musicScoreId, filePath);
 | 
	
		
			
				|  |  | +            LOGGER.info("录音文件大小:{}MB,伴奏编号:{},源文件:{}", record.getSize()/1048576f, musicScoreId, filePath);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              BigDecimal oneHandred = new BigDecimal(100);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -218,7 +198,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 +212,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 +231,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);
 |