Getting task to work in Pavlovia - TypeError

I have a rather long/complicated task - it uses a QUEST threshold and detection thresholds to obtain 25, 50, 75% detection of auditory stimuli - then participants are asked if they hear the sound or not at the same time as white noise is playing.

It works fine in Psychopy but I also want it to work on Pavlovia. I am very new to Javascript, I’ve removed all the imports from my PsychoPy task (which was the initial problem).

But now I get this error:
Unfortunately we encountered the following error:

  • TypeError: undefined is not an object (evaluating ‘win._psychoJS’)
    But in the javascript code file I can’t locate the code and/or know what the problem is. Like I said there is lots of errors so any advice on the other errors would be great too.

I have the crib sheet which is helpful but im still a bit lost. PsychoPy Python to Javascript crib sheet 2023 - Google Docs

White_NoisePrac = new sound.Sound("/Users/user/Documents/Psychopy/JS/Stimuli/WhiteNoiseLONG.wav", {"loops": (- 1)});

I also recommend creating sound objects as components, rather than in code.

Thanks - my problem was that I need the sound component to play continuously and across trials in a loop and restart playing when it has ended I tried to do this by unticking the ‘stop with routine?’ button in the builder of the sound component but because the component is in one of the routines in the loop it would restart every time it came back to the routine. It also said to add a sound component with no audio for a few seconds to stop the audio but that didn’t stop the audio either.

Is there anyway to do this with a sound component or to use code that won’t be a problem with javascript

The way I do this is create the sound object in an earlier routine (e.g. the instructions) with 0 volume and then set the volume to 1 in code at the end of that routine (White_NoisePrac.setVol(1)). Then I use .play() commands as appropriate in cold.

Thanks! I’ll give it a try, will it work better for JS?

Yes. I optimise almost all of my experiments for online.

Hello,

I was just wondering if you have any advice. I use the (White_NoisePrac.setVol(1) ). Then I use .play() commands. It plays the WN in the task but sometimes the audio quality is affected (echoey/ degraded). It is completely random, sometimes it’s fine then on other trials/routines it’s affected. At first I thought it was just safari because it handles audio differently, but it’s also happening on other browsers. I’ve checked the sample rate and it’s an mp3 file. My other sounds that are audio components don’t have this problem but I need WN to run continuously at different points so I can’t use a component for it.

Any help would be much appreciated.
Thanks