2

Given a several minute Wave file with short clicking sounds at semi regular intervals, how would I go about getting millisecond timestamps for each of the clicks? I'm trying to verify the accuracy of a single second timer. Preferably using only the shell, Python, Ruby or other standard *nix tools.

  • 2
    can you post an example .wav recorded file showing the peaks (a few seconds of .wav showing the peaks will be enough)? It might help to find a solution – Basj May 5 '15 at 13:17
  • This is an interesting question, but it sounds like a programming question to me. Perhaps this one is for Stack Overflow? – Benjamin B. May 5 '15 at 13:38
  • How did you solve this? – FloHimself Nov 2 '16 at 12:10
  • 1
    I abandoned it :( However, I've marked your answer as accepted since it should do the job. – l0b0 Nov 2 '16 at 12:50
4

Possibly sox would be an option.

Invoked like this:

sox sound.wav sound.dat

it writes a textual representation of the sample data to the file sound.dat. Depending on the options you can get a file with the time since the beginning in the first column and a normalized sample volume in second column, e.g.:

; Sample Rate 44100
; Channels 1
               0     -0.026428223 
   2.2675737e-05     -0.022186279 
   4.5351474e-05     -0.022186279 
   6.8027211e-05     -0.022827148 
   9.0702948e-05     -0.022491455 
   0.00011337868     -0.025756836 
   0.00013605442     -0.021850586 
   0.00015873016     -0.026428223 
    0.0001814059      -0.02545166 
   0.00020408163     -0.023162842 
   0.00022675737      -0.02545166 
   0.00024943311     -0.018249512 
   0.00027210884     -0.018249512 
   0.00029478458     -0.019226074 
   0.00031746032      -0.01663208 
   0.00034013605     -0.013702393 
   0.00036281179     -0.014984131 
   0.00038548753     -0.015319824 

A bit of awk could reveal the peeks with a timestamp:

$ awk '$2 > 0.6 { print }' < sound.dat
; Sample Rate 44100
; Channels 1
       1.1002721       0.64196777 
       1.1004762       0.65371704 

man sox and man soxformat should give more info.

|improve this answer|||||
  • Output data columns (1 per input channel) are [-1.0,1.0] so you should take the absolute value (of all channels) for accurate results. It's useful also to use printf("%.12f",..) in awk, sox uses %g for its output, the presence of E notation would complicate further processing, e.g. via sort -n. – mr.spuratic May 5 '15 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.