|
@@ -323,12 +323,18 @@ public class SoundCompareHelper implements PitchDetectionHandler {
|
|
|
float pitch = pitchDetectionResult.getPitch();
|
|
|
int decibel = (int) (100 - Math.abs(silenceDetector.currentSPL()));
|
|
|
|
|
|
+ int byteIndex = (int) (audioEvent.getTimeStamp()*(SoundCompareHandler.soundCompareConfig.audioFormat.getFrameSize()*SoundCompareHandler.soundCompareConfig.audioFormat.getFrameRate()));
|
|
|
+ byte byteOne = audioEvent.getByteBuffer()[byteIndex];
|
|
|
+ byte byteTwo = audioEvent.getByteBuffer()[byteIndex + 1];
|
|
|
+
|
|
|
+ double amplitude = ((byteOne&0x000000FF)|(byteTwo<<8));
|
|
|
+
|
|
|
if(decibel <= SoundCompareHandler.soundCompareConfig.validDb){
|
|
|
pitch = -1;
|
|
|
decibel = 0;
|
|
|
}
|
|
|
|
|
|
- SoundCompareHandler.LOGGER.info("时间:{}, 频率:{}, 分贝:{}", timeStamp, pitch, decibel);
|
|
|
+ SoundCompareHandler.LOGGER.info("时间:{}, 振幅:{}, 频率:{}, 分贝:{}", timeStamp, amplitude, pitch, decibel);
|
|
|
|
|
|
if(currPitchInfos.size()>0&&(Math.abs(currPitchInfos.get(currPitchInfos.size()-1).getFrequency()-pitch)>10||Math.abs(currPitchInfos.get(currPitchInfos.size()-1).getDecibel()-decibel)>10)){
|
|
|
Double avgPitch = currPitchInfos.stream().skip(1).collect(Collectors.averagingDouble(MusicPitchDetailDto::getFrequency));
|