yonge 3 年之前
父節點
當前提交
9c7c7d5c43

+ 18 - 9
audio-analysis/src/main/java/com/yonge/netty/dto/UserChannelContext.java

@@ -32,6 +32,8 @@ public class UserChannelContext {
 	
 	private final static Logger LOGGER = LoggerFactory.getLogger(UserChannelContext3.class);
 	
+	private String user;
+	
 	private double standardFrequecy = 442;
 	
 	private int offsetMS;
@@ -131,6 +133,10 @@ public class UserChannelContext {
 		return datas;
 	}
 	
+	public void setUser(String user) {
+		this.user = user;
+	}
+
 	public Long getRecordId() {
 		return recordId;
 	}
@@ -220,7 +226,8 @@ public class UserChannelContext {
 		final int index = noteIndex;
 		MusicXmlBasicInfo musicXmlBasicInfo = getMusicXmlBasicInfo(songId);
 
-		if (musicXmlBasicInfo != null && index <= getTotalMusicNoteIndex(null)) {
+		int totalNoteIndex = getTotalMusicNoteIndex(null);
+		if (musicXmlBasicInfo != null && index <= totalNoteIndex) {
 			return musicXmlBasicInfo.getMusicXmlInfos().stream().filter(t -> t.getMusicalNotesIndex() == index).findFirst().get();
 		}
 
@@ -338,7 +345,7 @@ public class UserChannelContext {
 		
 		if (noteAnalysis.getMusicalNotesIndex() >= 0 && noteAnalysis.getMusicalNotesIndex() <= getTotalMusicNoteIndex(null)) {
 			
-			LOGGER.info("delayPrcessed:{} dynamicOffset:{}  Frequency:{}  splDb:{}  Power:{}  amplitude:{}  rms:{}  time:{}", delayProcessed, dynamicOffset, playFrequency, splDb, power, amplitude, rms, playTime);
+			LOGGER.info("user:{} dynamicOffset:{}  Frequency:{}  splDb:{}  Power:{}  amplitude:{}  rms:{}  time:{}", user, dynamicOffset, playFrequency, splDb, power, amplitude, rms, playTime);
 			
 			ChunkAnalysis chunkAnalysis = new ChunkAnalysis(playTime - durationTime, playTime, playFrequency, splDb, power, amplitude);
 			
@@ -831,13 +838,15 @@ public class UserChannelContext {
 		}
 		
 		//判断是否与上一个音是同一个音符
-		MusicXmlNote preMusicXmlNote = getCurrentMusicNote(null, musicXmlNote.getMusicalNotesIndex() - 1);
-		if((int)preMusicXmlNote.getFrequency() == (int)musicXmlNote.getFrequency()){
-			Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= 100).findFirst();
-			if(optional.isPresent()){
-				return optional.get().getEndTime();
-			}else{
-				return musicXmlNote.getTimeStamp() + dynamicOffset;
+		if(musicXmlNote.getMusicalNotesIndex() > 0){
+			MusicXmlNote preMusicXmlNote = getCurrentMusicNote(null, musicXmlNote.getMusicalNotesIndex() - 1);
+			if((int)preMusicXmlNote.getFrequency() == (int)musicXmlNote.getFrequency()){
+				Optional<ChunkAnalysis> optional = chunkAnalysisList.stream().filter(t -> t.getFrequency() <= 100).findFirst();
+				if(optional.isPresent()){
+					return optional.get().getEndTime();
+				}else{
+					return musicXmlNote.getTimeStamp() + dynamicOffset;
+				}
 			}
 		}
 

+ 1 - 1
audio-analysis/src/main/java/com/yonge/netty/server/NettyServer.java

@@ -53,7 +53,7 @@ public class NettyServer {
 
 	private EventLoopGroup bossGroup = new NioEventLoopGroup();
 
-	private EventLoopGroup workGroup = new NioEventLoopGroup();
+	private EventLoopGroup workGroup = new NioEventLoopGroup(5);
 
 	@Autowired
 	private NettyServerHandler nettyServerHandler;

+ 2 - 1
audio-analysis/src/main/java/com/yonge/netty/server/service/AudioCompareHandler.java

@@ -126,7 +126,8 @@ public class AudioCompareHandler implements MessageHandler {
 
 			channelContext.getSongMusicXmlMap().put(musicXmlBasicInfo.getExamSongId(), musicXmlBasicInfo);
 			channelContext.init(musicXmlBasicInfo.getPlatform(), musicXmlBasicInfo.getHeardLevel(), musicXmlBasicInfo.getSubjectId(), musicXmlBasicInfo.getBeatLength());
-
+			channelContext.setUser(user);
+			
 			userChannelContextService.register(channel, channelContext);
 
 			break;