Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-05-10 08:34:20

simond
Member
Registered: 2016-05-10
Posts: 4

Trigger a mp3 or wav file from within the code

Hi folks, First let me say that I am very excited to find this product and forum and have big plans for the future :-). I am a newbie to Raspberry Pi and REX but a very old hand at PLCs and HMI, I have programmed everything from small industrial machines to power stations and huge mines.
I am building a BMX start gate for a friend and need to control some lights, a solenoid and the start warning audio. Does anyone have any ideas on interfacing to the Pi's on-board audio player to trigger some mp3s or wav files from within the PLC code?
I know that I can use an external audio file player and trigger it with an output pin but obviously it would be better to do it internally!

Thanks, and looking forward to the adventure :-)
Cheers Simon

Offline

#2 2016-05-10 09:19:55

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Trigger a mp3 or wav file from within the code

Hi Simon,
thanks for your kind words!

I have prepared an example on playing sounds on the Raspberry Pi for you. There is a readme file attached. Using an external audio player is of course not the best way to go...

For this application you need the Advanced function blocks which are not included in the demo verison. This is the package you might be interested in: https://www.rexcontrols.com/product/rex … spberry-pi

Jaroslav

Offline

#3 2016-05-10 09:37:49

simond
Member
Registered: 2016-05-10
Posts: 4

Re: Trigger a mp3 or wav file from within the code

Hi Jaroslav, thanks for your prompt reply.
Your solution looks good and I will test it ASAP ?
Regards Simon

Offline

#4 2016-05-10 09:39:54

simond
Member
Registered: 2016-05-10
Posts: 4

Re: Trigger a mp3 or wav file from within the code

Is there any chance that you could customise a package for me with the basic functions and just the one advanced function? As this is for a friend I can't charge him for it and I probably won't use the advanced functions any time soon!
Thanks Simon

Offline

#5 2016-05-10 10:06:26

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Trigger a mp3 or wav file from within the code

Hi Simon,
thanks for asking, I understand your request. No such option is available, though.

If you want to avoid using Advanced function blocks, you can use the SILO function block to save a Boolean variable to a text file and write your own external script for watching this file and playing the sound when the contents of the file change.

Both approaches can be used, it all depends on how much you value your time.

Jaroslav

Offline

#6 2016-05-10 10:14:19

simond
Member
Registered: 2016-05-10
Posts: 4

Re: Trigger a mp3 or wav file from within the code

Thanks Jaroslav, I'll program the rest of it first and see how much patience I have left at the end ?.
I presume your pricing is in US$?
Cheers S

Offline

#7 2016-05-10 12:03:27

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Trigger a mp3 or wav file from within the code

Yes, all our prices are in US$.

Offline

Board footer

Powered by FluxBB