audio files and delays

1,931 views
Skip to first unread message

Conrad

unread,
Aug 20, 2009, 1:46:22 PM8/20/09
to E-Prime
Hi all,

I am developing a task which includes audio files. My samples loop
pretty fast. This is how it looks.
Slide 1: 350 ms with audio clip (1 of 12 audio files)
Slide 2: 50 ms of black screen buffer
Slide 3: 600 ms with audio clip (same audio file every time); collect
response
Slide 4: 100 ms of black screen buffer.
Repeat 2500 times.

I have noticed that i get a pretty significant delay 150 ms with each
audio file. This delay seems to grow quite a bit by the end of the
task to 500 ms.

I've played around with the pre-release, audio buffer time, and
streaming vs. buffered audio files and I haven't found a combination
where the audio file will completely play and I don't have a massive
delay.

Anybody have any thoughts or suggestions?

Thanks,
Conrad
Madison, WI

David McFarlane

unread,
Aug 20, 2009, 2:48:06 PM8/20/09
to e-p...@googlegroups.com
Conrad,

Since you mention streaming mode, you must be using EP2, which
answers the first question. Next question, are you running this
under Windows XP, or Vista?

-- David McFarlane, Professional Faultfinder

Conrad

unread,
Aug 21, 2009, 12:22:29 PM8/21/09
to E-Prime
I am running XP. I see from other discussions streaming is the way to
go.

I've tried changing the SoundDeviceOutput properties but that didn't
help.

I have changed the duration of the slide to multiples of the refresh
rate and that helped a little.

Next up for my game plan is to cache these audio files, if I can
figure out how to do that.

Thanks for the help!

Conrad

unread,
Aug 24, 2009, 12:13:07 PM8/24/09
to E-Prime
I have not figured out how to cache. Getting the sample script from E-
Prime is taking longer than I hoped. Does anybody have it?

So this issue is unresolved. Any other thoughts?

Thanks again.
Conrad

Peter Quain

unread,
Aug 24, 2009, 12:41:56 PM8/24/09
to e-p...@googlegroups.com

there's probably some much simpler way to do this that i don't know
about, but you could do it with code.

Need to


Dim mySoundBuffers As SoundBufferCollection
Set mySoundBuffers = new SoundBufferCollection
mySoundBuffers.Add sBuffer1, , ,
mySoundBuffers.Add sBuffer2, , ,
mySoundBuffers.Add sBuffer3, , ,


'Spin through the collection and debug.print the name

Dim r As RteObject

Dim nIndex As Long

For nIndex = 1 To newCollection.Count

Set r = newCollection.Item(nIndex)

If Not r Is Nothing Then

Display.Canvas.Text 5, nIndex * 20, "Collection object " &_

"# " & nIndex & ": " & r.Name

End If

Next 'nIndex

Peter Quain

unread,
Aug 24, 2009, 12:57:19 PM8/24/09
to e-p...@googlegroups.com


Whooops .. thought I was clicking save, not send... better finish
this now, then :)

there's probably some much simpler way to do this that i don't know
about, but you could do it with code.

Need to do something with SoundBuffer I think ... no idea whether
this will work, but might be one track to look at for preloading
audio info into memory.

'make a collection of soundbuffers
Dim mySoundBuffers As SoundBufferCollection
Set mySoundBuffers = new SoundBufferCollection

'add buffers to hold as many audio files as needed for a trial
mySoundBuffers.Add sBuffer1, , ,
mySoundBuffers.Add sBuffer2, , ,
mySoundBuffers.Add sBuffer3, , ,

'set the file for the buffer to hold
sBuffer1.FileName = "myWavFile-1.wav"
sBuffer2.FileName = "myWavFile-2.wav"
sBuffer3.FileName = "myWavFile-3.wav"

'load the buffer into memory
sBuffer1.Load
sBuffer2.Load
sBuffer3.Load
.....
'play the appropriate file
If cond = "whatever" Then
sBuffer1.Play
ElseIf cond = "another" Then
sBuffer2.Play
Else
sBuffer3.Play
End If

~Peter

Michiel Spape

unread,
Aug 27, 2009, 9:12:33 AM8/27/09
to e-p...@googlegroups.com
Hi Conrad et al.,
I've worked quite a bit with audio files, and pre-buffering in the style of Peter is usually the way to go for me (never used the .add and some differences but this looked very neat). However, I do not think this (problem) should be happening in the first place, unless you use a sort of manual loop (or jump-label, for instance). Do you have these 2500 repeats in a loop, or using many sequences? The thing is that E-Prime should always pre-buffer sound-files if used in a slide (in e-basic help: "E-Studio automatically generates calls to SoundBuffer.Load for the buffer identified as SoundOut.ActiveBuffer for each SoundOut object in the experiment"), and although I have never believed E-Prime can do what NO professional music programme, to my knowledge, can (i.e. play sound with 0 latency) even with sub-quality soundcards (e.g. those with ASIO drivers) and directx engine, the latency should not be... growing. This typically suggests a memory or processing 'leak', such as when you leave response collections unfinished, etc. I therefore suggest rather than looking at the sound, to take a look at your design and programming (of the rest).
To give you some indication: I'm currently doing a tapping tasks which should involve about 1200 taps that are to be made in sync with tone (i.e. subject hears tones at about 1 Hz and responds with the spacebar or whatever at similar Hz, trying to minimise tap-to-response asynchrony). So I do just about what Peter suggested (i.e. preload with script, play with script). I find that the onset of the playing is pretty accurate, certainly not shifting, but sometimes, my 50 ms stimuli are cut off (easily detectable as they have a fade-in and out, so that you hear a tick if the fade-in is not played correctly. I've recreated this design in several ways (such as described, or doing buffer.load once, long before the sound is played, etc), more importantly also using normal sound-objects (in or not in slide-objects), but the cut-offs as described above is always present. Anyway, the quality of the sound is not crucial to my experiment, nor is the timing as such as long as these errors are equally distributed over conditions, but just a (sorry) long-winded story to say that I'm sure that buffering errors occur... but they should not be as you describe (growing).

Should you find no problematic issue with the rest of your design, I have one remaining tip: make 1 audio file with silences and samples pre-mixed, instead of
> > >Slide 1: 350 ms with audio clip (1 of 12 audio files)
> > >Slide 2: 50 ms of black screen buffer
> > >Slide 3: 600 ms with audio clip (same audio file every time); collect
> > >response
> > >Slide 4: 100 ms

1. make soundbuffer etc as Peter described, make it at least 1101 ms
2. fill the buffer with one file: 350 ms of audio clip, followed by 50 ms of silence, followed by 600 ms of audio clip, followed by 100 ms of silence, load and
3. play the file (it will keep playing following this command)
4. show slides 1 -4 with whatever you want.

Sometimes this method takes quite a bit of time and is, granted, extremely inflexible. But, download a trial version of CoolEdit (these days called adobe audition), and you will be able to get your silences and sounds beyond millisecond accurate: if your system plays at 44.1 Khz, timing accuracy should be correct at about 0.02 ms level.

Cheers,
Mich


Michiel Spapé
Research Fellow
Perception & Action group
University of Nottingham
School of Psychology
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

Conrad

unread,
Aug 27, 2009, 11:36:28 AM8/27/09
to E-Prime
Thanks Michael, Peter, and David.

I didn't have a loop or a jump.

My problem had a much simpler solution for me, use E-Prime 1! The
word on the street is EP2 is currently a bit buggy with audio files.
I wrote up an identical program in EP1 and I got my delays down to an
average of 7 or 8 ms per slide, which is pretty dang good.

Two other tips to share is adding a pre-release to the slide prior to
the audio slide. The pre-release duration is the same as the slide
duration. Also I closed other programs before running the task.
That's it. No inlines necessary.

Conrad


On Aug 27, 8:12 am, Michiel Spape <Michiel.Sp...@nottingham.ac.uk>
wrote:
Reply all
Reply to author
Forward
0 new messages