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

Author Topic: Ability to chose sound input device  (Read 9122 times)

0 Members and 1 Guest are viewing this topic.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Ability to chose sound input device
« on: April 27, 2012, 11:59:32 am »
Hello!
While playing around with the audio library I noticed that I couldn't change the device that inputs the audio data (i.e. microphone). My laptop has a build in mic, but I would rather use a better microphone, that I plug in the back.
I saw in https://github.com/SFML/SFML/blob/master/src/SFML/Audio/SoundRecorder.cpp#L81 that SFML always uses the default device. Could there be a function added that lets you chose the audio input device?

Thanks,
Foaly :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ability to chose sound input device
« Reply #1 on: April 27, 2012, 12:15:20 pm »
It could be considered. So you should open a new issue on the tracker so that I don't forget it (make sure thatit doesn't exist yet first) :)
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #2 on: April 27, 2012, 06:59:45 pm »
I checked the issue tracker this time before posting ;) and I didn't find one. But I'm not gonna be at my computer for the next couple of days, so I can't create a ticket. I'll do that once I get home, if nobody else did it :)
I'd really love to see this feature being implemented :)

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Ability to chose sound input device
« Reply #3 on: April 28, 2012, 01:05:21 am »
It's a cool thing and something that should be supported in the future I think. Though the priority on it shouldn't be that big since as I understand SFML uses the default input device which is set by windows. I think it's 100% viable to depend on that. I for instance know that Skype doesn't work well with the drivers for my sound card at my workstation and it always only show like one input even if I have several(which is the default input set by the drivers) and so on.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #4 on: May 04, 2012, 07:47:13 pm »
Ok I added a issue to the tracker: https://github.com/SFML/SFML/issues/220
Also I did some research and found that it's not to difficult to implement. The OpenAL function
Code: [Select]
alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);returns a list of the available devices. That could be stored and the user could chose the right device via a function. (I also added that information to the issue)

edit: I wasn't able to put the issue in any category (not sure if I'm not supposed to or if i couldn't find it...) It belongs in audio and feature anyway.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ability to chose sound input device
« Reply #5 on: May 04, 2012, 08:38:38 pm »
Quote
I wasn't able to put the issue in any category
Tags are added by the project managers.
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #6 on: May 04, 2012, 08:46:57 pm »
ok perfect!

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Ability to chose sound input device
« Reply #7 on: May 06, 2012, 02:19:14 am »
It could be considered. So you should open a new issue on the tracker so that I don't forget it (make sure thatit doesn't exist yet first) :)

Could I give a suggestion of how to modify the pre-existing function to enable that functionality easily?

If I understand how the function works correctly...

Modify:
https://github.com/SFML/SFML/blob/master/src/SFML/Audio/SoundRecorder.cpp#L64

So it becomes:
void SoundRecorder::start(unsigned int sampleRate, const char *DeviceName = NULL)

And then modify:
https://github.com/SFML/SFML/blob/master/src/SFML/Audio/SoundRecorder.cpp#L81

So it becomes:
captureDevice = alcCaptureOpenDevice(DeviceName, sampleRate, AL_FORMAT_MONO16, sampleRate);

So the default argument is set to the default device, and you can always add in a function that returns a const char reference or similar to the sound input devices on the computer as a separate function.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ability to chose sound input device
« Reply #8 on: May 06, 2012, 09:14:09 am »
Thanks... But don't waste your time, this is really trivial (and you already got it wrong: SFML never uses const char* in its public interface) ;)
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Ability to chose sound input device
« Reply #9 on: May 16, 2012, 04:11:50 pm »
Thanks... But don't waste your time, this is really trivial (and you already got it wrong: SFML never uses const char* in its public interface) ;)

I'd love to see ALChar * squashed into a std::string. But despite my mistake, it was a suggestion as how it could be implemented.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #10 on: June 07, 2012, 08:59:30 am »
Hey there,
I kind of need this feature right now / very soon. So I think I'm going to implement it myself (using a modified version of sfml), since you are busy releasing sfml 2. My question is what kind of interface would you choose? I'm asking, because once it's proven to work on my side, it then can easily be integrated in sfml. I was thinking of a getAvailableDevices() and a setDevice() function. What would you use as a return type for the get function though? A vector of strings?! And what would be a good parameter for the set function? A string? Of course when non of these functions are called the class will use the default device.
Foaly

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ability to chose sound input device
« Reply #11 on: June 07, 2012, 09:14:53 am »
Answering this kind of questions and finding a proper design is what consumes time. Implementation will then take maximum 10 minutes, tests included. So I can't answer.

But don't bother trying to find the "final" design, I will change it anyway ;D
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #12 on: June 07, 2012, 10:54:19 am »
Ok I see. I just though you might already have something in mind or there is a typical smfl design for those kinds of problems.

Since this is such a trivial thing, which can't really break anything, is there any chance this might still make it into sfml 2.0?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Ability to chose sound input device
« Reply #13 on: June 07, 2012, 11:03:50 am »
Quote
Since this is such a trivial thing, which can't really break anything, is there any chance this might still make it into sfml 2.0?
No. SFML 2.0 RC is currently being tested, only critical bugs will be fixed before the final release. The public API is frozen.

And I try to focus on writing the tutorials so that SFML 2.0 can be released, and I can start working on 2.1 :)
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Ability to chose sound input device
« Reply #14 on: June 07, 2012, 11:35:13 am »
Well that's unfortunateā€¦ I guess I'll have to wait then till 2.1 will be released. I think I'll find a solution untill then.

Just out of curiosity: how far along with the tutorials are you?

 

anything