[open] Stop Sampler playing music (using key e.g. ENTER)
Currently doing a project where sentences are presented alongside background music. The background music is presented 3000 ms before the sentence is presented and then continued as long as the participant reads the sentence. This is all working, but when you push ENTER to go to the question paired with the sentence, the music keeps on playing.
The music files are around 30 - 40 seconds so what also happens when you go to trial 2, 3 and 4 is that new music files are simply added to the already playing music, so that you have 3-4 music items playing at once.
How do I get the music to stop playing alongside the sentence, by using ENTER or similar.
Atm i'm using the sampler item and not an incline code.
Ola
Comments
It would actually be nice to be able to include a white screen/ canvas during the 3 seconds of music playing without the sentence.
Hi Ola,
What Josh suggested in the other thread is a good way to solve your issue. So, basically, instead of using the
sampleritem, you should play the files from within aninline_script, actually, twoinline_scripts.First, you replace the
samplerwith the firstinline_scriptand put this code into it:Then, you do the other stuff you intended to present, as soon as subjects pressed a key (specify with the
allowed_responseargument, whichever you want). After yourkeyboard_response, e.g. as last thing to be executed before you start the next trial, in which you place the single line:sound.stop(). Et voila, there you go.Let us know, if this worked out for you.
Good luck,
Eduard
NO it doesn't work. Have three inline scripts at the moment. None of them are doing what they are supposed to do.
script one RUN
script one prepare
script two Prepare
script two run
not working.. the music stops playing after 3 ms so no music here and keyboard response doesn't work.
Sorry. Just getting slightly frustrated as nothing is working at the moment.
I suppose you are running Opensesame 2.9.x? In this case
clock.time()is not defined, right. Instead, you can useself.time(3000); it will have the same effect.Why? You can still do exact same thing. The only difference is, that you have retrieve your [Noise] variable (I suppose you define it in the
loop_table):noise = exp.get(Noise)sound_file = exp.get_file(noise)This won't work. I either you go entirely for the option of doing this with
inline_scripts. Then, I highly recommend you checking out the documentation of how to do things withinline_scripts.Basically, something like this will do the trick:
Alternatively, you just use the
keyboarditem as you did before, and add anotherinline_scriptlater on.I hope things make more sense now. No reason to despair.
Eduard