Hi everyone. I’ve been working on an experiment that I really need to get out soon. It works perfectly in PsychoPy, but the moment I try to pilot it on Pavlovia I get the following message: TypeError: Cannot read properties of undefined (reading ‘Keyboard’)
I’ve tried inspecting the experiment, and this is what I got:
I’m sorry, I’m terribly new to this so I’m a bit at a loss and unsure what else I should add. I found other posts on here about things being undefined, but none of them really gave me a solution.
It was mostly built in the builder, with 4 code components:
To let the experiment branch depending on whether a participant consents to take part: if they consent (by pressing Y), they’ll get sent to the experiment, if they don’t consent (by pressing N), they’ll skip the experiment loop and be sent to a goodbye message
To determine which conditions file they get in the learning routine: this is determined by the participant number they fill in, so no keyboard response needed there
To determine which conditions file they get in the test routine: this is the same as the previous code. No keyboard involved
To let a test sound play when they press T: before they get exposed to the actual audio stimuli, I let them test their device’s volume by pressing T. Then they can adjust their volume accordingly, and press SPACE to continue to the rounds with the actual audio stimuli. This is the one whose programming I am the most unsure of, because well… I tried something and it just happened to work. Here’s the code, if you’re curious:
Begin Experiment Tab:
var core = import("psychopy/core");
var sound = import("psychopy/sound");
function playSound() {
var testaudio;
testaudio = new sound.Sound("testaudio.wav", {"secs": 1});
testaudio.setVolume(1);
testaudio.play();
core.wait(0.3);
}
Each Frame Tab:
if (psychoJS.eventManager.getKeys({"keyList": ["t"]})) {
playSound();
}
Those code components were first written in python, but later converted to JS, as there was an issue with initialising the experiment at first.
I’m just at a loss because I’m not sure where it even expects Keyboard to be defined: it let me add all those keyboard components in the builder and now it starts complaining in Pavlovia, then why let me add them in the first place?! (this is me just venting).
Any help would be hugely appreciated, I really need to get this experiment out soon.
It’s the routine that asks people whether they consent to participating in the experiment. (so the first code component I described in my original post)
I will have a look at your links tomorrow morning (it is 10 pm here and I’m exhausted). Thank you for responding
I gotta be honest, I have no clue anymore.
I know it was from a post like this: How to play and repeat stimuli after a manual click , but it had that var code and var sound in front of it, but I can’t seem to find said post anymore.
Or rather, this was how it originally was in python:
import psychopy.core as core
import psychopy.sound as sound
def playSound():
testaudio = sound.Sound('testaudio.wav', secs = 1)
testaudio.setVolume(1)
testaudio.play()
core.wait(.3)
and this is what it became in JS:
import * as core from 'psychopy/core';
import * as sound from 'psychopy/sound';
function playSound() {
var testaudio;
testaudio = new sound.Sound("testaudio.wav", {"secs": 1});
testaudio.setVolume(1);
testaudio.play();
core.wait(0.3);
}
which caused trouble because of the asterisks, and so I ended up with the var core that you see now (with some help from a friend who knows a little more than me)
I’ve honestly been considering just throwing the audio testing routine out and get my participants to check their audio another way, because I keep suspecting this routine is the cause of all my woes.