Home   Archive   Permalink



Playing one sound after another

I am making a little helper program for quickly sampling sound files, like in the windows/media folder so I can find out what the windows sounds sound like. I build a list of wav files, show the list, and when I pick a file I then play it. The code for the window and the code that is executed when a wav file is picked is shown below. It all works IF...I plod through the files slowly. But if I try to click through them too quickly, the program crashes in this manner:
** Access Error: Cannot open sound
** Where: SOUND-LAUNCH
** Near: SOUND-PORT: open sound://
insert SOUND-PORT
>>
    
Does anyone know what I might be doing wrong?
    
Thank you.
    
;; -- Function to play a sound.
SOUND-LAUNCH: does [
     wait 0
     SOUND-PORT: open sound://
     insert SOUND-PORT load to-file SOUND-LIST/picked
     wait SOUND-PORT
     close SOUND-PORT
]
;; -- Build and view main window.
;; -- SOUND-NAMES is a list of file names built in code not shown here for clarity.
MAIN-WINDOW: layout [
     across
     banner 'Wav Demo Assistant' font [shadow: none]
     return
     SOUND-LIST: text-list 300x700 data (SOUND-NAMES)
         [SOUND-LAUNCH]
     return
     button 'Quit' [quit]
]
view MAIN-WINDOW
    


posted by:   Steven White     28-Jul-2016/12:48-7:00



R E B O L []
    
SOUND-PORT: open sound:// ;open it here
    
SOUND-LAUNCH: does [
     close SOUND-PORT ;because you have to close it before you open it, otherwise....
     open SOUND-PORT
     wait 0
     insert SOUND-PORT load to-file SOUND-LIST/picked
     wait SOUND-PORT
     close SOUND-PORT
]
;; -- Build and view main window.
;; -- SOUND-NAMES is a list of file names built in code not shown here for clarity.
MAIN-WINDOW: layout [
     across
     banner "Wav Demo Assistant" font [shadow: none]
     return
     SOUND-LIST: text-list 300x700 data [%frog.wav %racoon.wav %turkey.wav]
         [ SOUND-LAUNCH]    
     return
     button 'Quit' [quit]
]
view MAIN-WINDOW
;wav files from soundbible.com

posted by:   Al     31-Jul-2016/2:12:26-7:00