Dynamic start time of a sound file

URL of experiment: Pavlovia

Description of the problem: Cannot set start time of a sound file to a variable from the conditions file

I am using the builder, with use of code parts.

I am trying to generate a four-interval auditory discrimination task, with stimuli that differ in duration.
Because I want constant ISIs, I need to set the sound onsets dynamically, i.e., they are specified in the condition file:

Here is two-line example of the data source:
|item|wav1|wav2|wav3|expectedKey|ot1|ot2|ot3|ot4|ot5|ot6|ot7|ot8|
|ked|kedn.mp3|kedn.mp3|gubm.mp3|p|0.2|0.607|0.807|1.214|1.614|2.021|2.221|2.019|

When I set the onset of a sound file to, e.g., ot7 in the builder, this gives rise to an error message
that javascript error unknown reference “asarray”. If I look into the js file, I find that the start is determined by this:

if (t >= asarray($ot7) && b2_sound.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later

Apparently, the asarray is added in the script generation.
When I remove them online (on github) to the followoing, the experiment actually works.

if (t >= ot7 && b2_sound.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later

So apparently, in the script generation process, this “asarray” is added.
Not sure whether this is a bug, or I am making a mistake.
Any way to get around this, so that the complining-script process does not add the
assarray around the provided variable from the conditions file?

Kind regards,
Holger Mitterer

Please could you show a screenshot of your sound component?

You shouldn’t need to edit the JS file directly.

I didn’t quite understand. Is os7 from an Excel file?

Hello there, thanks for the reply.
First of all, yes, all the variables (here ot5) are coming from the conditions file.
(in this case a csv). Here an example:

item wav1 wav2 wav3 expectedKey ot1 ot2 ot3 ot4 ot5 ot6 ot7 ot8
ked kedn.mp3 kedn.mp3 gubm.mp3 p 0.2 0.607 0.807 1.214 1.614 2.021 2.221 2.019
schmied schmiedn.mp3 schmiedn.mp3 schreibn.mp3 p 0.2 0.783 0.983 1.566 1.966 2.549 2.749 2.547

I also played around a bit more. Thinks work if I simply put in a number there,
like putting the onset of the sound file to 1s.
(But that does not allow me to run the experiment as needed).

I also tried to see whether it is the problem with a variable coming from the conditions file,
and put the value into another variable in a code bit run at the beginning of the routine,
but that gives the same result.

Kind regards,
Holger

PS: Just in case you are wondering, the variable m_soundfile is set at the beginning of the routine,
supplying the full path, with the variable in the conditions file only giving the file name:
(m_soundFile = “sounds/”.concat(wav2))

image

Actually, I’d need to check my crib sheet but I think that you might need to start the component in code.

What I do is create the audio component in an earlier routine with the start time set to very long (ending that routine early in code) Then the audio component can be started if t > ot5 and it hasn’t started yet

Hello there,

so I went back to earlier experiments, and in Version 2020v2.5,
it was possible to use a variable (coming from a condition-sfile)
to set the onset of a sound component.

Kind regards,
Holger

Hi there, same problem here. Using time variable in builder would lead to asarray function showing up in JS code, which does not work at all since there’s no asarray function in JS and it will show error in pavlovia. This shows up in V.2021, so I think there’s some problem in builder-code conversion. Currently I am working by removing asarray function manually. I also put issue in github expecting for a quick fix since I have to get this done asap for school project. Thank you!