Music throughout experiment
in OpenSesame
Hello,
I want a music file to play throughout an experiment. I'm using it as an auditory distraction throughout the whole experiment. It will currently play but will only go to the next stage of the experiment when the song has finished. Is there any way that I can get the music file to play once completely for the whole experiment?
thanks in advance!
Comments
Hi @DK21 ,
Are you running your experiment locally or online?
It will currently play but will only go to the next stage of the experiment when the song has finished.
Indeed, OpenSesame runs the items in
sequencesin a sequential way. Therefore, what you are trying to do sounds a bit complicated (at least for me) to achieve withoutcoroutinesand/or Pythoninline_script, which are both not supported in OSWeb.Cheers,
Lotje
Did you like my answer? Feel free to

Hi Lotje,
I'm running it locally. Thanks for your reply and for that information. This is all new to me and I'm a bit lost 😅
cheers
Damien
Hi @DK21 ,
Ok, good to hear that you are not running the study online. ;-)
Could you upload the script of what you programmed so far (by clicking the paperclip icon)? Then I can give it a thought.
Cheers,
Lotje
Did you like my answer? Feel free to

Hi @DK21 ,
Sorry, I was totally overthinking this one. It's actually as simple as appending a sampler item to the very beginning of your experiment and settings its duration to 0. (Works both locally and online.)
Sorry for the confusion! ;-)
Cheers,
Lotje
Did you like my answer? Feel free to

Hi Lotje,
Thats great, thank you for getting back to me, much appreciated.
Hi,
Related to this discussion, how to play background music (or sound) repeatedly until the end of experiment?
Sometime we want to play BGM or sound stimuli repeatedly and automatically from first when the BGM ends.
Thanks
Hi @rrr
Have you tried the above solution? (i.e., add a sampler item with your sound at the beginning of the experiment, and set the duration to 0)
Duration indicates the duration of the sampler item, before the next item is presented. This doesn't need to match the length of the sound file. For example, if the duration of the sampler is set to 0 ms, OpenSesame will advance directly to the item that follows the sampler (e.g., a sketchpad), while the sound file continues playing in the background. Sound // OpenSesame documentation
It should work as expected, but let us know if you encounter any problems.
Claire
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖
Hi, @cvanbuck
Yes, already tried.
The BGM is played, but it is not played repeatedly from the first of BGM.
I know that repeating music is possible by adding codes in inline_script after the sampler as below.
My question is how we can do that without inline_script.
Thanks
Hi @rrr
If you're looking to repeat background music without using any
inline_script, a simple workaround is to create a longer audio file e.g., by using Audacity to copy-paste the tracks multiple times, re-arranging them as you like. Then, play this extended file at the beginning of your experiment using a sampler item set to duration 0, so it continues in the background.It’s not as elegant as looping via code, but it can work well if the experiment has a fixed duration or if you use a long enough audio file to cover the max duration of your experiment.
Another workaround would be to add multiple sampler items at different points in your experiment where you estimate the audio might end, to re-trigger the playback without scripting. Again, not as elegant as code, but can work well if your estimations are accurate.
Hope this helps,
Claire
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖
Hi @cvanbuck ,
Thank you for the information! This discussion is very helpful for every researchers to make experiments with BGM.
There are 3 options for repeating BGM;
Thanks a lot