LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Music player in Labview

Hello, I need to create the following program:

Gather 18 wav files in three folders, each folder will be considered as a playlist. Design a front panel with the theme of an audio player that includes:

  1. The visualization of audio signals in both time and frequency domains.
  2. A slider indicator showing the progress of the current track. Its upper limit must be adaptable in seconds.
  3. Buttons with the following functions:
    • Play (Plays the current track or resumes playback after a pause).
    • Pause (Pauses the playback until the user presses the pause or play button again).
    • Stop (Stops the playback. After this, only the play button can resume playback from the first song in the playlist).
    • Fast Forward (Advances the playback by one second. If it reaches the end of the track, the program plays the next track).
    • Rewind (Rewinds the playback by one second. If it reaches the beginning of the track, the program plays the previous track from the end).
    • Skip Forward (Skips to the start of the next track. If it reaches the end of the playlist, it starts playing the first song of the next playlist).
    • Skip Backward (Skips to the start of the previous track. If it reaches the beginning of the playlist, it starts playing the last song of the previous playlist).
  4. An array indicator should display the names of all the songs in the current playlist.

In general, the front panel should be customized to look like an audio player.

I have already managed to create the graphs and the array indicator that shows the names of all the songs, but I still can't get the slider and the buttons to work. Any help is greatly appreciated.

0 Kudos
Message 1 of 13
(967 Views)

You didn't post any code or ask a specific question.  I assume this code should also be able to actually play the songs out of the PC audio?  Not just visualization?

 

What kind of programming pattern are you thinking of?  

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 2 of 13
(954 Views)

This is my code so far. But I can't get it to play all the files. I have a main folder and three subfolders within it, and within those three subfolders, I have 6 wav audio files in each one (18 in total). However, I don't know how to make it play all 18 audios in sequence.

0 Kudos
Message 3 of 13
(949 Views)

I'm still using LabVIEW 2019 so I can't open your code, but I'm sure others will take a look. 

 

If you want to maximize the help on this forum, you can always back-save your code to older versions.  2018 is a good choice. 

File > Save for Previous...  and select 2018 or so.

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 4 of 13
(941 Views)

asumouq11_0-1716927597712.png

This is my block diagram so far. I managed to adjust the maximum value of the slider with a property node, but i dont know how to make it move according to the time of the song. When i run it, the slider doesnt move at all

0 Kudos
Message 5 of 13
(913 Views)

You are new to the Forums, so you haven't seen responders yelling "Attach VIs, not pictures!  We can't test, debug, modify a Picture ...".  Of course, many of us aren't using the most recent version(s) of LabVIEW, so you need to "Save for Previous Version" and specify LabVIEW 2019 or 2021 for a better chance of getting an "expert" to look at (and maybe fix) your code.  But no pictures, please.

 

Bob Schor

 

0 Kudos
Message 6 of 13
(895 Views)

Sorry, it was my first time asking something here. I just started using labview. This is the vi for 19.0 version

0 Kudos
Message 7 of 13
(889 Views)

I think your main problem is that you didn't quite get the operation of Recursive File List.  I also am not quite sure about the structure of your data.  Here's what I think you have:

  • Top Level Folder (no files in this folder)
    • Folder 1 (no sub-folders in this folder)
      • Files 1 through 6
    • Folder 2
      • Files 7 through 12
    • Folder 3
      • Files 13 through 18

Assume the above file scheme is correct.  Start with a Path to the Top Level Folder (what I call the Folder of Folders).  Pass this into "List Folder" -- you want to "construct" the paths to the three sub-folders.  List Folder gives you (as outputs) Path Out (which is "Folder of Folders") and an Array "Folder Names" (which should be the strings "Folder 1", "Folder 2", and "Folder 3").

 

You now want to process the "Array of 3 folders".  What do you do when you want to process the elements of an Array?  Right, you drop a For Loop.  Wire in "Path Out" (which comes in on an "ordinary" tunnel) and the array "Folder Names" (which becomes an Indexing Tunnel, automatically).  What do you wire to "N"?  Nothing, having an Array input makes N process each element of the Array.  [Oops -- I forgot to mention you should also wire the Error Line into the For loop].

 

So now you are "inside the (first) For Loop", with a Path to a Folder, and the name of a sub-Folder of that folder.  How do you put the two together to get the name of the "Folder of 6 Files"?  [Hint -- it's on the File menu, and will give you another Path to the sub-Folder.

 

So you have the path to the sub-Folder.  What do you want?  You want the files in the sub-Folder.  Pass the path to List Folder, where you want the files in this sub-Folder.  You want to process the Array of Files, knowing the sub-Folder where they are found.  What do you do?  [Sound familiar?].  I hope you say "Drop another For Loop, bring in the sub-Folder, the Array of Files, and the Error Line, combine to get a path to the File in the sub-Folder, and play it.  Maybe put a 3-second Wait after you play the file, after which it will play File 2, then 3, then 4, then 5, then 6, and that finishes the innermost For for the first sub-Folder, then you'll do the 6 files of the second sub-folder, and so on.

 

Give it a try.

 

Bob Schor 

Message 8 of 13
(872 Views)

Help, I need to create a program that plays the audio files within a folder, and with buttons, it performs the following actions: Play (plays the current track or resumes playback after a pause), Pause (stops the playback sequence until the user presses the pause or play button again), Stop (stops the playback sequence, after which only pressing play will resume playback from the first song in the playlist, i.e., from the folder).

I have an idea for the state machine design, but I'm not quite sure how to implement it. First, the user runs the program, and the audio files start playing automatically in the order they are in the folder, and when the audio finishes, the program execution ends (this part is already done).

Here the state machine with its case structure and event structure comes into play. State 1 is playback, and the program remains in this state until a change occurs. If the play button is True, the program does nothing because the audio is already playing; if the play button is False, the program does nothing. If the pause button is pressed and it is True, the audio playback is paused, and the program changes to state 2; if the pause button is False, the program does nothing. If the stop button is pressed and it is True, the audio playback is paused, and the program changes to state 3; if the stop button is False, the program does nothing.

State 2 is pause. If the play button is pressed and it is True, the program plays the song and returns to state 1; if the play button is False, the program does nothing. If the pause button is True, the program does nothing; if the pause button is pressed and it is False, the program plays the song and returns to state 1. If the stop button is pressed and it is True, the program changes to state 3; if stop is False, the program does nothing.

State 3 is stop. If the play button is pressed and it is True, the program should return to the beginning of the playlist, i.e., it should play the first audio from the beginning; if the play button is False, the program does nothing. In this state, it does not matter if the pause and stop buttons are true or false, as the only button that can resume the program is play.

That's my idea, but I don't know how to implement it in an event-driven state machine. My main question is not so much about how to change from one state to another, it's more about how to pause and resume playback. From which sound -> output function can this be obtained? I was thinking of the info function that tells me if the audio is playing. Or connecting it to the stop function in some way to my case to stop the execution, but I already tried it, and it doesn't work for me. Any help is appreciated.

0 Kudos
Message 9 of 13
(856 Views)

I try to implement my idea, but now the sound doesnt play and nothing happens when i press play, pause or stop. Please help me, I dont know what else to do

This is the 19.0 version of my code

 

0 Kudos
Message 10 of 13
(812 Views)