Custom coroutines (simultaneous auditory and verbal presentation)
I'm trying to convert an OS experiment so that it is suitable for OSWeb and can be distributed online but am struggling with writing custom coroutine code which can be run in JavaScript. Basically, the coroutine in OS consists of 2 sketchpad items sandwiched between 2 sampler items, which are audio files. The first audio file plays right at the start of the coroutine, the first sketchpad item (a fixation dot) appears 500ms in and then the second sketchpad item (a word on the screen) and audio file (the same word said out loud) both start 1500ms in (so the participant sees and hears the word simultaneously).
In JavaScript, is it possible to store a variable and manipulate it in a loop? Also, can you play sounds using a command alone?
I had a look at the documentation on writing a custom coroutine but not being very technical, I can't quite wrap my head around it, so if anyone is prepared to help me privately on this, that would also be greatly appreciated!
Comments
I suggest you take a JS lib which has a method to play sounds in
asyncmode, possibly utilising WebGL - otherwise you likely to have bad timings. Coroutines are mainly a term for game engines and such, in most programming tasks, it is called asynchronous execution, or Workers.Of course, you can manipulate your vars in a loop, if it was declared __before__ the loop started. But I cannot understand why this question is there?
What is `OSWeb`?
OSWeb is the version of OpenSesame which is compatible online and can be run through a browser.
I know there are quite a lot of different JavaScript libraries. Is there any particular one which has a method to play sounds in async mode that you would recommend?
If we can manipulate a stored variable in a loop and can play sounds using a command, we should be able to run the experiment in OSWeb and also be able to play sound and display text ‘simultaneously’.