I create a simple auditory priming experiment on the Builder and upload it to pavlovia according the guideline provided in this forum regarding the experiment settings (blank output path, export HMTL set on Sync, uploaded additional resources). However, when turned on piloting stage, the following error pops up:
I figured that os is not a js module, so I just substitute os.path.sep with a simple "/", and that issue is resolved. However, if I test the script again, a similar error pops up:
ReferenceError: Canāt find variable: secs
which refers to this line of the code:
playSound.setSound(audio, secs=-1)
In the API reference of PsychoJS setSound() does not have a secs argument, so I just removed it. I re-tested the experiment, and finally this new error popped up:
Unfortunately we encountered the following error:
when replacing the current sound
invalid input, need an instance of the Sound class.
Try to run the experiment again. If the error persists, contact the experiment designer.
Hi @wakecarter, thank you for your suggestion! I have checked your crib sheet and tried to implement what you are saying here, but when I try to run the code locally this error pops up:
NameError: name āthisSoundConditionā is not defined
I am attaching the .psyexp file below, in case it helps. (In the settings of the sound component I replaced $thisSound with $audio, as it is the name of the condition in the conditions files.
What I meant is. In your example, thisSoundCondition was named liked that because you added the variable $thisSound in the settings of the sound component. I had set $audio because thatās what is called the column in my condition files, hence I assumed that the variable audioCondition was automatically created by PsychoPy.
However, in code_SoundMute you have
if t > 1:
continueRountine = False
in Begin Routine when you should have
if t > 1:
continueRoutine = False
in Each Frame
and (if I understand your experiment correctly) in the playVoice routine you should remove playSound.
Your code from EndRoutine in soundMute should be in Begin Routine of playVoice
if audioCondition != "Silence":
sound_1.setVolume(1)
sound_1.play()
I did what you said here, but again the variable audioCondition is not defined. Am I missing/misreading something in your working example?
Oook, I get what you mean now. And everything seems to work now, thank you!
Now, the issue is ā I need the sound to be play after a 1s fixation cross. The fixation cross is within the playVoice routine. How do I do that if the sound is preloaded in a routine preceding it?
The easiest option is to put the fixation cross in the routine with the silent sound.
The alternative is to play the sound using an Each Frame code component set to trigger at 1 second but using a flag variable to stop it triggering multiple times.
I am trying to implement this suggestion of yours in my code, but I am facing some issues. In my soundMute routine, I now have the fixation cross, the sound and the code component. However, if I use the code component as before in the Each Frame tab of the soundMute routine:
if t > 1:
continueRoutine = False
the fixation cross will not be presented at all. So I tried to replace the code above with this instead:
if t > 1:
sound_1.setVolume(0) #mute the sound
Eventually the volume of sound_1 is reset to 1 and played in the following routine as shown above.
Locally, this works as intended. However, Iām back to square 1 when the experiment is run online, as a number of errors pop up (ie., regarding the secs argument of the function setSound).
Do you have any suggestion on how to solve this? I tried to use pause() and stop() but it did not do the trick.
I need to set the volume to 0 in the soundMute routine because otherwise the sound will automatically play in the routine. In the soundMute routine, I want (a) the fixation cross to be printed on the screen, but (b) the sound not to be played. In your demo, your soundMute routine had just the sound component in it, so you just did:
if t>1:
continueRoutine=False
In my case, the code above will prevent both the fixation cross and the sound from being presented. So, I thought to adapt the code so that it selectively does not play the sound but prints the fixation cross:
if t>1:
playSound.setVolume(0) # or playSound.stop() or playSound.pause()
This solution works on locally, but it does not work online. When I test it, it gives me the usual error as above:
ReferenceError: Canāt find variable: secs
Regarding this:
I normally leave the duration of sound components blank and have the sound file of the desired length.
I donāt understand your point here. I do leave the duration of sound components blank, but still the error above pops up (online only, though). Your solution did solve the error, I just canāt seem to find a solution when implementing a pre-stimulus fixation cross.
I am still having trouble getting the experiment to work online. The experiment works now as intended locally (thanks for the last tip, @wakecarter!), but it gets a number of errors online. First, the usual error pops up:
ReferenceError: Canāt find variable: secs
The JavaScript console suggests that the error above refers to the argument secs of the setSound() function. If I try to delete that argument across all setSound() instances, the following error pops up:
Unfortunately, we encountered the following error:
when replacing the current sound
invalid input, need and instance of the Sound class
So, basically I am back to my first message of this post. I canāt seem to understand why this is happening. Is this a known issue?
No, I created a workflow on PsychoPy with a few code components as you recommended in your crib sheet, and then push it to pavlovia. I am attaching the psyexp file.
Hey there, Iām trying everything, but the experiment still gives me the usual error:
ReferenceError: Canāt find variable: secs
and I donāt really know what else to do. I tried to delete the previous project on pavlovia and redo the whole experiment on the Builder from scratch (according to @wakecarterās crib sheet). But that did not make much of a difference.