juliencegarra / OpenMATB

OpenMATB: A Multi-Attribute Task Battery promoting task customization, software extendability and experiment replicability
Other
43 stars 32 forks source link

Audio listening while running the scenario #25

Open thomakl opened 1 year ago

thomakl commented 1 year ago

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.

benoitvalery commented 1 year ago

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.

thomakl commented 1 year ago

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,

benoitvalery commented 1 year ago

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

thomakl commented 1 year ago

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 ?

benoitvalery commented 1 year ago

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.