Pārlūkot izejas kodu

feat:云教练协议

Joburgess 3 gadi atpakaļ
vecāks
revīzija
b4d7821dc5

+ 20 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundCompareHandler.java

@@ -341,12 +341,12 @@ public class SoundCompareHandler implements WebSocketEventHandler {
 
             int totalCompareNum = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).size();
 
-            MusicPitchDetailDto min = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).stream().min(Comparator.comparing(MusicPitchDetailDto::getTimeStamp)).get();
-            MusicPitchDetailDto max = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).stream().max(Comparator.comparing(MusicPitchDetailDto::getTimeStamp)).get();
-
-            int recordNoteSize = (int) userSoundInfoMap.get(phone).getRecordMeasurePitchInfos().stream().filter(e -> e.getTimeStamp() >= min.getTimeStamp() && e.getTimeStamp() < (max.getTimeStamp() + max.getDuration())).count();
-
-            boolean cd = recordNoteSize<=totalCompareNum;
+//            MusicPitchDetailDto min = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).stream().min(Comparator.comparing(MusicPitchDetailDto::getTimeStamp)).get();
+//            MusicPitchDetailDto max = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).stream().max(Comparator.comparing(MusicPitchDetailDto::getTimeStamp)).get();
+//
+//            int recordNoteSize = (int) userSoundInfoMap.get(phone).getRecordMeasurePitchInfos().stream().filter(e -> e.getTimeStamp() >= min.getTimeStamp() && e.getTimeStamp() < (max.getTimeStamp() + max.getDuration())).count();
+//
+//            boolean cd = recordNoteSize<=totalCompareNum;
 
             for (int i = 0; i < userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).size(); i++) {
                 MusicPitchDetailDto musicXmlInfo = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().get(measureIndex).get(i);
@@ -356,10 +356,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
 
                 int ot5 = (int) (musicXmlInfo.getDuration()*0.3);
 
-                List<MusicPitchDetailDto> recordPitchs = new ArrayList<>();
-                if(cd){
-                    recordPitchs = userSoundInfoMap.get(phone).getRecordMeasurePitchInfos().stream().filter(m -> Math.abs(startTimeStamp-m.getTimeStamp())<ot5 && m.getTimeStamp() < endTimeStamp).collect(Collectors.toList());
-                }
+                List<MusicPitchDetailDto> recordPitchs = userSoundInfoMap.get(phone).getRecordMeasurePitchInfos().stream().filter(m -> m.getTimeStamp()>=startTimeStamp-ot5 && m.getTimeStamp() < endTimeStamp-ot5).collect(Collectors.toList());
 
                 boolean cadenceRight = false;
                 boolean intonationRight = false;
@@ -375,9 +372,6 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                     cadenceNum++;
                     cadenceRight = true;
                 }
-                if (musicXmlInfo.getFrequency()<0&&recordPitchs.size()<=0){
-                    cadenceNum++;
-                }
                 //音准、完成度
                 if (cadenceRight){
                     //音准
@@ -410,6 +404,19 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                     integrityRight = integrityDuty>0.7;
                 }
 
+                //如果当前音符不需要演奏
+                if (musicXmlInfo.getFrequency()<0&&recordPitchs.size()<=0){
+                    cadenceNum++;
+                    cadenceRight = true;
+
+                    intonationScore += 100;
+                    musicXmlInfo.setAvgFrequency(-1);
+                    intonationRight = true;
+
+                    integrityScore += 1;
+                    integrityRight = true;
+                }
+
                 if(!cadenceRight){
                     userSoundInfoMap.get(phone).getMusicalNotesPlayStats().add(new MusicalNotesPlayStatDto(musicXmlInfo.getMusicalNotesIndex(), MusicalErrorTypeEnum.CADENCE_WRONG));
                 }else if(!intonationRight){

+ 2 - 2
mec-websocket/src/main/java/com/ym/mec/web/config/WebSocketConfig.java

@@ -33,8 +33,8 @@ public class WebSocketConfig implements WebSocketConfigurer {
     @Bean
     public ServletServerContainerFactoryBean createWebSocketContainer() {
         ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
-        container.setMaxTextMessageBufferSize(8192*4);
-        container.setMaxBinaryMessageBufferSize(8192*4);
+        container.setMaxTextMessageBufferSize(8192*9);
+        container.setMaxBinaryMessageBufferSize(8192*9);
         return container;
     }