Howdy, Stranger!

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

Supported by

[solved] How to get the actual duration of a sound when "Duration" is set to 0 ms?

edited June 2015 in OpenSesame

Hello,

In my task, subjects hear a tone. As soon as the tone starts, they need to count using key presses until the tone stops. I use a synth item to present the tone, and an inline script to get the key presses. The duration of the synth item is set to 0 ms, so that I can collect responses while the tone is still playing. Now I would need to know how long the tone was played exactly (to check the timing accuracy, etc.). Without the response collection, I would log self.time() before and after the synth item is run, but that is not possible in this case. Does the synth item perhaps have something like a "end_time_synth" property?
It would be great if someone could help me out!

Kind regards,
Sabine

Comments

  • edited 11:56PM

    Hi Sabine,

    If you click on your synth item in the overview, you'll see the parameter "Length" above the "Duration" parameter. That value represents how long the tone was played. If you want to control the length per condition, you just determine the value beforehand, in an inline_script or loop item, (e.g. your_tonelength = 150), and then refer to the variable in your synth item, meaning you'd insert [your_tonelength] in the "Length" box.

    Good luck!

    Josh

  • edited 11:56PM

    Hi Josh,

    Thank you for your reply. I am actually already controlling the "Length" parameter (i.e., I have a [tone_dur] variable specified in a loop and the "Length" parameter of the synth item refers to [tone_dur]. What I want to know is how long the tone was "really" presented. If I would not have the response logging while the tone is still playing, I could simply look at the time when the synth item has finished and subtract from that the start time of the synth item. When I did that, I received deviations from the duration specified in [tone_dur] of about 8 ms (on average). I would like to know whether this deviation magnitude applies also to the current situation, where I do not simply let the synth item finish, but where I move on to an inline script in which I am waiting for key responses.

    Best,
    Sabine

  • edited 11:56PM

    Hi Sabine,

    Did the 'real' time also deviate below your indicated tone_dur? I suspect that there might be an 8ms lag in the initiation of the tone, but not in the tone itself, meaning that the real duration of the tone is always tone_dur. However, if you got deviations below tone_dur this can't be the case; in which case I'd still have to figure out an explanation...

    Cheers

  • edited June 2015

    Hi Sabine,

    Very good question. There is no programmatic way of knowing the actual sound duration. You will have to use an external device to monitor the sound.

    I would advise to test the system that you use for sound output: have OpenSesame produce sounds of [tone_dur], and record those sounds. You can check the length of each tone in the recording using audio editing software (e.g. Audacity). This can give you an indication of the variability of you sound card.

    The higher quality your computer's sound card is, the less latency there will be in starting and stopping sound playback.

    Alternatively, you could opt for using sound files with a sampler (of which you know the exact length) rather than creating sounds on the spot (with the synth). Sometimes this decreases latency issues (at least within the sound).

    Good luck!

    Edwin

  • edited 11:56PM

    Hi,

    Thanks for your answers. The deviation between the desired duration and the real duration when using a synth item were both positive and negative (ranging from -9 to 26 ms).

    Regards,
    Sabine

  • edited 11:56PM

    That's quite a bit of variability; very annoying. Unfortunately, this is an issue of the sound card...

    Have you tried my suggestion using sound files instead of the synth? Does that work better?

  • edited 11:56PM

    Hi guys,

    Just my 2 cents, to confirm what @Josh said:

    I suspect that there might be an 8ms lag in the initiation of the tone, but not in the tone itself, meaning that the real duration of the tone is always tone_dur.

    Indeed, the synth simply generates a tone of the specified duration, and then uses it as a sound file for the sampler. So there is no difference (in this respect) between generating a tone yourself and passing it to the sampler, and using the synth item.

    But because the computer doesn't know perfectly when playback starts and stops, it seems as though the actual sound duration differs--even when it doesn't. If you'd record the sound and analyze it, like @Edwin suggests, it should always be the same length.

    An exception is, of course, when playback stutters. In that case, all bets are off.

    Cheers!
    Sebastiaan

  • edited 11:56PM

    Sorry, I must've misunderstood: I thought @SabineS did measure the sound lengths?

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