0

I have written a Java application which records a .wav audio file from a microphone. If you look at a wave graph of the file (screenshot attached), it will be a flat-line with just two spikes. My goal is to process the file to find the time (in the recording) at which each spike peaks.

Example: In the attached screenshot, the first peak happens at 1.52585 seconds into the recording while the second peak happens 1.52692 seconds in. Subtracting these, I can find the time difference between the spikes: 0.00107 seconds.

I'm sure all it takes is a relatively simple algorithm, however, I have no idea how to go about it. Should i be looking at decibels? Can someone please guide me? I'm so confused (I know nothing about audio).

Screenshot

Sam
  • 7,252
  • 16
  • 46
  • 65
sryan2580
  • 1
  • 2
  • Calcualte differences between adjacent samples. Differences between differences should do it, I think? – Martin James Dec 12 '15 at 21:35
  • Im sorry, but how would i do that? – sryan2580 Dec 12 '15 at 21:39
  • What have you actually tried? – Durandal Dec 12 '15 at 21:48
  • This is exactly my problem, i dont know what to try. I just barely managed to get the actual recording function working. I have every other function written but i need this part to work before they can be implemented – sryan2580 Dec 12 '15 at 21:52
  • i know im asking alot here... – sryan2580 Dec 12 '15 at 21:54
  • You do it just as @Martin has said. If you can actually graph the spikes then you can also place the moment in time at which each spike is applied to the graph into an Array. You can then do your calculations based on what is stored within that Array. Use an ArrayList since it can dynamically grow. First element within the array would be the start time and then each spike time for additional elements. – DevilsHnd - 退職した Dec 13 '15 at 00:12
  • Is the problem you are having the issue of recognizing the spikes? The relationship between time and location in a data array is simple, can be derived from the bytes per frame and frame rate, both of which are obtainable via the format of the sound file. The explanation about calculating RMS in the answer Andrew linked should help with identifying the spike. – Phil Freihofner Dec 14 '15 at 04:14

0 Answers0