From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sound file using sampling; cannot play different files

 sir,

i am trying to play a .wav file using array method in a case structure but only the default case keeps playing in a loop.

my aim is to play each file once as per the string control.

i have attached VI. please modify it and fix it 

thank you

🙂

0 Kudos
Message 1 of 4
(2,188 Views)

@may97 wrote:

 sir,

i am trying to play a .wav file using array method in a case structure but only the default case keeps playing in a loop.

my aim is to play each file once as per the string control.

i have attached VI. please modify it and fix it 

thank you

🙂


Hi May,

 

You do not have any arrays or loops on your diagram. Once you make your string control into an array you can pass them through the border of a for loop one by one.

 

As for "please modify and fix it", it appears that this is an assignment for a class, so you must do the work and learn. Even if it was not for a class, it would be much better for you to try 10 iterations to arrive at the answer than to just be handed a program that works but you can't explain.

0 Kudos
Message 2 of 4
(2,184 Views)

A few more comments about your code:

 

  • You case structure only differs by two diagram constant (path, index) and these are the only things that should be inside the structure. All shared code belongs after the case structure. No need to duplicate everything.
  • Even easier, use an array of two sound files and index into it by "=a?" followed by "boolean to 0,1". No case structure needed.
  • Instead of using a string for the case structure, use an enum. Now it is impossible to enter an unrecognized string.
  • If you want to keep it a string, at least set the control to "limit to single line". If you don't, the string might contain an invisible linefeed and case "a" will never execute. (users typically enter "a" and hit the return key, adding an invisible linefeed unless it is limited to a single line).
  • How many channels are in your data? Why are you reading the first channel for "b" and the second channel for "a"?
  • If you don't need the graph, you could just use this to play a sound file.
  • ...

 

0 Kudos
Message 3 of 4
(2,153 Views)

thanks for your help!!

0 Kudos
Message 4 of 4
(2,131 Views)