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.
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?
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!
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:
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!
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.
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?
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.