LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset sound file read wave

Solved!
Go to solution

Hello all,

 

We are a student group from DTU and we are working with software defined radio in a 3-week course in which we will be designing an FM radio station/receiver. 
We have run into an issue with regards to resetting the position file marker in the Sound File Read.vi. Our attempt is to have a reset button which when clicked resets the wave file marker to 0 so that the next read occurs from the beginning of the audio file. We have tried to use the absolute/relative position mode coupled with a variety of ways to utilize the position offset input and offset output, but neither with any luck. The offset seems to either increase rapidly or refuse to read data when reset causing an underflow in our Tx component. 

 

Would anyone be able to provide a simple example of resetting the Sound File Read.vi or is it necessary to initiate a whole new instance/component?

Thank you very much in advance. 

0 Kudos
Message 1 of 11
(3,179 Views)

We're giving this a first and final bump to see if anyone can help us out. 

0 Kudos
Message 2 of 11
(3,121 Views)

Hi ral,

 

can you attach your test VIs?

 

From the function help it seems you only need to set "position mode" to absolute and provide a zero at "position offset" input to have it read from the start of the wave file...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 11
(3,116 Views)

Hi GerdW,

 

Thank you for your reply. 

Something peculiar occurred while trying to clean up the .VI to its simplest foundations to show why the reset function didn't work. Strangely in the simplified example the reset works with no issue. When replicating this code in our complete system it fails. 

We have uploaded both the simplified and the full code, sorry for the mess in advance it is very much a work in progress and we've only had half a dozen days of working with Labview for the first time. 

Looking forward to your reply. 

Download All
0 Kudos
Message 4 of 11
(3,108 Views)

Hi ral,

 

in your simplified example you created some problems: you open two files, but you only close one reference. Even worse: you forget about the first file's reference. And you need to learn to use shift registers. And you should learn to live without local variables...

 

In your complete VI you have the same problems with forgetting to close references!

Also when it "fails": how does it indicate that failure? Any error messages?

 

Why is there a while loop set to run only once? What's the purpose of that loop?

 

How large are your wave files? Can you load them into memory at start and just pick the part that is currently needed? Usually it's much more reliable to read some memory instead of doing file access all the time (if available memory permits).

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 11
(3,102 Views)

Hi GerdW,

 

Thank you again for the quick response. 

We will try to look up some tutorials with shift registers, assumably they are the solution to removing our local variables?

In hindsight we should probably change the inner while loop to a one-run for loop (it was initially a while loop with a proper condition). Its purpose is to read a portion of the audio file and apply relevant FM relevant operations for modulation and then finish the loop to hand this on to the transmitter component. 
The audio wave files are 40-60 MB large and could possibly be loaded into the memory to be read sequentially, we wouldn't know how to do this though. 

 

In the complete VI the error is indicated as follows:
1. The music track plays correctly initially

2. The reset button is pressed and the case for reset triggered (absolute and pos. offset set to 0)
3. The music is shortly set back to the start point for 1-2 seconds

4. The music returns to the position in the sound file prior to reset and continues as if no reset had occurred. 

 

In the simplified VI this does not occur. 

Cheers. 

0 Kudos
Message 6 of 11
(3,096 Views)

Any recommendations GerdW? 

Or anyone else who might have an idea as to why the reset only functions in the partial .VI but not in the complete VI despite having identical execution?

0 Kudos
Message 7 of 11
(3,050 Views)

Hi Ral,

 

please start by incorporating my suggestions in your simplified example (closing all references, using shift registers,...). When done so test the simplified VI for correct operation.

 

If all is ok up to here you can do the same changes to your full VI. Come back when you have done so...

 

Btw. there are several recommended programming schemes to reduce interaction/influences between parts of code like the producer/consumer pattern. You might think about them too and you might incorporate them also in your full VI to separate sound generation from data analysis...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 11
(3,046 Views)

Hi GerdW,

 

We have closed all references and used shift registers when possible and removed all local variables for both the simplified VI and the complete VI.

The issue still persists and the only major difference between the two VI (as far as we can tell) is the larger data consumation in the complete VI. We will try to implement the producer/consumer pattern, but this will take a while to rerrange all the components and so forth. 

Meanwhile we have uploaded the new VIs here. 

 

best regards

Download All
0 Kudos
Message 9 of 11
(3,039 Views)

Hi ral,

 

see the attachment as an idea…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 11
(3,032 Views)