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.
|