GML Is it possible to detect whether the user uses the speaker or headphones?

salyossy

Member
I wonder if it is possible to detect whether the user uses the speaker or headphones, since I wish to play certain sounds only if headphones are in use.

Thanks.
 
Not if it's directly plugged in the soundcard with an 1/8" jack for sure.
MAYBE possible with Bluetooth stuff, but still...
What, are you trying to make some sort of XXX game safe to play at the office? 😂
 

TsukaYuriko

☄️
Forum Staff
Moderator
Ask them if they're using headphones. If they answer yes, they're probably using headphones... :D

Both of these use the same interface(s), and whatever is behind those is unaware and doesn't care which one (if any) it is, so there's no differentiation.
 

salyossy

Member
lol.

I have my reasons.... It really matters to me and I can't rely upon the user's answer.

But... You say it's not possible.. 😕
 

Gamebot

Member
Just something to keep in mind with headphones and speakers.
They all will have different frequency outputs therefore sounding different.
Generally, why many developers have that "SOUND MENU" so the user can adjust to their needs as @TsukaYuriko "Hinted".


Here is a a quick hypothetical scenario:

Speakers:

1. I Don't have "surround sound" or any other speaker device other then my laptop speakers. Don't use very low ( "B" five string and sub bass ) and high sounds ( Screeching or squealing sounds).

2. I Don't play games on my phone so don't use "loopy" or "annoying sounds".

3. I have the best system in the world....bring it on perfect sound mix.


Headphones:

1. I have a $5.00 pair. A whole lot of treble and bass sounds muffled and loud .

2. A $12.00 pair. A bit muffled , but treble and bass same levels.

3. A $60.00 pair. A slight more "Bassy" but clean.

4. A German Studio $300.00+ pair ( NOT TOUCHED BY ANYONE ELSE ).

Can you guess which one I plug into my computer?
Me neither as it changes.
 
Just something to keep in mind with headphones and speakers.
They all will have different frequency outputs therefore sounding different.
Generally, why many developers have that "SOUND MENU" so the user can adjust to their needs as @TsukaYuriko "Hinted".


Here is a a quick hypothetical scenario:

Speakers:

1. I Don't have "surround sound" or any other speaker device other then my laptop speakers. Don't use very low ( "B" five string and sub bass ) and high sounds ( Screeching or squealing sounds).

2. I Don't play games on my phone so don't use "loopy" or "annoying sounds".

3. I have the best system in the world....bring it on perfect sound mix.


Headphones:

1. I have a $5.00 pair. A whole lot of treble and bass sounds muffled and loud .

2. A $12.00 pair. A bit muffled , but treble and bass same levels.

3. A $60.00 pair. A slight more "Bassy" but clean.

4. A German Studio $300.00+ pair ( NOT TOUCHED BY ANYONE ELSE ).

Can you guess which one I plug into my computer?
Me neither as it changes.
Can vouch for that, I have pair of Barefoot monitors (insanely expensive), as well as a pair of Sennheiser HD600, and I never ever heard a game in either.
And as headphones are speakers in a headset, you have to rely on the user to set a 'headphones' flag somewhere.
 

Roa

Member
lol.

I have my reasons.... It really matters to me and I can't rely upon the user's answer.
ugh... does anyone else get the vibe that he wants to force users to wear headphones so he can play loud and obnoxious things through it?
 
  • Like
Reactions: Tyg

TsukaYuriko

☄️
Forum Staff
Moderator
If that was the intention, there are a couple of simple but effective ways to ensure players are wearing headphones from a game design perspective rather than a technical one. But we'd first need to know what the intent here is before we fire off random suggestions that may or may not even be relevant into the void.
 
P

ParodyKnaveBob

Guest
ugh... does anyone else get the vibe that he wants to force users to wear headphones so he can play loud and obnoxious things through it?
Does anyone? ~shrug~ Maybe.

Do I? Well, actually, I got the vibe that @salyossy wants to do some fun, nifty trick, either as a gimmick (like that PSX game villain who started rattling off other games you were playing via the Memory Card data) or an unexpected mechanic (like phones requiring headphones plugged in to play the radio because the radio uses the physical cord as its antenna) or something.

Clearly, OSes know whether or not things get plugged in. Sounds like sal...y...ossy sal (anyway ha ha) would do well to grab that info from the OS if available, and I can't imagine it totally wouldn't be.

I hope this helps,
 

Roa

Member
If that was the intention, there are a couple of simple but effective ways to ensure players are wearing headphones from a game design perspective rather than a technical one. But we'd first need to know what the intent here is before we fire off random suggestions that may or may not even be relevant into the void.
Only reason I mention it
It just comes off as a "so clever" subjection to trolling from the fact he doesn't disclose his intentions and thinks it's funny he doesn't ~"lol".
People love blasting audio in people's ears... but alas....



but for an actual answer... the simple answer is you can't.

Audio is 90% analog still. Some people have USB devices, but its mostly higher end condenser mics and such. There is no "data" for analog audio devices, no specific drivers, and no hardware IDs. So there is no chance in knowing what a user intends to plug into his 3.5mm jack. The reason people ask in software is specifically for this. You're out of luck unless you ask the user.

Sometimes you can "assume" the registered front audio jack is for headphones as windows does, but just because its labeled as such doesn't guarantee it is. And there is no way to set audio output in GMS. It always goes to the default output which is user assigned.
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
You can probably detect whether something is plugged into the audio jack (Windows can, so you can too if it provides an API call for it, or if you can replicate the behavior it uses). Anything past that is either pure guesswork or looking up serial numbers or device IDs or something in a table of known speaker/headphone devices - because there's no "isSpeaker" flag or anything like that - or, in other words, unfeasible.
 

Tyg

Member
I sure hope not...stay away from my webcam too :)

Why not just give them the option in a menu?
Headphones for you young guys and speakers for us that want to save our ears
 

salyossy

Member
I couldn't imagine such funny reactions.
I also didn't think my reasons would interest any of you.

I make a musical app, where the user play virtual piano inside the app or real piano with pitch detection.
There is background music from the app itself, and that makes hard on pitch detection.
So I wanted to make sure that only if the user uses SOME KIND of headset, quality not matters, That the app would produce that background music, otherwise not.

I understand that i could just ask the user. But in my experience its difficult to explain the rational, and in the result I would get ratings of 1-2 stars, since "it didn't work for me". Especially since it ment for kids.

Quality of sounds is not important. Just to ensure that some kind if earphones is in use.

I get it. It's not possible.
 
P

ParodyKnaveBob

Guest
My short answer is surely it's possible, whether or not in GML. You'll just need to get the OS information, even if that means a non-GML extension per target.

I hope this helps,
 
1. What about building in the following as a game element:
- Make a sound that pans from left to right (vs. from right to left)
- Make a visual object that is perceived as moving from left to right
- Make a different visual object that is perceived as moving from right to left
- Then challenge the user to click on the visual object that is perceived as tracking the moving sound
2. If the user's performance on the click challenge is random, they're probably using the tiny speakers built into their laptop. If they consistently get it right, they're probably using headphones.
3. Another cue: the time lag between the visual movement and a decision on which target to click. With headphones the lag time should be less than with laptop speakers that don't give good stereo separation.

None of this depends on high quality headphones -- just on the stereo separation that you get with even cheap headphones.
This is not a sure thing, of course, since a full-blown audio system with external speakers and good stereo separation would let them accurately track the audio pan. But it would probably work for 99% of users.
The hard part, of course, is making it fun (or at least not annoying) for the player/learner to track the visual movement across the screen, enough times to give a reliable result. But using the lag time metric might mean you'd only need to impose this challenge a few times. Something to experiment with.
(And I'd be curious if it works for you....)
 
Last edited:

Thultex

Member
I also think its funny how evasive some of the answers seem, as the question was quite straight forward. Im looking for the same thing, and on android there are possibilities. Many media-players support pulling your headphones and stopping the sound, even resuming on jack in. That is with both, Bluetooth and analog jacks and the uses are plentifull. In my case im working on a speach and language therapy app... You really want the user not no be overwhelmed, so checking if the user can hear stereo is very usefull, also some users may want the app not to blurt out on disconnect, since privacy is an issue, and knowing that someone trains a certain speech pattern can be very private knowledge.

So if you find a solution without tooo much external coding, i would appreciate to hear about it.
 

gnysek

Member
something is plugged into the audio jack
I've got speakers plugged into jack. What's fun, I also have external monitor connected by HDMI, and that monitor have output jack, which I've connected to same speaker using front AUX jack input, so that's 2 jack input cables at same time. What's even more fun, I'm sometimes connecting headphones to those speakers, as they also have jack for output :D Jack-combo.

So... there's no possibility to detect if someone is uses headphones except you visit him personally, and check that they aren't broken, and you manually set the volume 🤣
 
Top