playing SoundIn audio within the same trial

Alon Hafri ahafri at gmail.com
Thu Jul 14 18:44:59 UTC 2011


Hi David, first of all thanks for your quick reply and insights! I
will post this to PST support as well and see what they say.

In the meantime, I messed with the experiment a bit more and I
realized that the problem lies not with calling ".SaveToFile" twice in
the same trial (once in my InLine, once unavoidably at the end of the
procedure from automatic code inserted into the script by E-Prime).
Instead it has something to do with my trying to save a file with the
same name as the one I just PLAYED with the SoundOut object earlier in
the trial. When I removed the SoundOut object so the captured sound
file was no longer played, there were no errors (even when .SaveToFile
was called twice, both times with the same filename).

So maybe the played file is not closed completely, and so is not
accessible to be written over by the .SaveToFile method and produces
the "Writing captured audio to file failed" error. Maybe you have some
ideas on how to make sure the file is closed completely after it is
played?

Also, let me clarify things in response to what you wrote:

> >2) Was there an easier way to do this?
>
> Again, I have no experience yet with SoundIn.  But I would guess that
> instead of using the @Auto automatic file naming you could generate
> file names yourself in your code and that might avoid the "write
> fail" problem.  Since you already use inline code to handle playing
> the captured audio, generating your own file names should add no
> extra burden.  Sometimes all that extra "automation" just gets in the
> way, I like to turn it all off and supply my own code.
>

I didn't try using code to generate the name, but I did look at the
code used to automatically generate the file, and it generated a
string with the experiment name, subject #, session #, SoundIn object
name, and finally a unique index number, and then set the
SoundCaptureBuffer.Filename equal to the string, like this:

strSoundIn1CaptureName = ""
If c.AttribExists("Experiment") = True Then strSoundIn1CaptureName =
strSoundIn1CaptureName & c.GetAttrib("Experiment") & "-"
If c.AttribExists("Subject") = True Then strSoundIn1CaptureName =
strSoundIn1CaptureName & c.GetAttrib("Subject") & "-"
If c.AttribExists("Session") = True Then strSoundIn1CaptureName =
strSoundIn1CaptureName & c.GetAttrib("Session") & "-"
strSoundIn1CaptureName = strSoundIn1CaptureName & SoundIn1.Name & "-"
strSoundIn1CaptureName = strSoundIn1CaptureName &
CStr(SoundIn1SoundCaptureBuffer.GetNextCaptureIndex) & ".wav"
SoundIn1SoundCaptureBuffer.Filename = strSoundIn1CaptureName

So I could have done something similar in an InLine before the SoundIn
object was executed. But as seen above, the captured filename is
actually not the problem, but playing the file and then trying to save
over that file is. Also, the .SaveToFile call at the end of the
procedure is unavoidable as far as I can tell -- it is automatically
generated by E-Prime whenever you have a SoundIn object in your
experiment.

> SoundOut file names are actually handled by an associated SoundBuffer
> object, using the .Filename property and .Load method.  See the
> SoundBuffer topic in the EB Help, and look at the code that E-Studio
> generates for any SoundOut object.
>

Interesting -- I tried doing this through code to avoid having to use
an Attribute for this purpose, but couldn't figure out how to actually
modify and call methods of a SoundBuffer object without having a
SoundOut object already exist. And when I tried modifying the filename
in an InLine right before the SoundOut object was executed, it
defaulted to the filename as set in the properties window of the
object in the E-Studio user interface.

Perhaps there is a way to do it without any SoundOut object, or
alternatively a way to change the filename in an InLine so it remains
changed throughout the trial?

Thanks again,
Alon

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list