java - Trouble in finding difference between 2 sound frames in a wav file -


i wanted compare how 2 sound frames similar, can distinguish between them.

i doing because, when had video playing , advertisement comes up, there either sound drop or increase in sound.

so want compare sound frames wav file find difference.

the following code finds amplitude of sound wave per video frame

1 video frame corresponds 2000 sound frames.

code ---->

for (offset=wavefileheaderoffset; ((offset < raf.length()) && (videoframes < videofile.max_possible_frames)); offset+=2*audio_per_frame)  {           audioamplitude = 0.0;               (offset2=0; offset2 < 2*audio_per_frame; offset2+=2 )            {                 double temp = 0.0;                 raf.seek(offset+offset2);                 raf.read(bytes);                 temp = (double) math.abs((double)( ( ( bytes[1]  << 8 ) | ( bytes[0] & 0xff ) ) / 32768.0 ));                 audioamplitude += temp;              }             audioamplitude /= audio_per_frame;//we taking average of frames corresponding video frame              arraylist<double> tempframedata = new arraylist<double>();             (videofile.framehashmap.get(videoframes).clone());             tempframedata.add(audioamplitude);               videofile.framehashmap.put(videoframes, tempframedata);              videoframes++;       } 

the problem since amplitude divide 32768 normalize it. cant determine threshold distinguish between them.

all amplitude close each other. think making mistake in calculating amplitude.

can 1 comment on how compare 2 frames using these amplitudes find significant difference when advertisement comes in between video.

thanks

http://en.wikipedia.org/wiki/loudness_war
article music applies commercials too. interesting part dynamic range reduction.

studies have found human hear prefer "loud" signals instead of "weak" signals.
when you're trying sell something, comes in handy.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -