OpenMATB icon indicating copy to clipboard operation
OpenMATB copied to clipboard

Audio listening while running the scenario

Open thomakl opened this issue 1 year ago • 5 comments

Hi, I would like to play an audio file while the participant is running the scenario. More precisely, just after I run the program and the participant is in the scenario, I would like him/her to listen to a recording I made. What do you think would be the easiest way to do it ?

Cheers, T.

thomakl avatar Mar 27 '23 13:03 thomakl

Hi @thomakl, There’s currently no module to handle sound playing in OpenMATB. If you don’t mind the sound being played at anytime, even on pause, or during participant instructions, you could just play with pyglet and some code to suit your needs.

For instance, if you have a test.mp3 file into the includes/sounds/ directory, just add the following in the main.py

import pyglet.media
sound = pyglet.media.load('includes/sounds/test.mp3', streaming=False)
sound.play()

Put this just before the self.scheduler.run() command in main.py, line 55. Reading the pyglet documentation, you should be able to play this in loop if you want. You can also take a look at plugins/communications.py where sounds routines are used in a more complex manner.

benoitvalery avatar Mar 30 '23 15:03 benoitvalery

Hi, Thanks to your suggestion, I have managed to implement a 'radioprompt' with my instruction. 00:00:00;communication;instruction_scenario_A Will could imagine it as new feature ? Cheers,

thomakl avatar Apr 05 '23 12:04 thomakl

Hi @thomakl, I was talking about the communications plugin just to indicate you some parts of the code where sound routines are implemented, to inspire you, not to use it. The communications plugins should stick to its native logic, which is giving instructions about available radios and their frequencies. Best

benoitvalery avatar Apr 06 '23 07:04 benoitvalery

Hi, I see what you mean. I think implementing a feature to play the instructions without the participant to read could help the robustness of the experiment. what do you think ?

thomakl avatar Apr 06 '23 09:04 thomakl

It could be a great feature, you’re right. One constraint is that it should be a blocking plugin, i.e., the program should be paused when an auditory instruction is started: so as not to accidentally overlap with other sounds streams such as those of the communications plugin. One option could be to keep or hide the OpenMATB environment in the background. If hidden, we could simply display a fullscreen with minimal instructions like "Instructions", along with the auditory stream being played. This could also allow the user to press a key at the end of the (auditory) instruction, like for written instructions. Do not hesitate to add your ideas.

benoitvalery avatar Apr 06 '23 09:04 benoitvalery