Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] "Cancel" sampler playback on keypress?

edited April 2012 in OpenSesame

Hi there!

I am just trying to build up an experiment in which subjects have to respond to an audio stimulus as quickly as they can, with a maximum of 1000ms after the audio playback is finished to respond. However, I'd like them to be able to respond even while the file is still playing. Now I've managed to do that on the surface in a sequence of sketchpad->sampler->keyboard_response->logger, but I have to either live with having the sampler play out and then waiting for the keyboard_response to collect a response that was given while playing, which makes me unsure of how to deal with the response time, or I manage to skip from sampler with finish on keypress and timeout set to the files duration for the sampler, but then the sampler keeps playing into the next stimulus. So, I guess my question essentially is whether it is possible to somehow "stop" or "cancel" all samplers that are currently playing audio at the end of my sequence?

Thanks, Florian.

Comments

  • edited 1:17AM

    Hi Florian,

    Yes, sure. You can achieve this with (something like) the following sequence.

    • a sampler with the duration set to 0 ms, so that it advances immediately to the keyboard_response
    • a keyboard_response to collect the response
    • an inline_script with the following code:
    import pygame
    pygame.mixer.stop()

    This directly accesses the PyGame mixer. You can find out more about this here: http://www.pygame.org/docs/ref/mixer.html

    Does this work for you and/ or answer your question?

    Cheers and happy Easter!
    Sebastiaan

  • edited 1:17AM

    Thank you Sebastian, that works a treat!

    I've also added an inline script to the beginning of the loop, setting the variable response_timeout to the duration of my cue (which I have extracted before and inserted into the loop's table) + 1000, and then set the timeout in the keyboard_response to [response_timeout] to give the 1s timeout after playback is finished.
    cue_duration = self.get("cue_duration")
    self.experiment.set("response_timeout", cue_duration+1000)

    Just in case anybody diggs this up in the future :-)

    And a happy Easter to you too! Florian

  • edited February 2020

    Hi All,

    I am building a Stroop experiment (words) where during the trial the participant has to listen to some music (to test its effects on Stroop performance), I have built the experiment and all is working as expected, except one thing:

    I have the following

    • Loop
    • sequence
    • sampler (sound file .ogg)
    • fixation point
    • sketchpad
    • keyboard response
    • logger
    • inline script (which stops the music once all trials are complete).

    The problem is, because the 'sampler' is in a 'sequence', after every stimulus (word + keyboard press) the music is repeating itself and gets all scrambled.

    I just want the music to play once continuously during the trials, and then end, (the end section works fine), I just cant figure out to stop the music repeating itself during the loop of trials.


    Help, I am so close to finishing this experiment, just need to nail this final bit.

    Thanks


    Paul

  • Hi Paul,

    If I understand correctly, the only thing you need to do is to put the sampler with the music at the start of the experiment sequence, rather than in the trial sequence. That way it will start once, and keep playing in the background while the experiment continues.

    Cheers!

    Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games