Running Visual and Auditory Stimuli Simultaneously

1,311 views
Skip to first unread message

Nicolette

unread,
Dec 10, 2012, 2:42:57 PM12/10/12
to e-p...@googlegroups.com
Hi,
 
I am *very* new to EPrime, so I am looking for some guidance and have been unable to find an answer to my question in any tutorial I have come across.
 
I am running an n-back task in EPrime 2.0 (no problems making that), but I would also like auditory stimuli to play "overhead" of the ongoing task. I have been unable to figure out how to do this. So, a 7-min audio file I want running continuously while my participant is engaged in doing the n-back. Almost like I don't want my "sound" to know what my "image" is doing.
 
If anyone could offer me some guidance (and not make it too technical!), I'd really appreciate it.
 
Thanks

David McFarlane

unread,
Dec 10, 2012, 2:55:48 PM12/10/12
to e-p...@googlegroups.com
Try the following: Simply add a SoundOut (or Slide with
SlideSoundOut if you prefer) at the point where you want to start
playing your background sound file. Set Duration to 0 (if you do not
want to hold up the program), and set StopAfter to No (as you would
learn in my E-Prime course). Now your sound will continue playing
even after the SoundOut ends. For good measure you should also set
the sound's End Action to (none).

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (https://twitter.com/EPrimeMaster)

/----
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours, so make full use of
it. 3) In addition, PST offers several instructional videos on their
YouTube channel (http://www.youtube.com/user/PSTNET ). 4) If you do
get an answer from PST staff, please extend the courtesy of posting
their reply back here for the sake of others.
\----

Paul Groot

unread,
Dec 10, 2012, 6:03:00 PM12/10/12
to e-p...@googlegroups.com
Hi,

I think David described the most straightforward method to do this, so you should try that first. I know there is also an alternative method, which I used a few years ago. I don't remember if I had to work around any problems with the built-in sound objects, but here is what I did:

I inserted the following script in the global user script section. The inserted script uses low-level windows functions to play an audio file.


' Sound suppport by using the windows multimedia library directly (i.e. bypassing EPrime)
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

' Some constants for playing sounds
Const SND_LOOP = &H8        ' loop the sound until next sndPlaySound
Const SND_ASYNC = &H1       '  play asynchronously
Const SND_NOSTOP = &H10     '  don't stop any currently playing sound
Const SND_SYNC = &H0        '  play synchronously (default)
Const SND_NODEFAULT = &H2   '  silence not default, if sound not found
Const SND_PURGE = &H40      '  purge non-static events for task

' Remarks
' If the specified sound cannot be found, sndPlaySound plays the system default sound.
' If there is no system default entry in the registry or WIN.INI file, or if the
' default sound cannot be found, the function makes no sound and returns FALSE.
'
' The specified sound must fit in available physical memory and be playable
' by an installed waveform-audio device driver. If sndPlaySound does not find
' the sound in the current directory, the function searches for it using the
' standard directory-search order.

' Plays a sound from filename ans optionally wait until ready.
Function PlaySoundFile(ByVal filename As String, bWaitReady as boolean) as Boolean
  PlaySoundFile = sndPlaySound(filename, iif(bWaitReady, SND_SYNC, SND_ASYNC) )
End Function

' Plays a repeating sound from filename.
Function RepeatSoundFile(ByVal filename As String) as Boolean
  RepeatSoundFile = sndPlaySound(filename, (SND_LOOP Or SND_ASYNC) )
End Function

Sub StopSoundFile()
  dim ret as boolean
  ret = sndPlaySound(ebNullString, SND_SYNC)
End Sub

Then call one of the the Play functions somewhere in your script to start playing the music:

if (Not PlaySoundFile("media\\classic.wav", false)) then
    MsgBox "Cannot play sound"
end if


And simply call StopSoundFile to stop at any point. Note that this was used on a windows XP machine, so I'm not sure if it works on the latest Windows releases.

Best
Paul



--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-p...@googlegroups.com.
To unsubscribe from this group, send email to e-prime+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/e-prime/-/GRyKaY8V3oIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages