Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Problem in the sound of audio files presentation

Hello,
I have experienced an apparent random problem when I present audio stim using Expyriment. Sometimes, the recorded sound comes along with some white noise. I am using wav files recorded using Audacity. I stress the problem is not related to specific files. For the same file, this problem sometimes happens, sometimes it doesn't. I have alternatively tried to convert the files to mp3 but then I ran into another problem: I get no sound at all even trying many different codecs, such as ffmpeg libmp3lame.

I am using Expyriment 0.7.0 (Revision 7a6b73d) with Python 2.7 in a linux machine using Ubuntu 16.04.

Thank you very much in advance.
Best,
Ana Luísa Pinho

Comments

  • rrrrrr Posts: 78

    Hi anapinho,

    Have you checked the audio settings (buffer size, audio devices you are using, and so on)?

  • fladdfladd Posts: 69

    Dear anapinho,

    as rrr mentioned, this sounds like an issue with a too low audio buffer. Did you change the audio buffer to a custom value? The default is 2048, which should be high enough. You could try increasing it even further with expyriment.control.defaults.audiosystem_buffer_size = 4096 (this needs to be set before initializing Expyriment).

    Could you also check the specifics of the wav file? What is the bitrate of that for instance?

    Florian Krause (Developer)
    http://www.expyriment.org

  • anapinhoanapinho Posts: 10

    Hello,
    Thank you for your suggestions.

    These are the specifications of my wav files:
    RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

    I tried to increase the expyriment.control.defaults.audiosystem_buffer_size to 8192 and I still get the same problem. One thing I noticed is that if I open and close twice a file in vlc while running expyriment, the problem is solved. Even though it might be a short-term solution, I still would like to find a more stable long-term solution to this problem.

    Best,
    Ana Luísa

  • fladdfladd Posts: 69
    edited February 15

    Very strange. Could you maybe send me one of the files? Then I can check if it works here.

    Florian Krause (Developer)
    http://www.expyriment.org

  • anapinhoanapinho Posts: 10

    Hello,
    I am not allowed to attach .wav files. Is there any other way I can send it to you?

    Thank you.
    Ana Luísa

  • fladdfladd Posts: 69

    Depending on the size, you could send it to florian@expyriment.org, or alternatively, send it via services like https://wetransfer.com/

    Florian Krause (Developer)
    http://www.expyriment.org

  • fladdfladd Posts: 69

    I just tested with the audio files you sent me and the following script:

    import expyriment as xpy
    
    
    exp = xpy.control.initialize()
    
    s1 = xpy.stimuli.Audio("nord_ou_sud.wav")
    s2 = xpy.stimuli.Audio("ouest_ou_est.wav")
    s1.preload()
    s2.preload()
    
    for x in range(10):
        s1.play()
        xpy.control.wait_end_audiosystem()
        s2.play()
        xpy.control.wait_end_audiosystem()
    

    This worked fine on my computer. I tested with a newer version of Expyriment, though, but that should not make a difference, as there were no changes with regards to audio playback. Does the problem occur with this particular script on your computer? If not, can you send me a script that does show the problem?

    Also, it might be worth to check which Pygame version you are using. I tested with 1.9.3.

    Florian Krause (Developer)
    http://www.expyriment.org

  • anapinhoanapinho Posts: 10

    Hello,
    I am using '1.9.2b8'. Do you think I should upgrade to 1.9.3? I can send my expyriment program if you want, even though it contains many other things. But I am basically loading my Audio, using the same object as you did, i.e. stimuli.Audio().

  • anapinhoanapinho Posts: 10

    Hello once again,
    How did you install pygame 1.9.3? I installed it through pip and I just did an upgrade and I still get the same (apparently beta version).

  • fladdfladd Posts: 69

    python -m pip install -U pygame should just work fine. If the installation of Pygame 1.9.3 worked, then you should also get this version when you install it. I don't think two pygame versions can be installed in parallel in the same Python distribution. Are you using different Python installations or virtual environments?

    Florian Krause (Developer)
    http://www.expyriment.org

  • anapinhoanapinho Posts: 10

    Hello,
    I have re-installed pygame to the newest vs, i.e. 1.9.3. I removed the old installation. After several trials (since the problem was apparently random), it seems the problem disappeared. I thus believe it was related to my beta vs of pygame. Thank you very much for your feedback. It helped to solve the problem. :)

  • fladdfladd Posts: 69

    Great to hear the issue is solved!

    Florian Krause (Developer)
    http://www.expyriment.org

Sign In or Register to comment.