Howdy, Stranger!

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

Supported by

Synth cannot play G# (G-sharp)

edited December 2023 in OpenSesame

Hi, using Synth to play sounds. It works fine except it refuses to play G-sharp (g#). Using OS4

Calling my_sound = Synth(osc=u'sine', freq=u'g#1', length=200, attack=0, decay=20) results in a crash with the following message:

UnboundLocalError: cannot access local variable 'f' where it is not associated with a value

Octave does not matter. g0# and g2# also fail.


Other tones, like f# are fine (I have tested them all, only g# fails)

my_sound = Synth(osc=u'sine', freq=u'f#1', length=200, attack=0, decay=20)


Also replacing g# with its frequency (861 Hz) works fine:

my_sound = Synth(osc=u'sine', freq=861, length=200, attack=0, decay=20)

So I have this workaround, but I thought it's still worth reporting this quirk.


Also, what is the symbol for flat, as in B-flat, if there is any?


thanks, best,

Chris

Comments

  • Hi Chris,

    Yes that's a small bug in the source code. Thanks for spotting. I suggested a fix and probably it is going to be resolved in the next maintenance release.

    Also, what is the symbol for flat, as in B-flat, if there is any?

    Flat is just a b .

    So, gb for g flat. In case you wanted to replace g# with ab, that is not going to work at the moment, as the bug affects that one as well.

    Octave does not matter. g0# and g2# also fail.

    Small note here, the # must be before the octave. So this order would not work for any of the tones.

    Thanks,

    Eduard

    Buy Me A Coffee

  • @eduard @sebastiaan

    Thanks guys! I seem to hit another snag:

        my_sound.volume(0.5) results in "TypeError: 'float' object is not callable"

    my_sound is defined as a synth object, and is playing. other functions work fine, like my_sound.play() and my_sound.wait().

  • Hi Chris,

    I don't think this is how you set the volume. You probably want to use the set_config() method or pass it as keyword argument to play.

    Synth objects are essentially Sampler objects for which the sound is generated first. So, check out the the sampler docs to see some usage examples.

    Eduard

    Buy Me A Coffee

  • edited January 3

    Hi Eduard,


    Thanks, but while sampler accepts a volume key word, synth does not.

    what does seem to work is:

    synth_object.volume = .5
    


    best

    chris

  • Hi Chris,

    Doing it like this works:

    my_sound = Synth(osc=u'sine', freq=u'f1', length=200, attack=0, decay=20)
    my_sound.set_config(**{"volume":0.1})
    my_sound.play()
    

    However, I realized that using the psychopy backend no sound is played, whereas for legacy and expyriment it is. @sebastiaan are you aware of this?

    Eduard

    Buy Me A Coffee

  • Hi @chris_olivers and @eduard ,

    The standard way to change the volume is by setting the volume property, as Chris already found out:

    synth_object.volume = .5
    

    Alternatively, you can pass the volume keyword when initializing the Synth or Sampler or when calling the play() function. (However, there is indeed a bug in the Synth object such that it doesn't accept this keyword during initialization. I'll fix that shortly.)

    See also:

    The set_config() function is mainly for internal use. It works, but I wouldn't use it because it's not very readable.

    The set_volume() function (and other similarly named functions) were already deprecated for a long time and were finally removed in OpenSesame 4.0.

    However, I realized that using the psychopy backend no sound is played, whereas for legacy and expyriment it is. @sebastiaan are you aware of this?

    I suspect that this is specific to your system. Are you missing some of the libraries that psychopy uses for sound playback?

    — Sebastiaan

  • Hi Sebastiaan,

    Thanks for clarifying.

    The standard way to change the volume is by setting the volume property, as Chris already found out:

    My bad! I misread Chris' post, thinking that this didn't work.

    Eduard

    Buy Me A Coffee

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