Determining the length of a sound before playing it
[1/5] from: swhite::ci::bloomington::mn::us at: 31-Aug-2009 12:23
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
[2/5] from: rebolek:gma:il at: 31-Aug-2009 20:54
Hi Steven,
the lenght of the sound is:
(length in bytes) / (sampling frequency) / (sampling resolution in bytes) /
(number of channels) = length of the sound
This is for RAW sounds. For WAV/AIFF add header size, for MP3 you have to
use some MP3 analyzer (I think someone did it in REBOL).
So for example a stereo sound that is 176400 bytes long and is sampled at
44100kHz in 16bit it is:
176400 / 44100 / 2 / 2 = 1 second.
Hope that helps,
Bolek
On Mon, Aug 31, 2009 at 7:23 PM, 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
<<quoted lines omitted: 30>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
***
Boleslav Březovský
http://bolek.techno.cz == http://www.myspace.com/sonyrollinz
***
[3/5] 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.
<<quoted lines omitted: 19>>
> 952-563-4672 (fax)
> steven.white-ci.bloomington.mn.us
--
message ends
[4/5] from: gerardcote:gm:ail at: 1-Sep-2009 7:48
Hi Rosemary,
Quickly visited your web site
Nowadays - it's truely an art to be able to design such a beutifully
minimallist web site presentation that functions so well !!!
Even a child could navigate here - without never loosing his own traces !
Your REBOL links list contains all the main places I know about that
everybody needs to start well ... on the REBOL life road.
Congrats too for your funny swish based anims ...
Regards
Gerard
=======================================
2009/8/31 Rosemary de Dear <rdd-lizzy.com.au>
[5/5] from: semseddinm:bircom at: 2-Sep-2009 16:30
Very nice web site, espacially links are so useful for beginners.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted