I hope you've found a solution by now but thought I would chime in. I'm using E-prime 2.0.
I'm working on an EEG study using the Libet tasks, and we have programmed an auditory task in which participants hear a beep after the clock starts running. We have programmed the beep to occur at a random interval between 2.55s and 7.65s after the clock begins.
Here's what we have in the first inline, which is placed as the first object in the TrialProc (it comes up well before the clock is displayed). That way, E-Prime preloads the sound file well before having to play it.
Dim FeedbackBeep As SoundBuffer
Dim GenericSoundBufferInfo As SoundBufferInfo
GenericSoundBufferInfo.MaxLength = 100
GenericSoundBufferInfo.VolumeControl = CLogical("Yes")
GenericSoundBufferInfo.PanControl = CLogical("No")
Set FeedbackBeep = Sound.CreateBuffer(GenericSoundBufferInfo)
FeedbackBeep.Filename = "beep.wav"
FeedbackBeep.Load
FeedbackBeep.Volume = -1000 'Buffer Volume goes from -10000 to 0
Note that you need to include the file extension (.wav) and have the file in the same folder as the experimental file.
Later, at the appropriate place in a different inline code, we have this to play the file, record when it was played, and have it send a trigger:
FeedbackBeep.Play
BeepTime = Clock.Read
WritePort &H4020, 64
The first tricky part is getting it at the right place in the code. Our code uses looping to show a rotating clockhand, so it took some time figure out where to put the .Play command. The second tricky part is getting it to play at the precise times you want. We called on a part of the code that displayed the clockhand (in reference to tick marks) to determine when to play it (i.e. after the clockhand had passed between 153 and 459 tick marks). I would share that, but it wouldn't make sense without seeing the entirety of our code.
In your case, you may be able to get the file to play by inserting the .Play command in the correct location. If you are randomly varying the offset time between 300ms and 250ms within one session, you'll need to figure out a way to have it anchor to some other event (probably the button press) in your code and randomly offset either 250ms or 300ms from it. To do this, you may have to define an additional variable at the beginning (i.e. a random time of 250ms or 300ms) and then reference it later on when you are anchoring to another event. For example, we used this code in our first inline to define our random interval between tick marks...
Dim ran3 As Integer
ran3 = Random (153, 459)
...and then we had to use this when we anchored to the code relating to the clockhand.
On the other hand, if you have a set duration during one session (either 250ms OR 300ms but not both) I think you can find a way around this. If you can find where to correctly insert the .Play command such that it plays when the clock ends, you can just use a file which has a 250ms or 300ms period of silence at the beginning before it plays the beep. Set up one experimental file with the 250ms period of silence and one with the 300ms period.
You might also check out a topic I posted in this group before I reached my solution. I tried a few different things before someone helped me figure it out:
Hope this helps!
Paul