non-vr lobby, version fix
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Photon.Voice.Unity.UtilityScripts
|
||||
{
|
||||
[RequireComponent(typeof(Recorder))]
|
||||
public class MicAmplifier : VoiceComponent
|
||||
{
|
||||
[SerializeField]
|
||||
private float boostValue;
|
||||
|
||||
[SerializeField]
|
||||
private float amplificationFactor = 1f;
|
||||
|
||||
public float AmplificationFactor
|
||||
{
|
||||
get { return this.amplificationFactor; }
|
||||
set
|
||||
{
|
||||
if (this.amplificationFactor.Equals(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.amplificationFactor = value;
|
||||
if (this.floatProcessor != null)
|
||||
{
|
||||
this.floatProcessor.AmplificationFactor = this.amplificationFactor;
|
||||
}
|
||||
if (this.shortProcessor != null)
|
||||
{
|
||||
this.shortProcessor.AmplificationFactor = (short)this.amplificationFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float BoostValue
|
||||
{
|
||||
get { return this.boostValue; }
|
||||
set
|
||||
{
|
||||
if (this.boostValue.Equals(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.boostValue = value;
|
||||
if (this.floatProcessor != null)
|
||||
{
|
||||
this.floatProcessor.BoostValue = this.boostValue;
|
||||
}
|
||||
if (this.shortProcessor != null)
|
||||
{
|
||||
this.shortProcessor.BoostValue = (short)this.boostValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MicAmplifierFloat floatProcessor;
|
||||
private MicAmplifierShort shortProcessor;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (this.floatProcessor != null)
|
||||
{
|
||||
this.floatProcessor.Disabled = false;
|
||||
}
|
||||
if (this.shortProcessor != null)
|
||||
{
|
||||
this.shortProcessor.Disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (this.floatProcessor != null)
|
||||
{
|
||||
this.floatProcessor.Disabled = true;
|
||||
}
|
||||
if (this.shortProcessor != null)
|
||||
{
|
||||
this.shortProcessor.Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Message sent by Recorder
|
||||
private void PhotonVoiceCreated(PhotonVoiceCreatedParams p)
|
||||
{
|
||||
if (p.Voice is LocalVoiceAudioFloat)
|
||||
{
|
||||
LocalVoiceAudioFloat v = p.Voice as LocalVoiceAudioFloat;
|
||||
this.floatProcessor = new MicAmplifierFloat(this.AmplificationFactor, this.BoostValue);
|
||||
v.AddPostProcessor(this.floatProcessor);
|
||||
}
|
||||
else if (p.Voice is LocalVoiceAudioShort)
|
||||
{
|
||||
LocalVoiceAudioShort v = p.Voice as LocalVoiceAudioShort;
|
||||
this.shortProcessor = new MicAmplifierShort((short)this.AmplificationFactor, (short)this.BoostValue);
|
||||
//this.shortProcessor = new SimpleAmplifierShortProcessor((short)(this.AmplificationFactor* short.MaxValue), (short)(this.boostValue * short.MaxValue));
|
||||
v.AddPostProcessor(this.shortProcessor);
|
||||
}
|
||||
else if (this.Logger.IsErrorEnabled)
|
||||
{
|
||||
this.Logger.LogError("LocalVoice object has unexpected value/type: {0}", p.Voice == null ? "null" : p.Voice.GetType().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3986deb98168394684c41606a9495af
|
||||
timeCreated: 1561048437
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: dd940d333aeeaa048842e87b9b259188, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Photon.Voice.Unity.UtilityScripts
|
||||
{
|
||||
[CustomEditor(typeof(MicAmplifier))]
|
||||
public class MicAmplifierEditor : Editor
|
||||
{
|
||||
private MicAmplifier simpleAmplifier;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
this.simpleAmplifier = this.target as MicAmplifier;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
this.simpleAmplifier.AmplificationFactor = EditorGUILayout.FloatField(
|
||||
new GUIContent("Amplification Factor", "Amplification Factor (Multiplication)"),
|
||||
this.simpleAmplifier.AmplificationFactor);
|
||||
this.simpleAmplifier.BoostValue = EditorGUILayout.FloatField(
|
||||
new GUIContent("Boost Value", "Boost Value (Addition)"),
|
||||
this.simpleAmplifier.BoostValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
this.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ca8fce417a134e4eb5444c7a9d071bb
|
||||
timeCreated: 1561049980
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace Photon.Voice.Unity.UtilityScripts
|
||||
{
|
||||
|
||||
public class MicAmplifierFloat : IProcessor<float>
|
||||
{
|
||||
public float AmplificationFactor { get; set; }
|
||||
public float BoostValue { get; set; }
|
||||
|
||||
public float MaxBefore { get; private set; }
|
||||
public float MaxAfter { get; private set; }
|
||||
//public float MinBefore { get; private set; }
|
||||
//public float MinAfter { get; private set; }
|
||||
//public float AvgBefore { get; private set; }
|
||||
//public float AvgAfter { get; private set; }
|
||||
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
public MicAmplifierFloat(float amplificationFactor, float boostValue)
|
||||
{
|
||||
this.AmplificationFactor = amplificationFactor;
|
||||
this.BoostValue = boostValue;
|
||||
}
|
||||
|
||||
public float[] Process(float[] buf)
|
||||
{
|
||||
if (this.Disabled)
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
for (int i = 0; i < buf.Length; i++)
|
||||
{
|
||||
float before = buf[i];
|
||||
buf[i] *= this.AmplificationFactor;
|
||||
buf[i] += this.BoostValue;
|
||||
if (this.MaxBefore < before)
|
||||
{
|
||||
this.MaxBefore = before;
|
||||
this.MaxAfter = buf[i];
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54f7c01cbf9e64e42bde37b5a0bee411
|
||||
timeCreated: 1561049960
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
namespace Photon.Voice.Unity.UtilityScripts
|
||||
{
|
||||
public class MicAmplifierShort : IProcessor<short>
|
||||
{
|
||||
public short AmplificationFactor { get; set; }
|
||||
public short BoostValue { get; set; }
|
||||
|
||||
public short MaxBefore { get; private set; }
|
||||
public short MaxAfter { get; private set; }
|
||||
//public short MinBefore { get; private set; }
|
||||
//public short MinAfter { get; private set; }
|
||||
//public short AvgBefore { get; private set; }
|
||||
//public short AvgAfter { get; private set; }
|
||||
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
|
||||
public MicAmplifierShort(short amplificationFactor, short boostValue)
|
||||
{
|
||||
this.AmplificationFactor = amplificationFactor;
|
||||
this.BoostValue = boostValue;
|
||||
}
|
||||
|
||||
public short[] Process(short[] buf)
|
||||
{
|
||||
if (this.Disabled)
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
for (int i = 0; i < buf.Length; i++)
|
||||
{
|
||||
short before = buf[i];
|
||||
buf[i] *= this.AmplificationFactor;
|
||||
buf[i] += this.BoostValue;
|
||||
if (this.MaxBefore < before)
|
||||
{
|
||||
this.MaxBefore = before;
|
||||
this.MaxAfter = buf[i];
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa8d3b254d2d2e6488f58f4d71ee2363
|
||||
timeCreated: 1561049971
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user