Queueing tracks on the fly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Queueing tracks on the fly

Dim Tim
Please excuse my questions, but I did'nt find any documentation or FAQ on uos, besides examples. :)

I need to implement a voice feedback/diagnostics for a technological system based on a headless Raspberry Pi.  For that, I need a queue of audio tracks and an ability to add to the queue tracks on the fly.  So, does uos create players in separate threads?  Can I enqueue tracks with an existing lib functions (uos_AddFromFile?), or should I create a queue myself?  Can I add pauses to the queue?
Reply | Threaded
Open this post in threaded view
|

Re: Queueing tracks on the fly

fredvs
Administrator
Hello Dim Tim, welcome to uos forum!

Sorry but I dont understand what queue you want to do.

Each uos-player is a independent thread, so for queuing the easiest is to use 2 players and do a kind of "ping-pong" with those 2 players.

With your list of song, load a song in the first player and play it.
If you want to play a other song, load it in the second player, play it and close the first player.

And do that "ping-pong" for each song you want to play.

Taht way there is no problem to add songs in the track list.

You may take a look at StrumPract project, it uses the "ping-pong" trick:
https://github.com/fredvs/strumpract/releases

But maybe I did not catch what you want to do, if so, please explain it deeper.

Thanks.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Queueing tracks on the fly

Dim Tim
Thank you for the answer, fredvs! :)

Well, it's simple.  For example, I want my program to say "Water level in tank number three is 213 centimeters". So I need to enqueue tracks "water level in tank number", then "three", then "is", then "two hundred", "thirteen", "centimeters".  The tracks are stored as files.  If it's impossible "out of the box" - no problem, I'll implement it.  Sometning like this: a separate thread, which checks status of a player (playing/stopped), then if stopped and there is a track in the queue (updated by the main thread) - pick it and feed into the player.  I just wanted to be sure not to invent a bicycle. :)
Reply | Threaded
Open this post in threaded view
|

Re: Queueing tracks on the fly

fredvs
Administrator
This post was updated on .
Hello Dim Tim.

How do you do to have ""water level in tank number" and all other voices ?
Is it with a voice synthesizer like "espeak" or is it a wav file ?

If it is a wav file (or other sound file), maybe you could take a look at the uos demo "morseTL" (morse translator).

Imho, you could use the same trick for your project.

[EDIT]
 > Sometning like this: ...
             
 Take a look at the "uos_EndProc", that procedure is called at end of the player.
 You must use a other player in the uos_EndProc than the ended player, it is the reason of the "ping-pong" double players.
 
Fre;D

Reply | Threaded
Open this post in threaded view
|

Re: Queueing tracks on the fly

Dim Tim
Hello again. :)

Yes, they are pre-synthesized, high speech-quality tracks, selected and combined as voice messages for operator.  MP3's in fact.  I didn't find a good offline voice synthesizer for my language.

fredvs wrote
If it is a wav file (or other sound file), maybe you could take a look at the uos demo "morseTL" (morse translator).
Thank you, I'll take a look.

Take a look at the "uos_EndProc", that procedure is called at end of the player.
You must use a other player in the uos_EndProc than the ended player, it is the reason of the "ping-pong" double players.
So I cannot just start playing a track in a player, wait when it's finished (checking status periodically) and then play another track in the same player?  OK, I see, a bit different approach.  Ping-pong or juggling. :)
Reply | Threaded
Open this post in threaded view
|

Re: Queueing tracks on the fly

fredvs
Administrator
Dim Tim wrote
 So I cannot just start playing a track in a player, wait when it's finished (checking status periodically) and then play another track in the same player?
Yes, but you will need a timer, methods, it will not be perfectly synchro ( delay to re-create the other track in same player ), etc...

Dim Tim wrote
OK, I see, a bit different approach.  Ping-pong or juggling. :)
If you use "uos_EndProc" you dont need timer but you cannot load a other track in the player that call the "uos_EndProc".
It is the reason of the double ping-pong players.