0

The title of this question is already very clear I quess. I want to read a wav file and get pulses as 1 and silence as 0 and the duration of it in microseconds.

The reason is this, I have recorded a demolutaded 433Mhz signal from a car navigation system (using an unknown protocol). The wav is amplified (clipping) to straighten lines and a DC-offset is added to make it a perfect PWM square wave (in Audacity):

enter image description here

Have downloaded the cli application sox however overwhelmed by the amount of options, don't know where to start, really. Of course searching for a solution online how to do this, however cannot find anything.

Three questions:

  • Is it possible what I want to do?
  • What command-line options do I need to use?
  • Can sox do what I did with Audicity (to be able to automate the process in a batch file)?

Output example (bit,duration):

0,255
1,100
0,50
1,200
etc.

These 'tables' can be easily used to create arrays in C/C++, to use with a microcontroller to finally mimic the remote control.

Any suggestions?

2 Answers 2

0

I assume your data is in some sort of text file like a CSV.... Reading a WAV file is quite a bit harder. You might find a WAV to CSV or WAV to TXT tool somewhere for that step.

Some small programming is involved, easy to do by anyone who has done a few months of a programming course (ie kid) :)

You need to grab the data in microsecond chunks and do a MAX() and a MIN() of those samples. Not too hard to do in VBA or C or Python or so. There are more sophisticated ways to do this much more accurately, but nothing that I can write up in 60 seconds. MAX()-MIN() below a threshold should work

If you care about the 3 blips before they would preferably be around a microsecond to be easily filterable by the next step

Count consecutive small values (below threshold) from the previous, and that will give you the output you want. Since you already cleaned up some of the data, this threshold should probably be 1/2 of full scale. Print the MAX and MIN values a few times so you know their approximate values

There are also simple edge detection routines that can pretty much tell you the exact frequency (actually just the period) for each wave in the signal. Just more coding.

0

Here is the question that lead to a solution: https://stackoverflow.com/questions/42541588/any-way-i-can-get-sox-to-just-print-the-amplitude-values-from-a-wav-file

Syntax is:

sox file.wav -t dat file.txt

I suppose that this is not very hard to tell for somebody that use sox frequently. Anyway, this produces a file with content like this (time position => amplitude):

; Sample Rate 44100
; Channels 1
               0    0.99996948242 
  2.2675737e-005    0.99987792969 
  4.5351474e-005    0.99996948242 
  6.8027211e-005    0.99981689453 
  9.0702948e-005    0.99996948242 
   0.00011337868    0.99993896484 
   0.00013605442    0.99996948242 
   0.00015873016    0.99996948242 
    0.0001814059    0.99996948242 
   0.00020408163    0.99996948242 
   0.00022675737    0.99996948242 
   0.00024943311    0.99996948242 
   0.00027210884    0.99990844727 
   0.00029478458    0.99996948242 
   0.00031746032    0.99981689453 
   0.00034013605    0.99996948242 
   0.00036281179    0.99984741211 
   0.00038548753    0.99996948242 
   0.00040816327    0.99993896484 
......
......
   1.0236961  -0.0077819824219 
   1.0237188  -0.0081176757813 
   1.0237415  -0.0078735351563 
   1.0237642  -0.0079650878906 

Still the output need some work, there are some strange exponential values at the beginning and the output needs to be calculated to be usable. I already made something in PHP to parse this.

It is very strange that it is so hard to get wave information, most on the web is limited. incomplete, outdated or not working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .