Howdy, Stranger!

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

Supported by

Issue when using two samplers

edited October 2023 in OpenSesame

Hi all,

I am currently designing a study and I'm stuck when trying to use multiple samplers. The general idea is that people can look at two regions of interest, a left square or right square. If they look at the left one, they hear audio stream 1 and if they look at the right square they hear audio stream 2. If they look at none of them they hear nothing.

I tried to implement this (see code below) by creating two samplers, each with a different audio file. Whenever people switch their gaze to a different region of interest, the currently playing sampler is paused and the correct one is resumed.

However, when I'm trying to resume one of the samplers after it has been paused, both samplers start playing simultaneously. If i change the "sampler.resume()" code to "sampler.play()" it does play the correct sampler but it starts again from the start of the audio file, which is not what I want.

*Here's a link to a simple experiment with this code (couldn't add it as attachment): https://drive.google.com/file/d/18UAdcclJXKdjaekdLp3XkVVkL-7NgrGF/view?usp=sharing. The mouse cursor can be used to emulate eye movement (also make sure to change the folder path). This was written in OpenSesame 3.3.12 but I have the same problem with the latest version (4.0.5).

Any help is welcome :).

Best,

Christophe

  import time

# draw simple canvas with regions of interest represented as a rectangle (ROIs)
my_canvas = Canvas()
my_canvas["left_rect"] = Rect(-650,-200,400,400)
my_canvas["right_rect"] = Rect(250,-200,400,400)
my_canvas.show()

# load ".wav" files and load them in seperate samplers
folder_path = "fill_in_path_to_wav_files"

random_sampler = Sampler(folder_path + "random_stream.wav")
random_sampler.block = False
random_sampler.play() # the idea is to play and pause the sampler quickly, so it can be resumed later (otherwise extra flags are needed)
random_sampler.pause()

structured_sampler = Sampler(folder_path + "structured_stream.wav")
structured_sampler.block = False
structured_sampler.play() # the idea is to play and pause the sampler quickly, so it can be resumed later
structured_sampler.pause()

# flag that stores what is currently being looked at/ what stream is playing
currently_playing = None

# timer for while loop
duration = 10
duration_end = time.time() + duration

# loop until duration is over
while time.time() < duration_end:

  x, y = eyetracker.sample() # Get the fixation location

  if x > 310 and x < 710 and y > 340 and y < 740: # if in left ROI, play structured stream

    # pause random stream if it is playing, then resume the structured stream

    if currently_playing == "random":
      random_sampler.pause()

    if currently_playing != "structured":
      structured_sampler.resume()
      currently_playing = "structured"

  elif x > 1210 and x < 1610 and y > 340 and y < 740: # if in right ROI, play random stream

    # Pause structured stream if it is playing, then resume the random stream

    if currently_playing == "structured":
      structured_sampler.pause()

    if currently_playing != "random":
      random_sampler.resume()
      currently_playing = "random"

  else: # if outside of ROIs, pause stream that is currently playing

    if currently_playing == "structured":
      structured_sampler.pause()

    elif currently_playing == "random":
      random_sampler.pause()

    currently_playing = None

Comments

  • Hi @chvhouwe ,

    Thanks for reporting this. Indeed, when using the legacy backend (and in OpenSesame 3.3, also the psycho with legacy sound backend), the pause/resume functions operate on all channels, rather than on individual samplers. Now that this is on the radar, it will be fixed in an upcoming maintenance release. For now, you can use the psycho backend (if that is suitable for your experiment), which does not suffer from this issue.

    — Sebastiaan

  • I see, I'm glad that it's such an easy fix. It does indeed work as intended when using the psycho backend. Thanks a lot!

    Christophe

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