Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch failed mixer init in legacy backend #541

Closed
smathot opened this issue Jun 14, 2017 · 3 comments
Closed

Catch failed mixer init in legacy backend #541

smathot opened this issue Jun 14, 2017 · 3 comments

Comments

@smathot
Copy link
Collaborator

smathot commented Jun 14, 2017

Currently, a pygame.error sometimes occurs when calling pygame.mixer(). This prevents running the experiment, but could easily be caught to at least allow for soundless experiments.

@smathot smathot closed this as completed in 8bf615f Jul 6, 2017
@JdenHartog
Copy link
Contributor

Hi Sebastiaan,

When trying to fix this for the Psychopy back-end as well by changing openexp/_canvas/psycho.py

	pygame.mixer.init()

to

	try:
		pygame.mixer.init()
	except:
		print(u'openexp._canvas.psycho.init_display(): failed to initialize mixer')

I think I discovered pygame.mixer is also initialized by sampler (even when not using a sampler item).
The output I get when running the default template with the psycho back-end acknowledges this see
openexp.sampler._legacy.init_sound(): below

Starting experiment as ExperimentProcess-3
C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp_canvas\psycho.py:56: UserWarning: Your PsychoPy version is outdated. To draw complex shapes that include holes, concavities, etc., please update to PsychoPy version 1.84.1 or higher.
warnings.warn(u'Your PsychoPy version is outdated. To draw complex '
openexp._canvas.psycho.init_display(): waitblanking = True
openexp._canvas.psycho.init_display(): monitor = testMonitor
openexp._canvas.psycho.init_display(): screen = 0
openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 1024
openexp.sampler._legacy.init_sound(): mixer already initialized, closing
experiment.run(): experiment started at Wed Jul 26 14:20:19 2017
experiment.run(): disabling garbage collection
experiment.run(): experiment finished at Wed Jul 26 14:20:21 2017
experiment.end(): enabling garbage collection
done!

Shall I make a pull request for removing

	pygame.mixer.init()

from openexp/_canvas/psycho.py? Or do you think this will break something on Mac OS or Ubuntu systems?

@smathot
Copy link
Collaborator Author

smathot commented Jul 27, 2017

Thanks for looking into this. Yes, I don't see why initializing the mixer in the PsychoPy canvas is necessary, or even makes sense. So feel free to remove it.

As a suggestion (which is not relevant if you're going to remove the init altogether), it's always better to specify which Exception you will catch, instead of doing a black except:. So: except pygame.error: in this case.

@smathot smathot reopened this Jul 27, 2017
JdenHartog added a commit to JdenHartog/OpenSesame that referenced this issue Jul 27, 2017
Removed `pygame.mixer.init()` as it is initialized by *openexp.sampler._legacy.init_sound()*. This further fixes open-cogsci#541
@JdenHartog
Copy link
Contributor

OK. great! > Done!

You think it would be safe to remove this for the expyriment back-end two? Deleting:

if defaults.audiosystem_autostart:
    mixer.init()
    mixer.init() # Needed on some systems

And if you want me to make a pull-request for that; on what branch?

JdenHartog added a commit to JdenHartog/OpenSesame that referenced this issue Aug 10, 2017
Set audiosystem_autostart to *False*. This skips the `mixer.init()' in [_experiment_control.py
](https://github.com/smathot/expyriment/blob/master/expyriment/control/_experiment_control.py#L303) as it is initialized by openexp.sampler._legacy.init_sound(). This further fixes open-cogsci#541
smathot pushed a commit that referenced this issue Aug 17, 2017
Set audiosystem_autostart to *False*. This skips the `mixer.init()' in [_experiment_control.py
](https://github.com/smathot/expyriment/blob/master/expyriment/control/_experiment_control.py#L303) as it is initialized by openexp.sampler._legacy.init_sound(). This further fixes #541
smathot pushed a commit that referenced this issue Sep 22, 2017
Set audiosystem_autostart to *False*. This skips the `mixer.init()' in [_experiment_control.py
](https://github.com/smathot/expyriment/blob/master/expyriment/control/_experiment_control.py#L303) as it is initialized by openexp.sampler._legacy.init_sound(). This further fixes #541
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants