PennController for IBEX › Forums › Support › Randomize audios
- This topic has 2 replies, 2 voices, and was last updated 3 years, 1 month ago by li_dx.
-
AuthorPosts
-
October 18, 2021 at 5:40 pm #7386li_dxParticipant
Hi Jeremy,
Thank you for creating and maintaining PCIbex! I’ve found it super useful! I’m wondering whether it’s possible to randomize the order by which multiple audios are played in a single trial. Here’s a link to the experiment. I’m building a word learning experiment where at each training trial, participants will see multiple objects and hear multiples non-sense words, and they will need to learn the word-object mapping. As shown in the code below, the order of the three audios at each trial is fixed, and I wonder if they can be randomized? Thanks!
// Trainings trials Template("training.csv", row => newTrial("training", newTimer("break", 1000) .start() .wait() , newImage("image1", row.image1) .size(200, 200) , newImage("image2", row.image2) .size(200, 200) , newImage("image3", row.image3) .size(200, 200) , newCanvas("side-by-side", 700,200) .add( 0, 0, getImage("image1")) .add(250, 0, getImage("image2")) .add(500, 0, getImage("image3")) .center() .print() , newSelector("selection") .add(getImage("image1"), getImage("image2"), getImage("image3")) .disableClicks() .shuffle() , newAudio("audio1", row.audio1) .play() .wait() , newTimer("break2", 1000) .start() .wait() , newAudio("audio2", row.audio2) .play() .wait() , newTimer("break3", 1000) .start() .wait() , newAudio("audio3", row.audio3) .play() , newTimer("break4", 1000) .start() .wait() , getAudio("audio3") .wait("first") ) .log("group", row.group) .log("item", row.item) .log("condition", row.condition) )
October 18, 2021 at 6:13 pm #7388JeremyKeymasterHi,
Yes, you can use plain javascript to randomize the order of the audios. Here’s how I would go about it:
Template("training.csv", row => newTrial("training", audios = [row.audio1,row.audio2,row.audio3].sort(v=>0.5-Math.random()), newTimer("break", 1000) .start() .wait() , newImage("image1", row.image1) .size(200, 200) , newImage("image2", row.image2) .size(200, 200) , newImage("image3", row.image3) .size(200, 200) , newCanvas("side-by-side", 700,200) .add( 0, 0, getImage("image1")) .add(250, 0, getImage("image2")) .add(500, 0, getImage("image3")) .center() .print() , newSelector("selection") .add(getImage("image1"), getImage("image2"), getImage("image3")) .disableClicks() .shuffle() , newAudio("audio1", audios[0]) .play() .wait() , newTimer("break2", 1000) .start() .wait() , newAudio("audio2", audios[1]) .play() .wait() , newTimer("break3", 1000) .start() .wait() , newAudio("audio3", audios[2]) .play() , newTimer("break4", 1000) .start() .wait() , getAudio("audio3") .wait("first") ) .log("group", row.group) .log("item", row.item) .log("condition", row.condition) .log("audio1", audios[0]) .log("audio2", audios[1]) .log("audio3", audios[2]) )
Jeremy
October 18, 2021 at 7:00 pm #7390li_dxParticipantThis works great! Thank you so much!
-
AuthorPosts
- You must be logged in to reply to this topic.