On Saturday, 7 January 2017 16:37:37 GMT Ralph Corderoy wrote:
> OK, I don't get the detail, but here's the current on-the-quarter code.
>
> while quarter_rings > 0:
> os.system('mpg321 -g 100 -q ./mp3/Two_Chimes.mp3')
> time.sleep(interval)
> quarter_rings -= 1
>
> time.sleep(march_delay)
> os.system('mpg321 -g 20 -q ./mp3/Wedding_March.mp3')
> time.sleep(changes_delay)
> os.system('mpg321 -g 100 -q ./mp3/amersham.mp3')
>
> os.system() is forking a new process, that creates a copy of your Python
> program, has that child exec mpg321 thus overlaying /usr/bin/python with
> /usr/bin/mpg321, and all the while the parent that did the fork waits
> for the child to exit.
>
> I think you're saying you want to kick off one tune and then, whilst
> that's still playing, kick off another a little later? Append ` &' to
> your mpg321 invocation so the /bin/sh running your os.system string puts
> the program in the background and exits, allowing os.system to return.
Yes. I was planning to do something like that if I found it was necessary.
It is a little more complicated than you have outlined, because when I do the
chimes, they need to be one after the other and not on top of each other ;-)
Likewise for the Wedding sequence. The main complication is the chimes, which
must continue to play even when the MP3 Player is doing the background music.
> More complicated needs can probably be satisfied with
> https://docs.python.org/2/library/subprocess.html instead of os.system.
Hopefully I won't need it, but now I have working hardware, I can really get
down to the coding side of things.
--
Terry Coles
--
Next meeting: Bournemouth, Tuesday, 2017-02-07 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
New thread: mailto:[email protected] / CHECK IF YOU'RE REPLYING
Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR