Play simultaneous sounds on Pi4b via XOJO

I am trying to simulate an elevator as an art installation. As the sound function in XoJo doesn’t seem to work with Pi, is there a way to play two different sound files at the same time on the Pi4 via Xojo? For example, elevator music with sound effects overlaid. Thanks for any help.

Matt

You can use the shell cass to run omxplayer

Thanks for the suggestion. I tried that, and was able to play one sound file, but the XOJO program was then unresponsive until the sound stopped playing. I was unable to play a second file at the same time as the first.

Matt

Use the shell.executemode = shell.executemodes.interactive

you’ll have full control of the sound/video with omxplayer.
You can have multiple shell class instances at the same time, so mutiple sounds.

https://documentation.xojo.com/api/os/shell.html#shell-executeMode

Interactive means; keep running so that you can send control characters and data (string) to the shell while it’s running using shell.write() or shell.writeline()
This way to can send; stop, pause, start, volume etc…

1 Like

For lightweight but powerful audio playback you could use sox ‘play’ command:
https://manpages.debian.org/jessie/sox/play.1.en.html

sudo apt-get install sox
you may also need for mp3 playback:
sudo apt-get install libsox-fmt-mp3

1 Like

Thanks Derk and Ian.

Now I have something to try. Was completely stuck…

Matt

I was able to use multiple shells with Omxplayer to play simultaneous music files! Thanks Derk for getting me going again.

A further question; How do I send “key bindings” via that same shell to change volume, etc.?

Matt

1 Like

Send the ascii codes for the keys using shell.writeline

Still not getting the results I want. For example “p” should pause/resume playing in Oxmplayer. I tried:

s = new shell
s.ExecuteMode = Shell.ExecuteModes.Interactive
s.Execute (“omxplayer /home/pi/Desktop/Music/‘03 Just Like Heaven 1.mp3’”)

Which starts playing the song. Then tried to pause it this way:

s.writeline (Chr(112)) //“p” character

And nothing happens…

Can you give me an example of how to use the write-in command for this?

Thanks again for your help

try:

s = new shell
s.ExecuteMode = Shell.ExecuteModes.Interactive
s.Canonical = True // ALLOW CONTROL characters to be send, important!
s.Execute("/usr/bin/omxplayer ""/home/pi/Desktop/Music/‘03 Just Like Heaven 1.mp3""")
s.WriteLine("p") // pause you may get a datavailable event giving you some info about the state of 
// omxplayer.

you need the FULL shell path to omxplayer and to the mp3 file in quotes (if it has spaces)

Docs: