Millisecond Forums

play sound in preset interval while running other task?

https://forums.millisecond.com/Topic23975.aspx

By Kim Lien - 3/8/2018

Dear All,

I would be very grateful for advice on how to implement a sound in a preset interval on top of another task. 

I would like to modify the Point Subtraction Aggression Paradigm ( http://www.millisecond.com/download/library/psap/ ).
I would like to play the sound of a bell every 2 or 3 minutes during the task as a reminder of previously explained instructions. 

Does anyone know how to implement the sound on top of the PSAP task? 

Any help would be much appreciated.

Best,
Kim Lien 
By Dave - 3/8/2018

Kim Lien - Thursday, March 8, 2018
Dear All,

I would be very grateful for advice on how to implement a sound in a preset interval on top of another task. 

I would like to modify the Point Subtraction Aggression Paradigm ( http://www.millisecond.com/download/library/psap/ ).
I would like to play the sound of a bell every 2 or 3 minutes during the task as a reminder of previously explained instructions. 

Does anyone know how to implement the sound on top of the PSAP task? 

Any help would be much appreciated.

Best,
Kim Lien 

The most straightforward option would be to:
- Create an audio file (e.g. an MP3) with 2 or 3 minutes of silence and then bell sound at the end.
- Set up a <video> element, with its /loop attribute set to true.
- "Display" the audio during the PSAP blocks

<video remindersound>
/ items = ("2minutesilencethenbell.mp3")
/ loop = true
</video>

<block PSAP>
/ bgstim = (remindersound)
/onblockbegin = [values.PSAPstart = script.elapsedtime]
/onblockbegin = [values.PSAPblocks += 1]
/onblockbegin = [text.letterA.textcolor = black; text.letterB.textcolor = black; text.letterC.textcolor = black]
/onblockbegin = [if (values.restart_total == 1) values.totalpoints = 0]
/onblockbegin = [values.presscounts = 0; values.protection = 0; values.procovationtime = 0;
values.count_optionA = 0; values.count_optionB = 0; values.count_optionC = 0; values.protectiontime = 0;
values.poscolortime = 0; values.negcolortime = 0; values.rt = 0; values.count_provocations; values.lastPFIstealcount = 0]
/ trials = [1 = select]
/stop = [script.elapsedtime >= (values.PSAPstart + (values.blockduration * 60 * 1000))]
/branch = [if (values.number_blocks > values.PSAPblocks && values.restperiod_active == 1) block.rest]
/branch = [if (values.number_blocks > values.PSAPblocks && values.restperiod_active == 0) block.PSAP]
</block>