Millisecond Forums

How to let a sound continue after a response?

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

By Ang - 4/12/2022

Hi everyone,

I am trying to program a motor sequence task where the participant responds to visual+audio cues by pressing the corresponding button on the keyboard.
I want participants to be able to respond as soon as the stimulus is starts, but I want each stimuli to be presented for the complete duration (~100 ms).
Currently, if the participant responds before the sound has completed, the sound gets clipped.
I've tried the 'playthrough' = false attribute - but that's not what I'm after.
I've also adding a 'posttrialpause', but my sound still gets cut off after the response.

Does anyone have any ideas? I have attached code for my sounds and the trial where I am trying to presenting the sounds.

Cheers,

An

<sound play_sound>
/ items = ("C4_100ms.wav", "D4_100ms.wav", "E4_100ms.wav", "F4_100ms.wav")
/ select = values.sound_position
/ playthrough = true
/ volume = -2000
</sound>

<trial experimental_trial_3>
/ ontrialbegin = [
    if (values.condition_label == "Bimodal_2" && values.trial_count == 1) {values.trial_type = "Random"; values.item_position = list.random_sequence.nextvalue; values.sound_position = values.item_position}
    else if (values.condition_label == "Bimodal_2" && values.trial_count > 1) {values.trial_type = "Learning"; values.item_position = list.bimodal_2_sequence.nextvalue; values.sound_position = values.item_position};
    
    if (values.item_position == 1) {text.box1.textbgcolor = red}
    else if (values.item_position == 2) {text.box2.textbgcolor = red}
    else if (values.item_position == 3) {text.box3.textbgcolor = red}
    else if (values.item_position == 4) {text.box4.textbgcolor = red}
    ]
/ stimulustimes = [0 = box1, box2, box3, box4, play_sound; 100 = grey_box1, grey_box2, grey_box3, grey_box4]
/ beginresponsetime = 0
/ validresponse = (parameters.response_1, parameters.response_2, parameters.response_3, parameters.response_4)
/ iscorrectresponse = [
    return ((values.item_position == 1 && trial.experimental_trial_3.responsetext == parameters.response_1) ||
    (values.item_position == 2 && trial.experimental_trial_3.responsetext == parameters.response_2) ||
    (values.item_position == 3 && trial.experimental_trial_3.responsetext == parameters.response_3) ||    
    (values.item_position == 4 && trial.experimental_trial_3.responsetext == parameters.response_4))
    ]
/ ontrialend = [
    if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 0} // correct
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 1} // incorrect button
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 2} // incorrect and too slow
    else if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 3}; // correct but too slow
    ]
/ branch = [trial.experimental_trial_4]
</trial>
By Dave - 4/13/2022

Ang - 4/13/2022
Hi everyone,

I am trying to program a motor sequence task where the participant responds to visual+audio cues by pressing the corresponding button on the keyboard.
I want participants to be able to respond as soon as the stimulus is starts, but I want each stimuli to be presented for the complete duration (~100 ms).
Currently, if the participant responds before the sound has completed, the sound gets clipped.
I've tried the 'playthrough' = false attribute - but that's not what I'm after.
I've also adding a 'posttrialpause', but my sound still gets cut off after the response.

Does anyone have any ideas? I have attached code for my sounds and the trial where I am trying to presenting the sounds.

Cheers,

An

<sound play_sound>
/ items = ("C4_100ms.wav", "D4_100ms.wav", "E4_100ms.wav", "F4_100ms.wav")
/ select = values.sound_position
/ playthrough = true
/ volume = -2000
</sound>

<trial experimental_trial_3>
/ ontrialbegin = [
    if (values.condition_label == "Bimodal_2" && values.trial_count == 1) {values.trial_type = "Random"; values.item_position = list.random_sequence.nextvalue; values.sound_position = values.item_position}
    else if (values.condition_label == "Bimodal_2" && values.trial_count > 1) {values.trial_type = "Learning"; values.item_position = list.bimodal_2_sequence.nextvalue; values.sound_position = values.item_position};
    
    if (values.item_position == 1) {text.box1.textbgcolor = red}
    else if (values.item_position == 2) {text.box2.textbgcolor = red}
    else if (values.item_position == 3) {text.box3.textbgcolor = red}
    else if (values.item_position == 4) {text.box4.textbgcolor = red}
    ]
/ stimulustimes = [0 = box1, box2, box3, box4, play_sound; 100 = grey_box1, grey_box2, grey_box3, grey_box4]
/ beginresponsetime = 0
/ validresponse = (parameters.response_1, parameters.response_2, parameters.response_3, parameters.response_4)
/ iscorrectresponse = [
    return ((values.item_position == 1 && trial.experimental_trial_3.responsetext == parameters.response_1) ||
    (values.item_position == 2 && trial.experimental_trial_3.responsetext == parameters.response_2) ||
    (values.item_position == 3 && trial.experimental_trial_3.responsetext == parameters.response_3) ||    
    (values.item_position == 4 && trial.experimental_trial_3.responsetext == parameters.response_4))
    ]
/ ontrialend = [
    if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 0} // correct
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 1} // incorrect button
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 2} // incorrect and too slow
    else if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 3}; // correct but too slow
    ]
/ branch = [trial.experimental_trial_4]
</trial>

You'll want the sound set to playthrough = false and the trial's /responseinterrupt set to trial.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm
By Ang - 4/13/2022

Dave - 4/13/2022
Ang - 4/13/2022
Hi everyone,

I am trying to program a motor sequence task where the participant responds to visual+audio cues by pressing the corresponding button on the keyboard.
I want participants to be able to respond as soon as the stimulus is starts, but I want each stimuli to be presented for the complete duration (~100 ms).
Currently, if the participant responds before the sound has completed, the sound gets clipped.
I've tried the 'playthrough' = false attribute - but that's not what I'm after.
I've also adding a 'posttrialpause', but my sound still gets cut off after the response.

Does anyone have any ideas? I have attached code for my sounds and the trial where I am trying to presenting the sounds.

Cheers,

An

<sound play_sound>
/ items = ("C4_100ms.wav", "D4_100ms.wav", "E4_100ms.wav", "F4_100ms.wav")
/ select = values.sound_position
/ playthrough = true
/ volume = -2000
</sound>

<trial experimental_trial_3>
/ ontrialbegin = [
    if (values.condition_label == "Bimodal_2" && values.trial_count == 1) {values.trial_type = "Random"; values.item_position = list.random_sequence.nextvalue; values.sound_position = values.item_position}
    else if (values.condition_label == "Bimodal_2" && values.trial_count > 1) {values.trial_type = "Learning"; values.item_position = list.bimodal_2_sequence.nextvalue; values.sound_position = values.item_position};
    
    if (values.item_position == 1) {text.box1.textbgcolor = red}
    else if (values.item_position == 2) {text.box2.textbgcolor = red}
    else if (values.item_position == 3) {text.box3.textbgcolor = red}
    else if (values.item_position == 4) {text.box4.textbgcolor = red}
    ]
/ stimulustimes = [0 = box1, box2, box3, box4, play_sound; 100 = grey_box1, grey_box2, grey_box3, grey_box4]
/ beginresponsetime = 0
/ validresponse = (parameters.response_1, parameters.response_2, parameters.response_3, parameters.response_4)
/ iscorrectresponse = [
    return ((values.item_position == 1 && trial.experimental_trial_3.responsetext == parameters.response_1) ||
    (values.item_position == 2 && trial.experimental_trial_3.responsetext == parameters.response_2) ||
    (values.item_position == 3 && trial.experimental_trial_3.responsetext == parameters.response_3) ||    
    (values.item_position == 4 && trial.experimental_trial_3.responsetext == parameters.response_4))
    ]
/ ontrialend = [
    if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 0} // correct
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency < parameters.RT_limit) {values.error_type = 1} // incorrect button
    else if (trial.experimental_trial_3.error && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 2} // incorrect and too slow
    else if (trial.experimental_trial_3.correct && trial.experimental_trial_3.latency >= parameters.RT_limit) {values.error_type = 3}; // correct but too slow
    ]
/ branch = [trial.experimental_trial_4]
</trial>

You'll want the sound set to playthrough = false and the trial's /responseinterrupt set to trial.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

Worked like a charm! Thank you so much, Dave!