🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #698

Using keyboard to interact with sounds

#698
From: ASFern
Date: Sun, 25 May 2003 03:57
42 lines
3096 bytes
Hi,
Can anyone help me?
I am working on a program to play wave files to a person who is sleeping.
I am using TMediaPlayer in Builder 5.0
This is what the computer should do:
Play a sound for a given number of seconds. The sound is followed by a silence of a given number of seconds.
This pattern of sound-silence is repeated say 10 or 20 times.
Whilst the pattern (sound-silence) is playing the computer operator (person conducting the test)must be able to press one of five keys, say keys A, B, C, D and E.
When the operator presses one of the five keys the computer acknowledges the action and responds to it by doing something like storing the exact time at which the key was pressed (to be printed later).

The print-out for 1 repetition of the pattern should look like this:
Original pattern:
->Sound1 starts @ 8:00:00 PM
Key A was pressed @ 8:00:05 PM
Key B was pressed @ 8:00:14 PM
Key C was pressed @ 8:00:22 PM
->Sound1 ends @ 8:00:33 PM
->Silence starts @ 8:00:34 PM
Key A was pressed @ 8:00:39 PM
->Silence ends @ 8:00:49 PM
1st repetition:
->Sound1 starts @ 8:00:50 PM
Key D was pressed @ 8:00:59 PM
Key E was pressed @ 8:01:19 PM
->Sound1 ends @ 8:01:29 PM
->Silence starts @ 8:01:30 PM
Key A was pressed @ 8:01:39 PM
->Silence ends @ 8:01:49 PM
2nd repetition ...

My problems are:
*If  I play the sound with wait = true (sync) the computer doesn't acknowledge the pressing of a key.
*If I play the sound async the computer stores the key-pressing time correctly but it doesn't wait to finish playing the sequence of sounds so only the last repetition is played.
*If I use my own time-delay method to wait until the sound has finished, the computer doesn't respond to any key-pressing event.

Question: Is there any way to play a sequence of sounds, wait until a sound finishes before another one starts and at the same time force the computer to do something in response to a key-pressing action?
I have seen games that do just that. People press al kinds of keys whilst sounds are playing and the computer responds to those keys whithout stopping the sound. How do you do that?

I would appreciate any help you can give me (books, references, homepages, sections of code, etc)

Augusto
Technical Details
Message-ID: <3ed03f10$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,c52566132c19ab73,start
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2003-05-24 21:00:58 PST
From: "ASFern" <augusto_sf@hotmail.com>
Sender: "ASFern" <augusto_sf@hotmail.com>
Reply-To: "ASFern" <augusto_sf@hotmail.com>
Subject: Using keyboard to interact with sounds
Newsgroups: borland.public.cppbuilder.multimedia
X-User-Info: 203.122.82.14 203.122.82.14    
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3ed03f10$1@newsgroups.borland.com>
Date: 24 May 2003 20:57:04 -0700
X-Trace: newsgroups.borland.com 1053835024 207.105.83.65 (24 May 2003 20:57:04 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail