Howdy, Stranger!

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

Supported by

Play sound from a list based on key response until participant chooses to move on

edited December 3 in OpenSesame

I want to create a loop in which participants can choose to press "1" or "2" to trigger a sound to be played at random from a corresponding sound list. For instance, there may be the following lists of sounds:

List1: 1a.wav, 1b.wav, 1c.wav

List2: 2a.wav, 2b.wav, 2c.wav

Within a loop, participants would see a Sketchpad that says "Press 1 or 2 to hear a sound from the corresponding list." They could then repeatedly press "1", for instance, to hear sounds from that list (one per click, at random), or they could alternate between pressing "1" and "2" to hear sounds from either list.

Once they are satisfied, I want there to be a third option for participants to press, like "0", to move on to the next portion of the experiment.

I believe this will involve a keyboard_response within a loop with allowed responses "1; 2; 0" (for instance), and nested items (of some sort?) which are run conditionally in the sequence depending on which key response is given ("1" or "2", and with "0" triggering the whole loop to end).

Any advice on how I might go about this complex process?

Comments

  • Hi @JKellogg,

    There are probably several ways to do this., but here's one method that is realtively economical.

    Here's the logic:

    1. Set Up the Experiment

    • Add all your sound files (e.g., 1.ogg, 2.ogg) to the File Pool.
    • Use Inline Script items to manage dynamic behavior.

    2. Task Workflow

    Step 2.1: Initialize Variables

    • Before starting the task, create two shuffled lists of sound file names (one for each key, e.g., 1 and 2).
    • Set up a mechanism to track which sounds have been played and reset the list once all sounds are used.

    Step 2.2: Main Loop

    • Create a Loop item to repeat the task until a specific key (e.g., 0) is pressed.

    Step 2.3: Participant Instructions

    • Use a Sketchpad to display instruction

    Step 2.5: Select a Sound

    Add an

    • Inline Script

    to:

    • Determine which key was pressed.
    • Pick the next sound from the corresponding list.
    • Remove the played sound from the list.
    • Reset and reshuffle the list if it is empty.

    Step 2.6: Play the Sound

    • Dynamically play the selected sound using Python (instead of the sampler; I found this to work best because the sample appears to be set in the prepare phase and in my tests I didn't present the sound selected from the code executed immediately before but only did so on the next trial).


    A couple of additional comments:

    • I set "run if" of the loop to only execute the code playing the sound if end_experiment is false (this is the variable used to break the loop if the participant presses 0).
    • I used 1.ogg. 2.ogg, 3.ogg as my list 1, and 4.ogg, 5.ogg, 6.ogg as my list 2 (replace with whatever sounds you're using).
    • the loop as only one row but 100 cycles and a break if condition

    Here's my version. You should be able to adapt it to meet your needs:

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • I was able to get this to work perfectly, thank you!

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