[REBOL] Re: Determining the length of a sound before playing it
From: rdd:lizzy:au at: 1-Sep-2009 10:20
Dear Steven,
You can see a powerpoint thingy (Narrated Slides) at
http://www.rcmdd.com/rebol/code.html
Alternatively, does this following help you?
Regards, Rosemary
...................................................................
rebol []
;;; thanks to Anton Rolls who helped me with slider
;;; also see Ch. 4 of Olivier and Peter's book.
wavefile: %any.wav
play: func [wavefile][
wave: load wavefile
total-time: 1000 * ((length? wave/data) / ((wave/bits / 8) * wave/channels) / wave/rate)
playing?: true
insert sound-port wave]
main: layout [
button "play" [set-face my-progress 0 play wavefile]
button "stop" [playing?: false start-time: none clear sound-port]
my-progress: progress
box 200x50 pewter rate 1
]
playing?: none
start-time: none
my-event-func: insert-event-func func [face event] [
if event/type = 'time [
if playing? [
either none? start-time
[start-time: event/time]
[elapsed: event/time - start-time
tp: min 1.0 elapsed / total-time
if tp <= 1.0 [set-face my-progress tp]
if tp >= 1.0 [playing?: false start-time: none]]
]] event
]
sound-port: open sound://
center-face main
view main
if error? set/any 'err try [do-events]
[print mold disarm err]
close sound-port
remove-event-func :my-event-func ()
...................................................................
On Tue, 01 Sep 2009 03:23:16 +1000, Steven White <swhite-ci.bloomington.mn.us> wrote:
> REBOL/View Pro will play a sound. I have done that. Does anyone know if it is possible
for a REBOL program to determine the length of a sound before playing it?
>Last night my spouse was struggling with Power Point to make a slide show with background
music. The reason it was such a struggle seemed to be that it was hard to find the settings
to make that happen, and when we found some settings that APPEARED to be the ones that
SHOULD make that happen, it still did NOT happen. Defeated by complexity.
>That got me thinking that it should be logically simple to make a program that does
only one thing, namely, display pictures with background music.
>Determine length of music.
> Obtain list of all pictures in a directory.
> Determine number of pictures.
> Divide length of music by number of pictures, giving duration.
> Start sound playing.
> For each picture,
> Display the picture
> Wait for the duration.
> Quit
> (Details are left as an exercise, as they say.)
>All those steps I have seen done in various sample REBOL scripts, except for the first
one of finding out how long a sound will play.
>Thank you.
>Steven White
> City of Bloomington
> 1800 W Old Shakopee Rd
> Bloomington MN 55431-3096
> USA
> 952-563-4882 (voice)
> 952-563-4672 (fax)
> steven.white-ci.bloomington.mn.us
>
--
message ends