11-04-2021 02:19 PM
Hello,
I'm trying to have two parallel while loops running in my labview vi. The top while loop works as it should, plotting portions of my incoming data frame.
The second (bottom) while loop I am trying to grab the audio data of my frame which is the 3rd and 4th byte of the packet and write this to a .wav file.
I'm really new to LabView and am not sure if I am doing this the correct way, but I also know the second while loop does not seem to be running. How do I get this to run in parallel with the top loop?
Thanks for any help.
11-04-2021 02:32 PM - edited 11-04-2021 02:36 PM
Hi LKcire,
@LKcire wrote:
I'm trying to have two parallel while loops running in my labview vi.
When you want to have parts of your code to run in parallel then there should be NO data dependency between those parts!
Now look at your code: is there any data dependency (aka wire/dataflow) between both loops?
@LKcire wrote:
I also know the second while loop does not seem to be running. How do I get this to run in parallel with the top loop?
By avoiding data dependencies!
Btw.:
11-04-2021 02:59 PM
11-04-2021 03:08 PM
Hi LKcire,
@LKcire wrote:
Ok thank you that does make sense about the code dependencies.
I originally tried to write the two bytes in the first loop after I picked them out of the packet, however, it really slowed down my plot and I was clearly missing data chunks during this.
I can't just save the 2 bytes because the end goal is to save those audio bytes into a .wav file
No need to hide your answer in a spoiler tag…
I suggested to save those bytes in a "raw binary" file instead of that convoluted wavefile creation because it really is slow the way you implemented it!
So again I suggest:
11-04-2021 03:26 PM
Hi!
A structure like a WHILE loop only starts to execute when all inbound wires carry data, and all outbound wires will carry data away when the structure is done.
That means, only when "stop" is clicked and the upper loop ends, the string data will flow out from the upper loop into the lower loop. Only then, the lower loop will start. And it will overwrite the same *.wav file with the same data over and over again, until you click "stop 2"
Further more, if during the last execution of the upper loop, there was no initial 0x24 byte, the FALSE case will be executed, which sends out an empty string.
And oh, the *.wav file will only contain a single sample.
I have modified your code:
This is just a minor change, but I think it does what you want, and it is closest to your idea. (But I can't test the VI)
The following picture was created from the block diagramm via Edit > Create snippet from selection. You can actually drag this picture into an empty block diagramm!
11-04-2021 03:41 PM
Thank you for doing this... I actually cannot drag it into a blank block diagram... if I try it only shows the link to the image in my block diagram.
11-04-2021 03:51 PM - edited 11-04-2021 03:52 PM
@LKcire wrote:
Thank you for doing this... I actually cannot drag it into a blank block diagram... if I try it only shows the link to the image in my block diagram.
You need to download the image, then drag the downloaded png file to the block diagram.
11-05-2021 07:07 AM
Thanks, it wouldn't let me drag and drop because I have an earlier version of LabView. Would you be able to just post the .vi so I can work with that?
Thanks again.
11-05-2021 08:57 AM
I tried to recreate what you have in the image, but the data is not correct. It saves 20KB of data when I click "Save" however it is not my audio bytes. It looks corrupt.
11-05-2021 09:03 AM
It actually does not even ask for the filename so I'm not certain that any "real" data is getting into the queue.