LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Raw PCM to WAV

Hi,

 

I have some raw PCM audio data.  I want to convert it to .WAV format.  I know the sampling frequncy is 48kHz, 16bits/sample stereo data.  The raw PCM data looks like below.  I want to convert it to .WAV by adding a header or whatever I need to do and be able to play it.

 

Raw Payload =
   32, 06, 32, 06, 99, 18, 99, 18,
   8B, 1B, 8B, 1B, C2, 15, C2, 15,
   AC, 09, AC, 09, 67, 01, 67, 01,
   49, FC, 49, FC, 1E, FE, 1E, FE,
   49, 06, 49, 06, E0, FF, E0, FF,
   B2, F6, B2, F6, 31, EF, 31, EF,
   3B, EA, 3B, EA, 6B, F4, 6B, F4,
   92, F3, 92, F3, AC, EA, AC, EA,
   99, E9, 99, E9, E5, EE, E5, EE,
   4F, EF, 4F, EF, D2, DF, D2, DF,
   92, DF, 92, DF, C2, E7, C2, E7,
   7D, E4, 7D, E4, A6, EB, A6, EB,
   29, EE, 29, EE, 99, EC, 99, EC,
   D9, F3, D9, F3, 58, F2, 58, F2,
   AA, EE, AA, EE, 4B, F2, 4B, F2,
   5C, F9, 5C, F9, AC, 00, AC, 00,
   B1, 06, B1, 06, A8, 0A, A8, 0A,
   CB, 03, CB, 03, 46, FD, 46, FD,
   16, F9, 16, F9, 1B, EF, 1B, EF,
   CE, E6, CE, E6, 74, E8, 74, E8,
   17, F1, 17, F1, AB, F6, AB, F6,
   4E, F6, 4E, F6, B8, FD, B8, FD,
   DD, 02, DD, 02, 43, FA, 43, FA,
   66, F6, 66, F6, 0E, F2, 0E, F2,
   82, ED, 82, ED, EA, F3, EA, F3,
   72, F7, 72, F7, 69, EE, 69, EE,
   94, EF, 94, EF, 5F, FD, 5F, FD,
   E8, FB, E8, FB, A0, F1, A0, F1,
   F6, EF, F6, EF, DB, F0, DB, F0,
   84, E7, 84, E7, 47, D8, 47, D8,
   3A, D6, 3A, D6, 1D, D8, 1D, D8,
   F1, DA, F1, DA, A2, E9, A2, E9,
   17, EF, 17, EF, CC, E8, CC, E8,
   47, EB, 47, EB, 60, EF, 60, EF,
   59, F1, 59, F1, 98, EF, 98, EF,
   07, EE, 07, EE, 54, F5, 54, F5,
   22, FB, 22, FB, 1B, F3, 1B, F3,
   C9, F0, C9, F0, F5, F6, F5, F6,
   01, FA, 01, FA, CA, FB, CA, FB,
   4D, EF, 4D, EF, AD, E2, AD, E2,
   D5, E9, D5, E9, EE, F6, EE, F6,
   3B, F9, 3B, F9, 99, F3, 99, F3,
   56, EC, 56, EC, 21, EA, 21, EA,
   BD, ED, BD, ED, 47, F3, 47, F3,
   6D, FA, 6D, FA, F5, FC, F5, FC,
   A6, FE, A6, FE, A4, 00, A4, 00,
   75, 00, 75, 00, 29, FB, 29, FB,
   EB, F7, EB, F7, 0F, FD, 0F, FD,
   E7, 05, E7, 05, ED, 09, ED, 09,
   75, 0D, 75, 0D, 00, 17, 00, 17,
   10, 12, 10, 12, BC, 0A, BC, 0A,
   1B, 06, 1B, 06, 67, FD, 67, FD,
   B6, 00, B6, 00, 30, 06, 30, 06,
   88, 03, 88, 03, 6E, 01, 6E, 01,
   97, F9, 97, F9, 7F, ED, 7F, ED,
   B9, E8, B9, E8, F9, E8, F9, E8,
   15, EF, 15, EF, 42, F2, 42, F2,
   CE, EB, CE, EB, 99, E6, 99, E6,
   6E, E7, 6E, E7, 1E, ED, 1E, ED,
   4F, E9, 4F, E9, BC, E3, BC, E3

0 Kudos
Message 1 of 15
(6,529 Views)

Hi Sidd,

 

Here are the list of functions that you can use to play the sound from the data provided.

http://zone.ni.com/reference/en-XX/help/371361K-01/lvpict/soutput_vis/

 

And here are the list of functions that you can use to write to the .wav sound file.

http://zone.ni.com/reference/en-XX/help/371361K-01/lvpict/sfilevis/

 

You can look at the example on how to play the sound and write to sound file via Help > Find Examples.

Under Browse tab, Select Browse according to: Task, go to Hardware Input and Output > Sound > Sound Input to File.vi

 

You can also get obtain Generate Sound.vi from the same folder as an exmaple on how to play the sound. You might need to perform some modifications to get what you want.

 

Hope that helps.

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



0 Kudos
Message 2 of 15
(6,489 Views)

Hi,

Did you found the way to convert this?

 

Thank you!

0 Kudos
Message 3 of 15
(5,924 Views)

Read the raw file as a text file (uncheck the "Convert EOL" option).  Don't worry - this just means it's reading the file as bytes and showing you the data as what it would look like if they bytes represented Extended ASCII characters.  Anyway, after you did that, add the .wav header to the beginning of the string.  Then write it back as a text file (uncheck the "Convert EOL" option.)

 

I've never actually done this before; it's just an educated guess.  To anyone reading this, do the instructions above seem right?  is there an easier way to do this?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 15
(5,919 Views)

Thank you Bill,

I just try and did't work, maybe the WAV header is not ok, I will continue trying.

 

 

0 Kudos
Message 5 of 15
(5,905 Views)

Sorry I can't be of more help.  😞

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 15
(5,900 Views)

Done!

Code annexed...

 

 

 

Download All
Message 7 of 15
(5,894 Views)

Hello!
I have a very similar problem, and your code generally seems to work. Is there any way you could help me interpret my own raw data file? I was able to open it in a HEX Editor to interpret, but I'm having a hard time deciphering the sampling rate, etc. so that I can "update" the header information.


To be honest, this is beyond me and I don't have access to support. I'm not even sure if I'm doing it right... Thanks in advance.

0 Kudos
Message 8 of 15
(5,140 Views)

Hey Vik_K,

 

If nobody replies to this post you could increase visibility and your chances of getting a reply by making a new post and linking to this one. If you do, I would also recommend posting your data along with it so that someone has access to it quickly. That might increase your chance of getting a reply.

Sam J.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 15
(5,126 Views)

I'm not sure how I did it, but inside the block diagram is the Link with some Instructions.

 

here again:

https://stackoverflow.com/questions/29992898/decoding-a-wav-file-header/

 

 

take a look here too

https://stackoverflow.com/questions/28231198/how-to-add-playablesuch-as-wav-wmv-header-with-pcm-data...

 

 

thanks

0 Kudos
Message 10 of 15
(5,121 Views)