// Check file objects // This example shows how to program a simple experiment in Exper: // A sample sound is played at a position choosed randomely in a set of // predefined positions (front, back, left, right). This is done 5 times. // After each sound play, the operator enter the subject answer by typing // "f", "b", "l" or "r". The system plays a bip according to the subject // answer. The answer and reaction time are recorded to a file // definition of the file object where will be stored the output of the // experiment define object f = file set f name = "listing.exper" // definition of the sound player define object p = sound_player set p config = "/h/pimprenelle/imagis/boissieux/SRC/EXPER/sound.cfg" // definition of 3 different sound objects define object bip_true = sound_source set bip_true file = "/h/pimprenelle/imagis/boissieux/DATA/SOUNDS/bip_true.aifc" set bip_true position = (0,1,0) set bip_true level = 3.0 set bip_true player = p define object bip_false = sound_source set bip_false file = "/h/pimprenelle/imagis/boissieux/DATA/SOUNDS/bip_false.aiff" set bip_false position = (0,1,0) set bip_false level = 3.0 set bip_false player = p define object sample = sound_source set sample file = "/h/pimprenelle/imagis/boissieux/DATA/SOUNDS/bip.aiff" set sample position = (1,1,1) set sample level = 3.0 set sample player = p // definition of a keyboard object for entering answers define object k = keyboard // definition of a string object to store answers define string ok = "" // open file for writing call f open start sound player call p start // definition of floats to store the number of trials and times define float count = 1 define float b = 0 define float e = 0 // experiment loop for 5 do choose random() in begin set sample position = (0,0,-2) set ok = "f" end begin set sample position = (0,0,2) set ok = "b" end begin set sample position = (-2,0,0) set ok = "l" end begin set sample position = (2,0,0) set ok = "r" end end // write number of trial in file call f write "sample #" call f write count call f writeline // play sample sound call sample play // record start time set b = time() // wait for the answer to be typed on the keyboard call k input // record end time set e = time() // write typed answer and reaction time in file call f writeline "given answer" string k key call f writeline "reaction time" e - b // process answer if (string k key == ok) then // play ding call bip_true play // write result in file call f write "right" // wait for 3 seconds wait(3) else // play dong call bip_false play // write expected result in file call f write "wrong, it was" ok // print expected result to screen print "it was " ok // wait for 3 seconds wait(3) end // increase trial number call f writeline set count = count + 1 end stop sound player call p stop close file call f close quit