psychopy.org | Reference | Downloads | Github

Issue with Audio Playing When it should Not

#1

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): MacOS 10.14.2
PsychoPy version (e.g. 1.84.x): 3.0.0.b12
Standard Standalone? (y/n) If not then what?: Not sure what this is asking.
What are you trying to achieve?: We are creating a Theory of Mind task where the person hears a directions that are paired with an image. With this first image, the person is supposed to click the object that they are “wanting to move”. The same image is shown again and the person is to click on where the object is supposed to go. I have included a picture of the excel file which is the conditions file.

What did you try to make it work?: In the conditions excel file, I made sure the cells that are not supposed to have anything in them were empty. (We want the audio directions to play once, during the first image slide and not during the second image slide.) I tried setting the audio stimuli from reset every repeat to constant.

What specifically went wrong when you tried that?: When I tried setting the audio stimuli from reset every repeat to constant I got this error message: " DirectorPracticeAudio = sound.Sound(AudioDirectionAB, secs=-1, stereo=True)
NameError: name ‘AudioDirectionAB’ is not defined"

Nothing changed when I made sure in my excel spreadsheet that the cells where we didn’t want audio direction to be played didn’t have anything in them. Yet it still plays the audio directions even when the cell is empty.

0 Likes

#2

I can’t really understand the description of this problem, but setting a field to be “constant” while also providing it with a variable name to use are mutually contradictory actions (this is why you get the NameError: name ‘AudioDirectionAB’ is not defined"" error: the variable doesn’t exist at the start of the experiment, when constant stimuli are defined). If you want a constant value, you must provide it in constant form (i.e. a literal filename like 'some_sound.wav', not a variable name. i.e. variables by definition are things that can change (generally on very repeat of routine).

0 Likes

#3

Thank you for your quick reply. Thank you for clarifying why I got an error with changing it to constant.

I will try to clarify. Our task consists of having a participant click on certain objects within our image based on an audio direction. To capture our mouse clicks we show the image twice. The first time we want the audio to play with the image. The second time that same image appears we do not want that audio direction to play while it captures the participant’s click. I have built the variables excel spreadsheet to this specification (or so I thought). When I do a trial run to make sure our experiment runs the way it is supposed to - it does not. The audio which is only supposed to play once with the images, plays twice.

How do I fix this issue? The variable excel sheet (a screen shot of it is in a previous post) is built the way I want it to work - however that is now how it is running.

Thanks for your help in advance.

0 Likes

#4

Sorry, the description of the problem is still not very clear to me. Perhaps a screenshot of your flow panel would be helpful, otherwise I’m just speculating. But if you have the image and the audio repeated on consecutive routines, why not just omit the audio component from the second one?

You might also be misunderstanding how conditions files work (again, I can’t tell without seeing your flow panel). One row of values applies to an entire iteration of a loop (which generally, although not always) corresponds to one trial. The values don’t update until the next iteration. So if you present two audio components within a single iteration, referring to the same sound file variable, that file will indeed play twice, because the value of the variable has not changed.

If you are indeed separating things across trials, then perhaps instead of just having blank cells, you should explicitly enter the value None. It’s possible by not having anything in the cell, the value just fails to update. This then itself might lead to other issues: maybe a sound component doesn’t want to play with None specified. Again, let’s see you flow panel and go from there.

0 Likes

#5

Michael,

Thanks for responding back.

To answer your first question, I did omit the audio component from the second one, yet it still continues to play.

Below I have attached the pictures of the flow chart and a picture of what the audio component looks like for each of the trials.

Thanks in advance for your help.

0 Likes

#6

Mike,

I just tried entering the value None into the blank space and here is the error message I received: 49%20AM

0 Likes

#7

Can you please describe exactly sentence what this means, in terms of the names of the routines and loops in the diagram above?

An audio component can’t play a sound if there is no actual audio component, so I suspect that we really need to sort out the terminology to isolate the problem.

0 Likes

#8

Thank you for your reply.

To your question: What I meant by the “I did omit the audio component from the second one, yet it still continues to play.” Refers to the conditions file, where the audio file is being pulled from. Each of the routines and loops in the diagram above are all configured the same way with an audio component, image component, and mouse component. This means that my audio issue shows up in all parts of my experiment.

My understanding of the conditions file (which is above) was that this was the place where you told the different components what to do? As you can see, we want to show an image twice. The first time the images shows we want the audio to play and the second time the images shows we want no sound to play. That is what I thought I had built into my conditions file.

I am not sure what else you need from me to help me with this issue. But I have tried everything I know to have the audio only play once and it continues to play twice. I also added in a screen shot of how the properties of the trial so you could have that image as well.

Please let me know if you need anything else from me.

Thanks!

0 Likes

#9

Precise descriptions are important: remember, the only thing we know about your situation is what you share with us. e.g. the descriptions above say both that there was an audio component on every routine, and that the audio component was omitted from the second routine. So it is important to use the right terminology, so we can actually understand what your situation is. Components are the stimuli you insert, which have icons. They get controlled with variables from your conditions files.

But from this latest explanation, and from the previous error message, we can perhaps see where to go. It seems that the difficulty is what to do when you want to specify that no sound should play. PsychoPy gives you an error message when trying to specify None. So I’d suggest an alternative approach:

  • In those empty cells, just put in a dummy value (like A, to notionally play the tone A).
  • Insert a new variable to control the volume of your audio component.
  • Set that variable to be 1 on rows where a sound file should play, and 0 on rows where you have your dummy A placeholder.
  • Insert that variable name in the Volume field of your audio component, set to update on every routine.
0 Likes

#10

Thank you for your help. I am new to coding so my terminology is not always correct, my apologies.

Your suggestion to use a dummy value helped and solved the issue.

0 Likes