Sound on button press

383 views
Skip to first unread message

Vera

unread,
Apr 14, 2011, 10:27:06 AM4/14/11
to E-Prime
Hi group!

I already got some useful help here about a year ago and everything
worked fine (after a while you kind of get the "hang" of
eprime...;-) ), but now I seem to run into a problem (which actually
seems a very easy-to-do-thing to me, but I haven't figured out a way
to do this yet).

I show participants an image on a slide for 2000 ms

They have to answer by pushing a button whether a target is present
(if there is no target, they shouldn't do anything -> typical go-nogo
task). The image will however stay visible 2000 ms independent of
their answer (every trial = 2000 ms of image).

Now, as this is all taking place in a driving environment, where quite
a lot is going on, I would like to give out a sound once a button is
pushed (but the image still needs to stay there!).

I of course have the option of using a feedback-display, but then I
only get the sound, once the slide disappears.

I really would like to have the sound on button press, just to confirm
the participant "ok, noticed your response" (or not: there will not be
sound in absence of a response).

Any ideas on how to do this?

Thanks in advance!

Greetings,
Vera

liwenna

unread,
Apr 14, 2011, 12:00:09 PM4/14/11
to E-Prime
Hi Vera!

first thing that comes to mind (I think something like this was
discussed here before... ages ago). Create a second, similar, slide
right after the current one you have now but add your sound object to
this slide so that the sound is heard when this slide appears.
Inbetween the two slides place an inline that sets the second slide's
duration to the remainder of the 2000 ms (slide2.duration = 2000 -
slide1.duration) and perhaps add a goto label line to entirely skip
the second slide in case of no response... i.e. "if slide1.resp = ""
then goto jumplabel", place the label called jumplabel after the
second slide .

A quick and dirty suggestion, I hope it helps you, though.

best,

liw

David McFarlane

unread,
Apr 14, 2011, 4:49:58 PM4/14/11
to e-p...@googlegroups.com
Vera,

Agree with liw generally about handling the timing, but I would just
use a SoundOut object instead of a Slide or anything visual, that way
your visual stim will simply remain while your sound plays with no
further fuss.

My own favorite trick for getting timing like this to work is to make
use of the more esoteric SetNextTargetOnsetTime (see the online
E-Basic Help). On your stimulus Slide (let's call it StimSlide), set
End Action to (terminate) and leave its Duration at 2000. Follow
that with an inline, and then a SoundOut object (let's call it
FeedbackSound) and set its Duration to 2000. In the inline between
StimSlide and FeedbackSound, just put

SetNextTargetOnsetTime StimSlide.OnsetTime

Now, whenever your program gets to FeedbackSound, it will think that
FeedbackSound was supposed to start at the same time as StimSlide and
then end 2000 ms later, i.e., 2000 ms after StimSlide started. Isn't
that slick? And it required no computation.

Admittedly, using tricks like this does rely on some deeper
understanding of the inner hidden workings of E-Prime, and I don't
have time to explain all that just now. Also, your subject may get a
short beep even for no response, so you may have to work out a little
more code to get everything to work the way you want (see liw's
further discussion earlier).

-- David McFarlane, Professional Faultfinder

Vera

unread,
Apr 15, 2011, 11:58:33 AM4/15/11
to E-Prime
Hi Liwenna, hi David,

I tried both of your solutions (and actually encountered problems with
both of them), but they gave me some useful ideas to actually solve my
problem and I would like to post the solution I found for future
users. :-)

To your SetNextTargetOnsetTime David, as I had to set the End Action
to (terminate), the slideimage would actually disappear (which is not
what I wanted, I just wanted to have a sound to confirm button press
WITHOUT the slideimage disappearing).

As for your solution Liwenna, using 2 identical slides of which the
second one with a sound, I actually found a small problem in the
inline that you proposed. It turns out that "slide.duration" is
actually referring to the duration you set for the slide (e.g. 2000
ms). If you then do
slide2.duration = 2000 - slide1.duration basically you get 2000 - 2000
= 0. :-)

The correct way (for me at least) to do it is:
slide2.duration = slide1.duration - slide1.RT (e.g. 2000 - 1345 = 655
= duration slide2)
(and make sure to put the duration of slide2 on 0 (zero) ms).

Then it works perfectly! :-)

I also would like to thank you, David for your hint towards
SetNextTargetOnsetTime StimSlide.OnsetTime. Although I couldn't use it
this time, it might be useful in the future.

In other words: thanks to both of you! :-)

Have an nice weekend!

Greetings,
Vera

David McFarlane

unread,
Apr 15, 2011, 12:32:10 PM4/15/11
to e-p...@googlegroups.com
Vera,

Thanks for posting back with your solution...

At 4/15/2011 11:58 AM Friday, you wrote:
>To your SetNextTargetOnsetTime David, as I had to set the End Action
>to (terminate), the slideimage would actually disappear

Um, no, not if you have Clear After set to No, which is the
default. I had just assumed that you had Clear After set to the
default value of No. With Clear After set to No, a visual stimulus
remains visible until some other visual stimulus comes to replace it,
which is almost always a better way to do things (i.e., why have a
stimulus do the extra work of clearing itself when the next stimulus
would cover it anyway?). You must have set Clear After to Yes at
some point, try setting it to No and see whether or not I know what I
am talking about :).

Regards,

Vera

unread,
Apr 17, 2011, 6:27:19 AM4/17/11
to E-Prime
David,

Thanks for replying, I will have a look at that tomorrow at work. I
was already wondering why you would write that, knowing that it would
terminate my action. Ok, I have to check the "clear after set" option.
Thanks for pointing that out! :-)

Greetings, Vera
Reply all
Reply to author
Forward
0 new messages