Howdy, Stranger!

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

Supported by

[open] PyO in OpenSesame

edited October 2015 in OpenSesame

Dear coders/researchers,

I would like to use Pyo (0.7.7) for sound presentation/manipulation in OpenSesame (2.9.7) via the Inline_Script item. As OpenSesame uses PsychoPy and Psychopy (in turn) utilizes Pyo, I figured it should work. So I decided to run the Pyo examples from within OpenSesame to get a first impression.

This is the code i used:

import sys

sys.path.append("/Library/python/2.7/site-packages/")
sys.path.append ("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7")

from pyo import *

s = Server(duplex=0).boot()
s.start()
a = Sine(440)
a.out()
time.sleep(1)
a.stop()

However, OpenSesame crashes as soon as s.start() is called. Interestingly, this code (without the time.sleep(1) and the a.stop() line) correctly generates a sound if written line-by-line in the debug window in OpenSesame.

What am I missing? Is it because Pyo is already implemented in PsychoPy? Does PsychoPy provide full functionality of the Pyo features? I hope you can help me because Pyo is a wonderful module with lots of interesting features for DSP. Currently. it's running on MacOS X (10.11), but Windows is also available. So both experiences are welcome :-).

Cheers,

Malte

Comments

  • edited 1:26PM

    Hi Malte,

    PyO looks very nice. Please let me know how this works for you, because it could be something to use by default in OpenSesame. (The PyGame sound module is quite poor.)

    What might happen in your case is that the pygame sound mixer causes trouble. This would explain why the code works when entering it in the debug window, but not when embedded in an experiment.

    If, in the debug window, you enter the following lines before anything else, does s.start() freeze as well?

    import pygame
    pygame.mixer.init()
    

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 1:26PM

    Hi Sebastiaan,

    thanks for the quick reply. The s.start()-command from PyO still works (from the debug) window when pygame is imported first and the mixer is initialized before any PyO-related commands are given.

    Is it possible to try this the other way around by *disabling" the pygame mixer before calling the PyO commands?

    Moreover, I noticed in the debug window that another mixer had been initialized. The line reads : openexp.sampler._legacy.init_sound(): mixer already initialized. This mixer seems to be rooted in the legacy backend, right? Might that be a hint?

    Or have you any other suspects in mind?

    Thanks in advance,

    Malte

  • edited 1:26PM

    Hi Sebastiaan, hi all,

    any ideas on how to tackle the problem with Pyo? I get the same problem on a Windows (7) machine: the s.start() command works from the debug window but freezes OS when run from an inline script item. I have not tried it on linux yet, which might be an alternative for me. Changing the backends (as part of a desperate attempt to fix it :-)) has no effect either.

    I read here that PsychoPy uses Pyo as sound library. Is that where the problem is rooted? I will try to find hints in the PsychoPy documentation, but perhaps you have an idea if that might be the case.

    As a rather quick & dirty workaround: Is it possible to (temporarily) disable all modules/processes etc. that OpenSesame natively uses to present sounds? All sound presentation should be handled by Pyo in my experiment, so that would cause no problem.

    I really hope that Pyo will work from within OS.

    Thanks a lot in advance!

    Cheers,

    Malte

  • edited 1:26PM

    Hi all,

    Got the same problem on debian linux. First tried it with psychopy, which results in a freeze of opensesame (pygame works correctly with psychopy) and then directly through pyo which ends the experiment when it reaches the pyo code.

    Anyone solved this problem already?

Sign In or Register to comment.