Commit fd71874a authored by alireza tbp's avatar alireza tbp

Update audioseqq.js

parent 429630fb
......@@ -47,9 +47,9 @@ flowScheduler.add(experimentInit);
flowScheduler.add(code1RoutineBegin());
flowScheduler.add(code1RoutineEachFrame());
flowScheduler.add(code1RoutineEnd());
//flowScheduler.add(IntroRoutineBegin());
//flowScheduler.add(IntroRoutineEachFrame());
//flowScheduler.add(IntroRoutineEnd());
flowScheduler.add(IntroRoutineBegin());
flowScheduler.add(IntroRoutineEachFrame());
flowScheduler.add(IntroRoutineEnd());
const trials_2LoopScheduler = new Scheduler(psychoJS);
flowScheduler.add(trials_2LoopBegin, trials_2LoopScheduler);
flowScheduler.add(trials_2LoopScheduler);
......@@ -517,90 +517,89 @@ function trials_2LoopEnd() {
var SOUNDComponents;
function SOUNDRoutineBegin(snapshot) {
return function () {
//------Prepare to start Routine 'SOUND'-------
t = 0;
SOUNDClock.reset(); // clock
frameN = -1;
continueRoutine = true; // until we're told otherwise
// update component parameters for each repeat
sound_1.secs = stop(ran);
sound_1.setVolume(1);
// keep track of which components have finished
SOUNDComponents = [];
SOUNDComponents.push(sound_1);
//------Prepare to start Routine 'SOUND'-------
t = 0;
SOUNDClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
sound_1.secs = stop(ran);
sound_1.setVolume(1);
// keep track of which components have finished
SOUNDComponents = [];
SOUNDComponents.push(sound_1);
for (const thisComponent of SOUNDComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
for (const thisComponent of SOUNDComponents)
if ('status' in thisComponent)
thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;
}
return Scheduler.Event.NEXT;
};
}
var frameRemains;
function SOUNDRoutineEachFrame(snapshot) {
return function () {
//------Loop for each frame of Routine 'SOUND'-------
// get current time
t = SOUNDClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// start/stop sound_1
if (t >= durationn(intervall)[c] && sound_1.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
sound_1.tStart = t; // (not accounting for frame time here)
sound_1.frameNStart = frameN; // exact frame index
sound_1.play(); // start the sound (it finishes automatically)
sound_1.status = PsychoJS.Status.STARTED;
}
frameRemains = durationn(intervall)[c] + stop(ran) - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if ((sound_1.status === PsychoJS.Status.STARTED || sound_1.status === PsychoJS.Status.FINISHED) && t >= frameRemains) {
if (stop(ran) > 0.5) {
sound_1.stop(); // stop the sound (if longer than duration)
sound_1.status = PsychoJS.Status.FINISHED;
//------Loop for each frame of Routine 'SOUND'-------
let continueRoutine = true; // until we're told otherwise
// get current time
t = SOUNDClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// start/stop sound_1
if (t >= durationn(intervall)[c] && sound_1.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
sound_1.tStart = t; // (not accounting for frame time here)
sound_1.frameNStart = frameN; // exact frame index
psychoJS.window.callOnFlip(function () { sound_1.play(); }); // screen flip
sound_1.status = PsychoJS.Status.STARTED;
}
}
// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({ keyList: ['escape'] }).length > 0) {
return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
continueRoutine = false; // reverts to True if at least one component still running
for (const thisComponent of SOUNDComponents)
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
break;
frameRemains = durationn(intervall)[c] + stop(ran) - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left
if (sound_1.status === PsychoJS.Status.STARTED && t >= frameRemains) {
// if (stop(ran) > 0.5) {
sound_1.stop(); // stop the sound (if longer than duration)
sound_1.status = PsychoJS.Status.FINISHED;
// }
}
// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({ keyList: ['escape'] }).length > 0) {
return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
continueRoutine = false; // reverts to True if at least one component still running
for (const thisComponent of SOUNDComponents)
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
break;
}
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
function SOUNDRoutineEnd(snapshot) {
return function () {
//------Ending Routine 'SOUND'-------
for (const thisComponent of SOUNDComponents) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
//------Ending Routine 'SOUND'-------
for (const thisComponent of SOUNDComponents) {
if (typeof thisComponent.setAutoDraw === 'function') {
thisComponent.setAutoDraw(false);
}
}
}
sound_1.stop(); // ensure sound has stopped at end of routine
// the Routine "SOUND" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
sound_1.stop(); // ensure sound has stopped at end of routine
// the Routine "SOUND" was not non-slip safe, so reset the non-slip timer
routineTimer.reset();
return Scheduler.Event.NEXT;
return Scheduler.Event.NEXT;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment