How to Stop Making a Shape Go Back and Forth


Author
Message
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K
krmanning10 - 9/8/2025
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.

There is no attachment. Please provide the files. In addition:
- Make sure your Inquisit installation is up to date.
- Provide the application log along with the other files (Tools -> View Log File).


The ZIP you attached contains seven MP3 files, nothing else. No code, no log.

I apologize! The code should be in there now.

The code you attached does not implement any of changes I proposed at all, so of course it has the same problems as before.

DId you pick the wrong file?

krmanning10
krmanning10
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.

There is no attachment. Please provide the files. In addition:
- Make sure your Inquisit installation is up to date.
- Provide the application log along with the other files (Tools -> View Log File).


The ZIP you attached contains seven MP3 files, nothing else. No code, no log.

I apologize! The code should be in there now.
Attachments
ZIP.zip (26 views, 806.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K
krmanning10 - 9/8/2025
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.

There is no attachment. Please provide the files. In addition:
- Make sure your Inquisit installation is up to date.
- Provide the application log along with the other files (Tools -> View Log File).


The ZIP you attached contains seven MP3 files, nothing else. No code, no log.
krmanning10
krmanning10
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Dave - 9/8/2025
krmanning10 - 9/8/2025
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.

There is no attachment. Please provide the files. In addition:
- Make sure your Inquisit installation is up to date.
- Provide the application log along with the other files (Tools -> View Log File).


Attachments
ZIP.zip (31 views, 802.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K
krmanning10 - 9/8/2025
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.

There is no attachment. Please provide the files. In addition:
- Make sure your Inquisit installation is up to date.
- Provide the application log along with the other files (Tools -> View Log File).
krmanning10
krmanning10
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Dave - 8/26/2025

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.

Hello,

Thank you for your help! I made the changes you suggested. Unfortunately, I'm afraid I'm still running into the same issue. I've attached a zip file with all the components needed for it. I would provide a video file of the issue but it is too large to be attached, so I apologize in advance.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K

In the main, the way you've changed the /onTrialEnd logic from the original where you wanted repetiosns makes no sense and creates problems.

Here's a fixed-up version, as best as I can guess at what you actually want.

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
// repCount = 0 // not needed anymore
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteC.skip = false;
    };
    // if over line 3, 4, or 7 we enable note G
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteG.skip = false;
    };
    // if over line 5 or 6, we enable note A
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteA.skip = false;
    };
}
/ stimulusframes = [
    1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
    noteA, noteC, noteD, noteE, noteF, noteG,
    debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony;
    }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
    // we start out playing no note, skipping all of them
    sound.noteA.skip = true;
    sound.noteC.skip = true;
    sound.noteD.skip = true;
    sound.noteE.skip = true;
    sound.noteF.skip = true;
    sound.noteG.skip = true;
    if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) {
        sound.noteF.skip = false;
    };
    // if over line 3 or 4, we enable note E
    if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct)) {
        sound.noteE.skip = false;
    };
    // if over line 5 or 6, we enable note D
    if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) {
        sound.noteD.skip = false;
    };
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) {
        sound.noteC.skip = false;
    };
}
/ stimulusframes = [
1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
noteA, noteC, noteD, noteE, noteF, noteG,
debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
    if (trial.synchrony2.response== 57) {
        values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
        values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
        values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
        return true;
    }
}
/ branch = {
    if (!(values.musicLineDuration <= 0 || trial.synchrony2.response == 0)) { // as long as animation / trial hasn't timed out, we keep running
        return trial.synchrony2;
    }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

<text debug>
/ items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>")
/ position = (50%, 10%)
/ erase = false
</text>


In the future, please:
- Always provide any and all files your code requires. Put script and associated files in a ZIP, attach the ZIP to your post. If it is too large to attach, upload it somewhere else and provide the download link.
- Don't paste entire scripts into a post's body. If you need to highlight speciic parts, you can do so using +Insert, and then </> (nsert code).
- Comment your code. E.g. if you're stripping out certain parts, your comments should explain why / what the modified code is supposed to do as opposed to the original.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K
krmanning10 - 8/26/2025
Hello,

I am having an issue with a trial that I want to play. My trial is meant to be playing notes to the tune of Twinkle Twinkle Little Star based on the allignment of a red rectangle with black rectangles. The red rectangle travels from one point of the screen to another without stopping. The participant clicks on the space bar to make the sound play, and the process repeats 5 more times (6 times total). At the end of each verse, the bar is meant to stop and go back to the beginning. However, I am having an issue where the bar goes a small distance backwards before teleporting to the starting point for the next verse. Is there something wrong with my code? Here are two verses to visualize the issue:

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
/ repCount = 0
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, -1, values.musicLineStartX, 50%, values.musicLineEndX, 50%)
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.repCount = 0;
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.repCount = 0;
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
  // we start out playing no note, skipping all of them
  sound.noteA.skip = true;
  sound.noteC.skip = true;
  sound.noteD.skip = true;
  sound.noteE.skip = true;
  sound.noteF.skip = true;
  sound.noteG.skip = true;
  // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
  if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct))
  sound.noteC.skip = false;
  // if over line 3, 4, or 7 we enable note G
  if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct))
  sound.noteG.skip = false;
  // if over line 5 or 6, we enable note A
  if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct))
  sound.noteA.skip = false;
  }
/ stimulusframes = [
  1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
  noteA, noteC, noteD, noteE, noteF, noteG,
  debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
  if (trial.synchrony.response== 57)
   values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
   values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
   values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
   return true;
  }
/ onTrialEnd = {
  if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything
   values.musicLineStartX = 5%; // back to the original start position
   //values.musicLineDuration = 7250; // back to original duration
        //values.xAtResponse = 0%; // we don't have any response yet
   values.repCount += 1; // we increase the repetition count
  }
/ branch = {
    if (values.repCount <= 7) {
   return trial.synchrony;
  }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
  // we start out playing no note, skipping all of them
  sound.noteA.skip = true;
  sound.noteC.skip = true;
  sound.noteD.skip = true;
  sound.noteE.skip = true;
  sound.noteF.skip = true;
  sound.noteG.skip = true;
  if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct))
  sound.noteF.skip = false;
  // if over line 3 or 4, we enable note E
  if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct))
  sound.noteE.skip = false;
  // if over line 5 or 6, we enable note D
  if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct))
    sound.noteD.skip = false;
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct))
  sound.noteC.skip = false;
  }
/ stimulusframes = [
  1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
  noteA, noteC, noteD, noteE, noteF, noteG,
  debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
  if (trial.synchrony2.response== 57)
   values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
   values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
   values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
   return true;
  }
/ onTrialEnd = {
  if (values.musicLineDuration <= 0 || trial.synchrony2.response == 0) // if trial times out, we reset everything
   values.musicLineStartX = 5%; // back to the original start position
   //values.musicLineDuration = 7250; // back to original duration
        //values.xAtResponse = 0%; // we don't have any response yet
   values.repCount += 1; // we increase the repetition count
  }
/ branch = {
    if (values.repCount <= 7) {
   return trial.synchrony2;
  }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

Unfortunately it is not letting me attach the sound files.

Please put everything in a ZIP -- the script, any files it requires -- and then attach the ZIP. Thanks
krmanning10
krmanning10
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Hello,

I am having an issue with a trial that I want to play. My trial is meant to be playing notes to the tune of Twinkle Twinkle Little Star based on the allignment of a red rectangle with black rectangles. The red rectangle travels from one point of the screen to another without stopping. The participant clicks on the space bar to make the sound play, and the process repeats 5 more times (6 times total). At the end of each verse, the bar is meant to stop and go back to the beginning. However, I am having an issue where the bar goes a small distance backwards before teleporting to the starting point for the next verse. Is there something wrong with my code? Here are two verses to visualize the issue:

<expt myExpt>
/ blocks = [1=task; 2=task2]
</expt>

<values>
/ repCount = 0
/ xAtResponse = 0
/ musicLineStartX = 5% // start x coordinate of animation
/ musicLineEndX = 90% // end x coordinate of animation
/ musicLineDuration = 7250 // duration of full animation
</values>

The bar that moves across the screen:
<shape musicline>
/ shape = rectangle
/ color = crimson
/ size = (2%,100%)
/ animation = path(values.musicLineDuration, -1, values.musicLineStartX, 50%, values.musicLineEndX, 50%)
/ erase = false
</shape>

7 shapes that the bar will pass over:
<shape line1>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (20%, 50%)
/ erase = false
</shape>

<shape line2>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (30%, 50%)
/ erase = false
</shape>

<shape line3>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (40%, 50%)
/ erase = false
</shape>

<shape line4>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (50%, 50%)
/ erase = false
</shape>

<shape line5>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (60%, 50%)
/ erase = false
</shape>

<shape line6>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (70%, 50%)
/ erase = false
</shape>

<shape line7>
/ shape = rectangle
/ color = black
/ size = (2%,50%)
/ position = (80%, 50%)
/ erase = false
</shape>

<block task>
/ trials = [1=synchrony]
/ onBlockBegin = {
    values.repCount = 0;
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<block task2>
/ trials = [1=synchrony2]
/ onBlockBegin = {
    values.repCount = 0;
    values.xAtResponse = 0;
    values.musicLineStartX = 5%; // start x coordinate of animation
    values.musicLineEndX = 90%; // end x coordinate of animation
    values.musicLineDuration = 7250; // duration of full animation
}
</block>

<trial synchrony>
/ onTrialBegin = {
  // we start out playing no note, skipping all of them
  sound.noteA.skip = true;
  sound.noteC.skip = true;
  sound.noteD.skip = true;
  sound.noteE.skip = true;
  sound.noteF.skip = true;
  sound.noteG.skip = true;
  // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31
  if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct))
  sound.noteC.skip = false;
  // if over line 3, 4, or 7 we enable note G
  if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct))
  sound.noteG.skip = false;
  // if over line 5 or 6, we enable note A
  if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct))
  sound.noteA.skip = false;
  }
/ stimulusframes = [
  1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
  noteA, noteC, noteD, noteE, noteF, noteG,
  debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
  if (trial.synchrony.response== 57)
   values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
   values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration
   values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
   return true;
  }
/ onTrialEnd = {
  if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything
   values.musicLineStartX = 5%; // back to the original start position
   //values.musicLineDuration = 7250; // back to original duration
        //values.xAtResponse = 0%; // we don't have any response yet
   values.repCount += 1; // we increase the repetition count
  }
/ branch = {
    if (values.repCount <= 7) {
   return trial.synchrony;
  }
}
/ timeout = values.musicLineDuration
</trial>

<trial synchrony2>
/ onTrialBegin = {
  // we start out playing no note, skipping all of them
  sound.noteA.skip = true;
  sound.noteC.skip = true;
  sound.noteD.skip = true;
  sound.noteE.skip = true;
  sound.noteF.skip = true;
  sound.noteG.skip = true;
  if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct))
  sound.noteF.skip = false;
  // if over line 3 or 4, we enable note E
  if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct))
  sound.noteE.skip = false;
  // if over line 5 or 6, we enable note D
  if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct))
    sound.noteD.skip = false;
    // if over line 7, we enable note C
    if ((values.xAtResponse >= 75pct && values.xAtResponse <= 84pct))
  sound.noteC.skip = false;
  }
/ stimulusframes = [
  1=clearScreen, musicline, line1, line2, line3, line4, line5, line6, line7,
  noteA, noteC, noteD, noteE, noteF, noteG,
  debug]
/ beginResponseTime = -1
/ validResponse = (" ")
/ isValidResponse = {
  if (trial.synchrony2.response== 57)
   values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response
   values.musicLineDuration -= trial.synchrony2.latency; // calculate remaining animation duration
   values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response
   return true;
  }
/ onTrialEnd = {
  if (values.musicLineDuration <= 0 || trial.synchrony2.response == 0) // if trial times out, we reset everything
   values.musicLineStartX = 5%; // back to the original start position
   //values.musicLineDuration = 7250; // back to original duration
        //values.xAtResponse = 0%; // we don't have any response yet
   values.repCount += 1; // we increase the repetition count
  }
/ branch = {
    if (values.repCount <= 7) {
   return trial.synchrony2;
  }
}
/ timeout = values.musicLineDuration
</trial>

The sound files to play:
<sound noteC>
/ items = ("Twinkle_Twinkle_Little_Star_C.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteG>
/ items = ("Twinkle_Twinkle_Little_Star_G.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteA>
/ items = ("Twinkle_Twinkle_Little_Star_A.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteF>
/ items = ("Twinkle_Twinkle_Little_Star_F.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteE>
/ items = ("Twinkle_Twinkle_Little_Star_E.mp3")
/ playThrough = false
/ erase = false
</sound>

<sound noteD>
/ items = ("Twinkle_Twinkle_Little_Star_D.mp3")
/ playThrough = false
/ erase = false
</sound>

Unfortunately it is not letting me attach the sound files.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search