Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Creating Device Selection for Playback  (Read 2025 times)

0 Members and 1 Guest are viewing this topic.

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
Creating Device Selection for Playback
« on: January 06, 2014, 04:08:05 am »
OK, so it's gotten to the point where, either SFML will need to be adapted, or I will need to use libsndfile and openAL directly myself and bypass SFML altogether for audio playback.  However, I was looking at the changes that were done to make SoundRecorder's device selectable, and I think I could do it myself, but I wanted to discuss with the dev(s) on here how exactly they would prefer to have it done.  I have thought of two ways thus far:

Expose a setDevice() function somewhere (like in SoundRecorder), but have it change the global AudioDevice variable, or
Have Sound.cpp have its own device and context values that default to those provided by the AudioDevice (much more complex).

It would make more sense to have an overall selection, I think, rather than each sound being able to have its own, but how do I expose a setDevice() function to modify AudioDevice, and where?  I assume, since AudioDevice and ALcheck are in the priv namespace, they aren't visible outside of the SFML code itself, but if a setDevice() function were to be placed in Sound that then called an AudioDevice.setDevice() function to change the global variable, then nothing in AudioDevice itself would need to be exposed to public usage.  I definitely think the current functionality still needs to be the default, because a lot of people would have no use for the new stuff, and would be thrown off if it wasn't included.  But there are those of us who want to stay in the family, as it were, and still have functionality such as this.  It would certainly make things easier for me in my soundboard program.

Laurent, what do you think?

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Creating Device Selection for Playback
« Reply #1 on: January 08, 2014, 01:29:43 am »
Alright, just as a matter of clarification, this is merely a post asking how I should go about adding the ability to select and/or change the playback device SFML is using.  There are at least three ways of going about it (the third being exposing AudioDevice to public usage and putting a setDevice() function in there), and I'm willing to do it and do the testing and such, I just don't want to do it one way and have Laurent say "I actually wanted it done this other way" after I'm done.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9984
    • View Profile
    • development blog
    • Email
Re: Creating Device Selection for Playback
« Reply #2 on: January 08, 2014, 01:20:04 pm »
I'd definitely be interested in seeing a device selection for SFML. It's not something everyone needs, but it's something that give a lot more freedom to developers.

SFML should if nothing explicitly selected use the default device. :)

As for the implementation we just have to wait till Laurent has time to answer.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Creating Device Selection for Playback
« Reply #3 on: January 13, 2014, 12:39:48 am »
Yeah this is a great idea! I actually thought about this when I implemented the device selection for the recording, but I never actually looked into it.
If there is only supposed to be one playback device for all sounds (and music), then I would suggest putting a static setPlaybackDevice (and the corresponding static getAvailablePlaybackDevice() and static getDefaultPlaybackDevice()) methods in sf::Sound. Those would then interact with AudioDevice.
I'm not really sure how to go about each sound being able to set it's own playback device.
We'll have to see what Laurent says.
And of course if nothing else is specified the default device should be selected.
If you need help coding or testing, I'd love to help!

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Creating Device Selection for Playback
« Reply #4 on: January 13, 2014, 02:57:55 am »
Yeah, I really don't think it would be necessary to have each sound capable of using its own device, just changing the core device would be enough.  I could probably put it together both in AudioDevice and in Sound pretty easily.  Suppose I should do both separately, test them, and then submit separate pull requests and let Laurent take it from there?

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Creating Device Selection for Playback
« Reply #5 on: January 15, 2014, 12:51:40 am »
Yep, that's the way I'd do it.