Photon Voice and iphone
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Voice.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Photon Voice and iphone
VRCraftworks
2017-12-22 17:12:48
Hi
using 1.13 Photon Voice
I can see you have implemented the https://github.com/cbaltzer/UnitySpeakerFix
However we still get sound only from the iphone ear speaker (the one used when making or receiving a call) not the main speakers.
On older devices with plug in headphones sound is routed to the headphones when plugged in.
If using bluetooth headphones on newer devices the sound is not routed and the ear speaker (the one used when making or receiving a call) remains activated.
Help, what am I missing?
All fine on Android though
Cheers
Comments
Hi @VRCraftworks,
Thank you for choosing Photon!
We are considering improving the iOS (and other) native Unity plugins to fix or add what's missing in Unity in terms of input and output audio devices handling.
Could you help us by defining what you mean by "older" and "newer" devices?
Maybe clearly list what's working and what's not, the different combinations you tried, Unity version(s), used device(s), expected and actual behaviors?
Thanks.
VRCraftworks
2018-01-02 10:16:23
Hi there
Happy New Year!
Devices
Older devices - those iphones with plug in headphones the 5 series and the 6.
Newer devices - iphone devices all have bluetooth headphones which are the iphone 7s and iphone 8s
List whats working and not working:
Working
On older devices iphone 5 and 6 series with plug in headphones sound is routed to the headphones when plugged in and the audio speakers (not the ear/call speaker the one used when making and receiving calls) when not.
Not working
If using bluetooth headphones on newer iphone 7 and 8 series devices the sound is not routed to the headphones and remains routed to the ear speaker (the one used when making or receiving a call). Sound is also only routed to the ear/call speaker when no headphone device is present.
The expected behavior
The sound to be routed properly to the audio speakers on newer devices the iphone 7 and 8 when no headphones are present and to the blue tooth headphones when they are plugged in. This expected behaviour is what happens on the older devices.
Unity
5.6.2 and 2017.1
Photon
1.13 Photon Voice which contains the fix for this from https://github.com/cbaltzer/UnitySpeakerFix
Let me know if you need any further information.
Cheers
VRCraftworks
2018-01-05 12:35:37
Hi guys
any progress on this?
Cheers B)
Hi @VRCraftworks,
No sorry, nothing yet but we have a task on our list for this.
We will post any updates here.
VRCraftworks
2018-01-05 16:52:57
No probs John.
Just thought it could be something we missed as the solution from
https://github.com/cbaltzer/UnitySpeakerFix
seems to have been implemented apart from the scripts in:
https://github.com/cbaltzer/UnitySpeakerFix/tree/master/Unity/Assets/Plugins/iPhoneSpeaker
Can this possibly be the reason??
Perhaps its missing an added call to iPhoneSpeaker.ForceToSpeaker() after you call Microphone.Start()?
Not a fan of ploughing through other peoples code but do you know in which scripts Microphone.Start() is called so we can quickly have check through?
We will also try this as sometimes its something as simple as this:
https://forum.unity.com/threads/audio-coming-out-of-small-phone-call-speaker-instead-of-speakers-on-bottom.207680/
(final post) that solves the issue.
Cheers :)
so at the end how do you solve it? i've tried
using UnityEngine.iOS;
if((Device.generation.ToString()).IndexOf("iPhone") > -1){ //for iphones only
iPhoneSpeaker.ForceToSpeaker ();
}
but it doesn't seem to work. Where did you place that code to make it work?
Hello,
I am facing problem, when i connected iPhone 7 or iPhone 8, i cant hear the voice generally.(with any headphones and Bluetooth also i cant hear the voice).But my voice is transmitting to another device.
What i have done wrong. Can you please let me know.
Thanks in advance.
Hi @ModulusPI,
Thank you for choosing Photon!
Can you please give us more details about the issue?
What is the Photon Voice version?
What is the Unity version?
iOS device (model + iOS version) sending audio
iOS device (model + iOS version) receiving audio
expected behaviour + actual behavior
Thanks.
Hello @JohnTube ,
Thanks for your quick response.
I am using unity 2017.3 and photon voice is 1.13.
When i am testing with iPhone 5s and version 11.2.6, with iPhone 6s and iPhone 7, Its not working well.
In iphone 5s voice is transmitting and hearing the voice from speaker, But in 6&7 voice is transmitting, they cant listen the voice from opponent person.
And some times photon speaker is unlinking by automatically.
Thanks.
VRCraftworks
2018-03-06 11:31:46
Hi guys
sorry about not checking back. As far as I can determine there is no easy fix here. The accepted solution was to use a plugin from github.
However this code seems to be incorporated into the latest build so I can't see how that would solve things now.
Here are the links should you wish to research out yourselves. Would be interested if anyone else has come to the same conclusion.
https://forum.unity.com/threads/audio-coming-out-of-small-phone-call-speaker-instead-of-speakers-on-bottom.207680/
https://forum.unity.com/threads/ios-speaker-volume-is-low.505657/
https://issuetracker.unity3d.com/issues/ios-audio-will-be-played-from-earspeaker-if-microphone-dot-start-is-used
https://github.com/cbaltzer/UnitySpeakerFix
Cheers all :/
utickledev
2018-08-22 19:08:15
Greetings @VRCraftworks @JohnTube , is the issue still unresolved?
I'm using Unity 2018.2.4f1, Dissonance 6.2.4 and PUN 1.91 and I have the problem with an iPhone X. I've tried the recommended links from the last post and still can't resolve it.
Hi @utickledev,
Thank you for choosing Photon!
On this forum, we usually give support for Photon Voice and not Dissonance.
You could ask on Dissonance's support channels or ask @martindevans directly.
Hey guys,
We are working on the fix for this iOS issue.
We want your help in testing few things.
Could you update to latest Photon Voice and use Photon Microphone type instead of Unity one (Read more about "Microphone Selection") and try if that fixes the audio output routing to the proper speaker? It may seem weird or unrelated but the system initialization may be different.
Let us know what do you find.
Please include the Unity version, iPhone device model, iOS version and external speaker if any with your results.
mahmoud93p
2018-11-14 14:02:15
@JohnTube hello
unity version : 2018.2.12f1
iPhone device : iphone x and iphone 6s
iOS version : 12.0
still some problem , also i am use this plugin (https://github.com/cbaltzer/UnitySpeakerFix)
also when i am using mic type photon not work plugin ! but when change mic type to unity plugin is work but with problem " echo too match" > so give me any solution to fix this problem .
note : i tried Photon voice 2 with pun 2 - some problem .
mahmoud93p
2018-11-15 11:23:06
any one ?!
hi @mahmoud93p,
What versions did you try? 1.16 and 2.1?
Do you use an external device like AirPods?
mahmoud93p
2018-11-15 11:37:32
@JohnTube thx for replay ,
Photon voice : 1.16
no i did't use any external device .
also if i don't use any plugin the sound come from ear speaker .
ok yesterday i tried few think , i found this scripts is update
"https://github.com/10people/UnitySpeakerFix"
"https://github.com/10people/UnitySpeakerFix/commit/e1d5e360c2c5a6c5b35a791a05c3e518074d8d4a#diff-1e290ac8433d555bce009b162cb869d0"
information devices : iphone 6s ios 12 , Samsung "android 7 ".
unity version : 2018.2.12f1.
i tried speaker script is work fine with my iphone , but still there is problem
the problem is : microphone not work i don't hear anything in anther device !
iPhoneSpeaker.CheckiOSPrepare();
AudioClip_m = Microphone.Start(null, false, 100, 44100);
Microphone.End(null);
iPhoneSpeaker.ForceToSpeaker();
i think iphone mic not sent to anther device after apply script .
mahmoud93p
2018-11-15 12:29:17
Device : iphone 6s ,Iphone x, ios 12.
Photon voice version : 1.16
unity version : 2018.2.12f1
@JohnTube right now i removed every plugin , problem is back sound come from "ear speaker "
and i don't use any code addition like (microphone.start()); , i'm back everything is default and the result
android work , iphone sound come from "ear speaker ".
what can i do ?
@mahmoud93p
In Photon Voice 1.16:
- Add "IOSAudioForceToSpeaker" component which will use the iOS speaker fix
OR
- Set MicrophoneType to Photon (see here for more details).
mahmoud93p
2018-11-15 12:48:06
@JohnTube can you give to me how can i use "IOSAudioForceToSpeaker"
and already i am using microphone type : photon .
mahmoud93p
2018-11-15 13:39:51
@JohnTube thank you for everything right my project in android and iphone
what did i do ?
Step 1
Select : microphone type : unity .
Step 2
after create your player call this function (IOSAudioForceToSpeaker.PhotonVoiceCreated();) this function from IOSAudioForceToSpeaker and this class include photon voice no need to download any plugin .
thank you @JohnTube شكرا لك
hey @mahmoud93p,
IOSAudioForceToSpeaker.PhotonVoiceCreated();
will be called automatcially if you add the IOSAudioForceToSpeaker component to the same GameObject as the PhotonVoiceRecorder. Sorry I did not mention that before.
mahmoud93p
2018-11-17 13:55:09
@JohnTube thank you, yes you can add this component "IOSAudioForceToSpeaker".
After few test I discovered unity microphone unusable there is echo tow match in android and ios, maybe is work fine if connected headset !
So the only way to use photon voice must be use "photon microphone" , but when you use "photon microphone" you can't use (IOSAudioForceToSpeaker) even if used the sound come fast or cut off ,also when you use " photon microphone " without (IOSAudioForceToSpeaker) in android work 100% but in ios sound come from "ear speaker".
how can i turn on main speaker in ios when used "photon microphone" ?
Note : when i am test there is tow device one location in Saudi arabia second device in Switzerland.
mahmoud93p
2018-11-17 16:30:06
@JohnTube Do you have paid support ? I am very upset
And does this plugin fix all issues in photonvoice ?
Plugin link : https://assetstore.unity.com/packages/tools/audio/dissonance-voice-chat-70078
Hi @mahmoud93p,
I suggest you create a separate new project and test Photon Voice 2:
About echo when using Unity Microphone API without headset/earpieces:
We have introduced acoustic echo cancellation and noise suppression in Voice 2.
You can try it in DemoVoiceUI scene in Voice 2 package.
There is a "VoiceAudioPreprocessor" component that when attached to the same GameObject as "Recorder" it will help with this issue.
I cannot guarantee results however as this depends on lots of factors.
About using Photon Microphone, in Photon Voice 2, make sure to Reinit the Recorder if you change the type at runtime.
Dissonance is another different product.
mahmoud93p
2018-11-17 20:55:36
@JohnTube If i upgrade to Photon Voice 2 must be also upgrade pun2 right !
and does fix this problem in Photon Voice 2 because my project is already is finish .
I am beginner in photon voice so can you explain to me more "how to Reinit Recorder" when i am just add this component "IOSAudioForceToSpeaker" ? also my player is Instantiate and have component (photon voice recorder , photon voice speaker , IOSAudioForceToSpeaker , etc) .
mahmoud93p
2018-11-18 12:09:02
@JohnTube Today i tried pun2 with photon voice 2 the problem still some think the sound in ios come from ear speaker, and you must to know few think
1 - i tried this scene "DemoVoiceUI" without any edit and problem in ios not fix.
2- when i am add "IOSAudioForceToSpeaker" the sound tow low in photon mic "unusable" ,also unity mic is bad .
Information
Xcode version : Version 10.1 (10B61).
unity version : 2018.2.12f1 .
Devices 1 : iphone 6s - ios 12
Devices 2: iphone x - ios 12
So right know i am back to my old project photon voice 1 , and i will try again fix photon voice problem
so if you have any note please tell me .
mahmoud93p
2018-11-18 12:18:12
@vadim can you help me
mahmoud93p
2018-11-18 13:53:18
Some update, after few tests the sound in ios come from main speaker using "Photon mic " , but there is anther problem mic does not work any more
this code work in realtime "OnClick button" .
AudioClip_m = Microphone.Start(null, false, 100, 44100);
Microphone.End(null);
IOSAudioForceToSpeaker.PhotonVoiceCreated();
So right know does have any solution for this problem ?
@JohnTube btw in photon voice 2 Reinit call automatic after change mic to photon !
and how can i Reinit Recorder in photon voice 1 ? and there is api for photon voice 1 !?
Hi @mahmoud93p,
IOSAudioForceToSpeaker
is useful only when using Unity MicrophoneType, you do not need it when you use Photon MicrophoneType.
AudioClip_m = Microphone.Start(null, false, 100, 44100);
Microphone.End(null);
Recorder.ReInit()
.
PhotonVoiceRecorde.UpdateAudioSource()
.
mahmoud93p
2018-11-19 18:58:46
@JohnTube Hello i am using " MicrophoneType photon " but nothing solve the sound come from "ear speaker", Also right know i tried " MicrophoneType photon " without any addition code and without this script "IOSAudioForceToSpeaker" still problem (sound come from "ear speaker")
So please explain to me how can i solve problem when i am using MicrophoneType photon
step by step or give to me any test project is work in ios and sound come from "Main Speaker" !
Note :MicrophoneType unity unstable in ios impassable , try it .
mahmoud93p
2018-11-20 07:57:20
@JohnTube @vadim can you help me
mahmoud93p
2018-11-21 11:38:17
any one !!
mahmoud93p
2018-11-21 17:05:01
To understand my problem please make this test
Test 1 follow this step
- Select microphone type : photon
- Then test your project in ios devices - must test in tow device ios
The Result : When you make this test the sound come from : ear speaker .
Test 2 follow this step
- Select microphone type : unity
- Then test your project in ios devices - must test in tow device ios
The Result : Sound come from main speaker but unusable because too much"echo" and sound is repeat. .
Hi,
Did you try to select speaker in ios control center?
mahmoud93p
2018-11-21 17:10:17
@vadim yes but same think ,also this is not solution i can't say to players please make this way .
mahmoud93p
2018-11-21 20:11:30
I fix photon voice issue . @JohnTube @vadim I've edited "AudioIn" line 231 , old code ([sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord) i add this to old code ("withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker ") --------new code [sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:&error];
Now microphone type :"photon" is work in android and in ios and the sound come from "Main speaker" without used "IOSAudioForceToSpeaker"
But there is a simple observation: when I hear my voice it is coarse or bigger than my natural voice!
Any suggestion may be helpful
i'm afraid players should guess this way themselves in such case. Setting speaker is a standard ios action.
Automatic routing to speakers does not work for Photon microphone currently. We are looking into this.
Maybe something else should be copied from ForceToSpeaker.m.
Also take a look at forcing to speaker module recently updated in one of its repos: https://github.com/10people/UnitySpeakerFix/blob/master/Unity/Assets/Plugins/iOS/iPhoneSpeaker.m
They state that it makes ios 7 / Unity 2018 working.
mahmoud93p
2018-11-22 10:28:48
@vadim After edit my code automatic routing to main speakers in microphone type photon , but the problem if connected headphone then take off the headphone not routing to main speakers but may be can i fix this problem via some manually action .
Either i tried this plugin" ForceToSpeaker" in microphone photon that is not work . you can make test ,that is not work in Microphone photon .
Right now microphone photon is work for my after edit in AudioIn .
If you have anther way to fix this problem make you sure test in tow ios device , also microphone unity unstable you can try it .
mahmoud93p
2018-11-22 13:28:57
There is some pitch in Audioin it is make sound slow around 0.07% , so do you know how can i control the pitch in Audioin ?
i can write some code to handle this problem but i want to edit in "Audioin" .
And i want to ask you when i edit value in photon voice setting it is effect when select microphone type photon ?
Note : i am looking for official update from photon voice 1 to solve microphone photon without edit any code .
Any suggestion may be helpful !
@mahmoud93p
I tested Unity 2018.2.17f1 and iPhone 6s ios 12.1
With "force to speaker" component from PhotonVoice package, both unity and photon mic modes route sound to speaker. So I can't reproduce the bug with this setup.
With unity built-in "force to speaker" option, unity mic mode routes to speaker, photon mic mode routes to phone.
Are you sure that sound in your tests comes from phone? Sometimes low volume sound form speaker seems like phone sound.
Setting required mode in AudioIn as you do instead of doing so with separate component looks reasonable. I will try this.
Hi,
I played a bit with audio session categories. For now, I found that category most appropriate for games is set via call
[sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:(AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionAllowBluetooth)
error:&error];
Without AVAudioSessionCategoryOptionAllowBluetooth, app did not switch to bluetooth device in my tests.
Of course, no need for ForceToSpeaker component with such call.
We plan to provide interface in voice api allowing set at least most common audio session categories
mahmoud93p
2018-11-28 16:13:16
@vadim thank you for this point it is an important point , and i don't try with bluetooth device , i will try today, but did you try to trun off bluetooth device after connected ? maybe should call again AVAudioSessionCategoryOptionDefaultToSpeaker !
And did you work everything good ?
I plugged and unplugged wired headset, switched on and off bluetooth headset in different combinations. While no headset is plugged or connected, sound goes through speaker.
AVAudioSessionCategoryOptionDefaultToSpeaker set once for audio session persists while session exists or until setCategory call updates it.
mahmoud93p
2018-11-29 11:47:04
@vadim After few test in headset and bluetooth device "Airpods" the result :
When the sound goes through speaker and i plugged wired headset or "Airpods" it is work good , but if unplugged wired headset or "Airpods" the main problem is back the sound come from "ear speaker"
so i think we need to call automatic again - (void)setupAudioSession - i don't try it .
something important : if you don't use this line of code "AVAudioSessionCategoryOptionAllowBluetooth" the "Airpods" not work .
Now I will mention the remaining problems that we will try to solve
1-if i unplugged wired headset or "Airpods" the sound come from "ear speaker"
2- The sound come from main speaker is slow, i mean slow not from internet no i mean sound is not normal the sound like big man (i think there is something in pitch in photon mic).
- This happens sometime to me too. I'm looking into it.
- So it's ok for headsets but slow for speaker? I can't reproduce this.
Note that our codebases are pretty different for the moment. To synchronize them you need to wait next Photon Voice 1 update.
- Sound source is correct in my tests in fact. But the level is significantly lower than before connecting headset. The level is almost as low as phone's when holding smartphone at some distance. So please check carefully which output actually works.
I noticed that it's much easier determine source of sound on iPhone 6s than on Xs since the latter has speaker at top side.
Look at logs. On each route change, Photon Voice logs previous and current record and play devices.
I don't know if the level changed intentionally by system and how to avoid this. But I always managed to revert to normal level by temporary sending app to background.
crystalpug
2019-01-16 09:12:03
I can confirm this also happens for me with an iPhone 7, iOS 12.1.2, running Photon Voice 1.15 with Unity 2017.4.17. Tried with both mic types Photon and Unity. Voice comes through the ear speaker instead of the loud speaker, so it is not audible when looking at the screen and playing the game.
Hi @crystalpug,
Please update to Photon Voice 1.17 and try again using Photon MicrophoneType.
Hello, I am using Photon voice 1 ver 1.18.1 and Unity 2018.3.12 with "photon microphone".
Same problem, can't use loud speaker on iPhone.
How can I fix it?
Hi @devolzhas,
Thank you for choosing Photon!
This issue is handled in a better way in Photon Voice 2.
We will not backport this to Photon Voice 1.
Before you start thinking about migrating, could you try building the demo scenes from a new project where you import Photon Voice 2?
@JohnTube can I use Photon Voice 2 with PUN v.1?
Hi @maxtyt,
Thank you for choosing Photon!
While the topic of this discussion is different, I will answer anyway.
Please open a new discussion next time or use one that has the same topic.
Photon Voice 2 does not support integration with PUN Classic (or PUN 1).
Back to top