Hi, I am a new user of E-Prime 3 and I am not good at writing a script to run it. So, my question is how to achieve the function of randomly displaying auditory stimuli using the inline object. In my design, there are two types of sounds: one is ba3 and the other is ba3_creak. Ba3 will be displayed 15 times at the initial part of the program. Then, ba3 and ba3_creak appear alternately. The number of ba3 preceding ba3_creak (it can not be repeated) ranges from 5 to 9 with an equal probability of occurrence (20%) for each number. (I guess you may know this design. Yes, it is an oddball paradigm.) I have written one, but it doesn't work when the program runs. I checked the data file, the program still loaded the list object to present the stimuli. Below is my script. I hope someone can help me to fix the bugs. Thanks.
----------------------------------------------------Script----------------------------------------------------------------
' Define constants and variables
Const TOTAL_BA3_INITIAL = 15
Const TOTAL_BA3_REPEAT = 300 - TOTAL_BA3_INITIAL
Const TOTAL_BA3_CREAK = 100
Const INITIAL_REP_BA3 = 15
Dim ba3(TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT) As String
Dim ba3_creak(TOTAL_BA3_CREAK) As String
Dim combinedList(TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT + TOTAL_BA3_CREAK) As String
Dim idx As Integer
idx = 1
' Initialize ba3 and ba3_creak lists
Dim i As Integer
For i = 1 To TOTAL_BA3_INITIAL
ba3(i) = "ba3.wav"
Next i
For i = 1 To TOTAL_BA3_REPEAT
ba3(TOTAL_BA3_INITIAL + i) = "ba3.wav"
Next i
For i = 1 To TOTAL_BA3_CREAK
ba3_creak(i) = "ba3_creak.wav"
Next i
' Add initial 15 ba3.wav
For i = 1 To INITIAL_REP_BA3
combinedList(idx) = "ba3.wav"
idx = idx + 1
Next i
' Define repetition frequencies and initialize counts
Dim frequencies(5) As Integer
Dim freqCount(5) As Integer
frequencies(1) = 5
frequencies(2) = 6
frequencies(3) = 7
frequencies(4) = 8
frequencies(5) = 9
For i = 1 To 5
freqCount(i) = 0
Next i
Dim maxCount As Integer
maxCount = TOTAL_BA3_REPEAT / 5 ' Equal distribution
' Add ba3.wav and ba3_creak.wav alternately
Dim ba3_index As Integer
ba3_index = TOTAL_BA3_INITIAL + 1
Dim ba3_creak_index As Integer
ba3_creak_index = 1
While idx <= (TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT + TOTAL_BA3_CREAK)
' Add ba3.wav with specified frequencies
If ba3_index <= (TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT) Then
' Select a frequency randomly, ensuring equal distribution
Do
Dim randomIdx As Integer
randomIdx = INT(RND * 5) + 1
Loop While freqCount(randomIdx) >= maxCount
Dim freq As Integer
freq = frequencies(randomIdx)
freqCount(randomIdx) = freqCount(randomIdx) + 1
' Add ba3.wav to the list with the selected frequency
Dim j As Integer
For j = 1 To freq
combinedList(idx) = "ba3.wav"
idx = idx + 1
If idx > (TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT + TOTAL_BA3_CREAK) Then Exit For
Next j
ba3_index = ba3_index + freq
End If
' Add ba3_creak.wav
If ba3_creak_index <= TOTAL_BA3_CREAK Then
combinedList(idx) = "ba3_creak.wav"
idx = idx + 1
ba3_creak_index = ba3_creak_index + 1
End If
Wend
' Output the sequence for playback
For i = 1 To (TOTAL_BA3_INITIAL + TOTAL_BA3_REPEAT + TOTAL_BA3_CREAK)
PRINT combinedList(i)
Next i
Comments
0 comments