|
@@ -7,10 +7,12 @@ import be.tarsos.dsp.util.PitchConverter;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.biz.dal.config.SoundCompareConfig;
|
|
|
+import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
|
|
|
import com.ym.mec.biz.dal.dto.MusicPitchDetailDto;
|
|
|
import com.ym.mec.biz.dal.dto.SoundCompareHelper;
|
|
|
import com.ym.mec.biz.dal.dto.WavHeader;
|
|
|
import com.ym.mec.biz.dal.dto.WebSocketInfo;
|
|
|
+import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
|
|
|
import com.ym.mec.biz.handler.WebSocketHandler;
|
|
|
import com.ym.mec.biz.service.SoundSocketService;
|
|
|
import com.ym.mec.biz.service.SysMusicCompareRecordService;
|
|
@@ -21,7 +23,6 @@ import org.apache.commons.io.FileUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -64,6 +65,8 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
|
|
|
|
@Autowired
|
|
|
private SysMusicCompareRecordService sysMusicCompareRecordService;
|
|
|
+ @Autowired
|
|
|
+ private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
|
|
|
|
|
|
public SoundCompareHandler() {
|
|
|
WebSocketHandler.regist("SOUND_COMPARE", this);
|
|
@@ -95,6 +98,13 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
|
userSoundInfoMap.get(phone).setMusicXmlInfos(musicXmlInfos);
|
|
|
musicXmlInfos = musicXmlInfos.stream().filter(m->!m.getDontEvaluating()).collect(Collectors.toList());
|
|
|
userSoundInfoMap.get(phone).setMusicScoreId(bodyObject.getInteger("id"));
|
|
|
+ if(bodyObject.containsKey("platform")){
|
|
|
+ userSoundInfoMap.get(phone).setDeviceType(DeviceTypeEnum.valueOf(bodyObject.getString("platform")));
|
|
|
+ }
|
|
|
+ List<Integer> subjectIds = sysMusicScoreAccompanimentDao.findSubjectByMusicScoreId(userSoundInfoMap.get(phone).getMusicScoreId(), null);
|
|
|
+ if(!CollectionUtils.isEmpty(subjectIds)){
|
|
|
+ userSoundInfoMap.get(phone).setSubjectId(subjectIds.get(0));
|
|
|
+ }
|
|
|
userSoundInfoMap.get(phone).setMeasureXmlInfoMap(musicXmlInfos.stream().collect(Collectors.groupingBy(MusicPitchDetailDto::getMeasureIndex)));
|
|
|
musicXmlInfos.forEach(e->userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(e.getMusicalNotesIndex(), e.getFrequency()));
|
|
|
for (Map.Entry<Integer, List<MusicPitchDetailDto>> userMeasureXmlInfoEntry : userSoundInfoMap.get(phone).getMeasureXmlInfoMap().entrySet()) {
|
|
@@ -144,10 +154,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
|
createHeader(phone);
|
|
|
break;
|
|
|
case SoundSocketService.PROXY_MESSAGE:
|
|
|
-// if(bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
|
|
|
-// int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
|
|
|
-// calOffsetTime(phone, offsetTime);
|
|
|
-// }
|
|
|
+ if(DeviceTypeEnum.IOS.equals(userSoundInfoMap.get(phone).getDeviceType())&&bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
|
|
|
+ int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
|
|
|
+ calOffsetTime(phone, offsetTime);
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -478,7 +488,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
|
|
|
header.put("commond", command);
|
|
|
webSocketInfo.setHeader(header);
|
|
|
Map<String, Object> result = new HashMap<>(5);
|
|
|
- BigDecimal score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0, BigDecimal.ROUND_UP);
|
|
|
+ BigDecimal score = cadence;
|
|
|
+ if(Objects.isNull(userSoundInfoMap.get(phone).getSubjectId())||userSoundInfoMap.get(phone).getSubjectId()!=23){
|
|
|
+ score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0, BigDecimal.ROUND_UP);
|
|
|
+ }
|
|
|
result.put("score", score);
|
|
|
result.put("intonation", intonation);
|
|
|
result.put("cadence", cadence);
|