LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert saved binary file to .wav file

Does the bin file is ok or not? Anyway, you are reading a single word from it. Use count = -1 to read the whole file.

Side note: you don't need to close the file and reopen, just use Set File Position to rewind the binary file.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 11 of 27
(1,825 Views)

The bin file is fine, just not sure why it won't create / overwrite a new wav file.  How would I read the binary file after stop is pressed and then write a new wav file instead of overwriting the bin?

 

Thanks for the reply.

0 Kudos
Message 12 of 27
(1,820 Views)

Have you put an error handler after on your error out for the file like you did for the other error wire?  I'm guessing there's an error you're not aware of.

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 13 of 27
(1,815 Views)

The attached is finally creating a .wav file and looks to have some data in it but when playing it in Audacity it shows no waveform.  Any clues as to what I am missing.

Again, thanks for all the help and replies. 

0 Kudos
Message 14 of 27
(1,810 Views)

You may have to "resample" it as a standard .wav file format.  Maybe Audacity doesn't consider it a .wav file.

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 15 of 27
(1,805 Views)

Do you mind showing how I would do that? 

0 Kudos
Message 16 of 27
(1,815 Views)

Well, according to your VI, you sampled at 0.0002 seconds, or 5 kHz which is not a standard .wav format.  Resampling at 44.1 kHz before writing the sound file should do the trick.  (There are other rates you could use, but that one is most common.)  LabVIEW has some resampling VIs to help you, but I'm actually not exactly sure which one you should be using.  There are examples for each of them included in LabVIEW.

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 17 of 27
(1,803 Views)

Hi,

 

I am attempting to write a .wav file from a .bin file in my VI after the stop button is pressed.  Currently when I do this, the .wav file is created and seems to have data being stored to the file (because the file size increases) but when I attempt to play the file in Audacity there is no signal.  My bin file has the correct audio data saved to it.  The .bin file and the .wav file show the same file size as well.

 

What am I doing wrong?


Thanks for any help.

0 Kudos
Message 18 of 27
(1,809 Views)

Hi LKcire,

 

please stop creating new threads for the very same problem! Keep related things/VIs in just one thread/discussion!

(I merged your threads…)

 

Why don't you divide your complete VI into several sub-problems?

Why not investigate the WAV-file generation on its own?

 

See this:

It works for me as expected: a WAV file is generated, with the content I expect to be written…

 

Two notes:

  • While it was suggested to change the samplerate to common values like 44.1kHz this is not needed. "Good" mediaplayers can handle any (reasonable) samplerate! Audacity (V3.0) or MediaplayerClassicHC play that 5kHz waveform nicely!
  • Did you notice that red coercion dot at the WriteWaveFile function? LabVIEW doesn't handle your U16 data very well and converts the samples to an DBL array before saving…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 27
(1,787 Views)

Sorry for the multi-threads.

 

You don't think it would have anything to do with how I am trying to read from the binary file do you?

 

If LabVIEW does not handle my U16 data well, how would I get around this to make sure that isn't the issue?
The wave file is created and the file size increases so I assume has "data" in it but when playing it through Audacity there is no waveform.

0 Kudos
Message 20 of 27
(1,781 Views)