Skip to content

Commit eae82f8

Browse files
committed
Merge branch 'develop'
# Conflicts: # Binaural/BuildUnityWrapperPackage/.gitignore # Binaural/audioplugin3DTIToolkit/.gitignore
2 parents 319174c + 1dcd6c0 commit eae82f8

389 files changed

Lines changed: 27735 additions & 323 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Binaural/audioplugin3DTIToolkit/src_autogenerated
2+
3DTi_ErrorLog.txt
3+
Binaural/audioplugin3DTIToolkit/WINDOWS/AudioPlugin3DTIToolkit.VC.VC.opendb
4+
Binaural/audioplugin3DTIToolkit/ANDROID/AudioPlugin3DTIToolkit.VC.VC.opendb

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
[submodule "3dti_AudioToolkit"]
4+
path = 3dti_AudioToolkit
5+
url = https://github.com/3DTune-In/3dti_AudioToolkit.git

3dti_AudioToolkit

Submodule 3dti_AudioToolkit added at a3d5146
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
################### UNITY 5 ##################
2-
/[Ll]ibrary/
3-
/[Tt]emp/
4-
/[Oo]bj/
5-
/[Bb]uild/
6-
/[Bb]uilds/
7-
/Assets/AssetStoreTools*
8-
9-
# Visual Studio 2015 cache directory
10-
/.vs/
11-
12-
# Autogenerated VS/MD/Consulo solution and project files
13-
ExportedObj/
14-
.consulo/
15-
*.csproj
16-
*.unityproj
17-
*.sln
18-
*.suo
19-
*.tmp
20-
*.user
21-
*.userprefs
22-
*.pidb
23-
*.booproj
24-
*.svd
25-
*.pdb
26-
27-
# Unity3D generated meta files
28-
*.pidb.meta
29-
30-
# Unity3D Generated File On Crash Reports
31-
sysinfo.txt
32-
33-
# Builds
34-
*.apk
35-
*.unitypackage
36-
37-
#3DTuneIn
1+
################### UNITY 5 ##################
2+
/[Ll]ibrary/
3+
/[Tt]emp/
4+
/[Oo]bj/
5+
/[Bb]uild/
6+
/[Bb]uilds/
7+
/Assets/AssetStoreTools*
8+
9+
# Visual Studio 2015 cache directory
10+
/.vs/
11+
12+
# Autogenerated VS/MD/Consulo solution and project files
13+
ExportedObj/
14+
.consulo/
15+
*.csproj
16+
*.unityproj
17+
*.sln
18+
*.suo
19+
*.tmp
20+
*.user
21+
*.userprefs
22+
*.pidb
23+
*.booproj
24+
*.svd
25+
*.pdb
26+
27+
# Unity3D generated meta files
28+
*.pidb.meta
29+
30+
# Unity3D Generated File On Crash Reports
31+
sysinfo.txt
32+
33+
# Builds
34+
*.apk
35+
*.unitypackage
36+
37+
#3DTuneIn
3838
*DebugLog.txt
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}

Binaural/BuildUnityWrapperPackage/Assets/3DTuneIn.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Binaural/BuildUnityWrapperPackage/Assets/3DTuneIn/APIScripts.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+

2+
using UnityEngine;
3+
using UnityEngine.Audio;
4+
using System.Collections;
5+
using System.Collections.Generic;
6+
using System.Collections.ObjectModel; // For ReadOnlyCollection
7+
using API_3DTI;
8+
using System;
9+
10+
11+
namespace API_3DTI
12+
{
13+
public class AbstractMixerEffect : MonoBehaviour
14+
{
15+
protected bool _SetParameter<Parameter, T>(AudioMixer mixer, Parameter p, T value, T_ear ear = T_ear.BOTH) where T : IConvertible where Parameter : Enum
16+
{
17+
ParameterAttribute attributes = p.GetAttribute<ParameterAttribute>();
18+
Debug.Assert(value.GetType() == attributes.type);
19+
Debug.Assert(!attributes.isReadOnly);
20+
if (attributes.isReadOnly)
21+
{
22+
Debug.LogWarning($"Parameter {p} is read-only.");
23+
return false;
24+
}
25+
26+
if (attributes.isSharedBetweenEars())
27+
{
28+
// Single parameter for both ears
29+
if (ear != T_ear.BOTH)
30+
{
31+
Debug.LogWarning($"Parameter {p} cannot be set for an individual ear. It must be set with ear == {T_ear.BOTH}.");
32+
ear = T_ear.BOTH;
33+
}
34+
}
35+
36+
if (ear.HasFlag(T_ear.LEFT))
37+
{
38+
if (!mixer.SetFloat(attributes.mixerNameLeft, Convert.ToSingle(value)))
39+
{
40+
Debug.LogError($"Failed to set parameter {attributes.mixerNameLeft} on mixer {mixer}", this);
41+
return false;
42+
}
43+
}
44+
if (ear.HasFlag(T_ear.RIGHT))
45+
{
46+
if (!mixer.SetFloat(attributes.mixerNameRight, Convert.ToSingle(value)))
47+
{
48+
Debug.LogError($"Failed to set parameter {attributes.mixerNameRight} on mixer {mixer}", this);
49+
return false;
50+
}
51+
}
52+
return true;
53+
}
54+
55+
protected T _GetParameter<Parameter, T>(AudioMixer mixer, Parameter p, T_ear ear) where Parameter : Enum
56+
{
57+
ParameterAttribute attributes = p.GetAttribute<ParameterAttribute>();
58+
Debug.Assert(typeof(T) == attributes.type);
59+
60+
if (attributes.isSharedBetweenEars() && ear != T_ear.BOTH)
61+
{
62+
Debug.LogWarning($"Parameter {p} cannot be retrieved for an individual ear. It must be retrieved with ear == {T_ear.BOTH}.");
63+
ear = T_ear.BOTH;
64+
}
65+
else if (!attributes.isSharedBetweenEars() && ear == T_ear.BOTH)
66+
{
67+
throw new Exception($"Cannot get parameter {p} for both ears. Choose wither {T_ear.LEFT} or {T_ear.RIGHT}.");
68+
}
69+
70+
float fValue;
71+
string mixerName = attributes.mixerName(ear);
72+
if (!mixer.GetFloat(mixerName, out fValue))
73+
{
74+
Debug.LogError($"Failed to get parameter {mixerName} from mixer {mixer}", this);
75+
return default(T);
76+
}
77+
78+
return (T)Convert.ChangeType(fValue, typeof(T));
79+
}
80+
}
81+
}

Binaural/BuildUnityWrapperPackage/Assets/3DTuneIn/APIScripts/AbstractMixerEffect.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
using System;
2+
using System.Collections.Generic; // List
3+
using System.Collections.ObjectModel; // ReadOnlyCollection
4+
using UnityEngine;
5+
6+
namespace API_3DTI
7+
{
8+
//////////////////////////////////////////////////////////////
9+
// PUBLIC TYPE DEFINITIONS
10+
//////////////////////////////////////////////////////////////
11+
12+
13+
[System.AttributeUsage(System.AttributeTargets.Field)]
14+
public class ParameterAttribute : System.Attribute
15+
{
16+
// For parameters that are not ear-specific, pluginNameLeft == pluginNameRight and mixerNameLeft == mixerNameRight
17+
public string pluginNameLeft;
18+
public string pluginNameRight;
19+
public string mixerNameLeft;
20+
public string mixerNameRight;
21+
public Type type;
22+
// Label used in GUI
23+
public string label;
24+
// Tooltip used in GUI
25+
public string description;
26+
// For numeric values, the units label, e.g. "dB"
27+
public string units;
28+
// For int/float parameters: limit to these discrete values. Leave as null for no limits.
29+
public float[] validValues;
30+
public float defaultValue;
31+
public float min;
32+
public float max;
33+
public bool isReadOnly = false;
34+
35+
public bool isSharedBetweenEars()
36+
{
37+
Debug.Assert((pluginNameLeft == pluginNameRight) == (mixerNameLeft == mixerNameRight));
38+
return pluginNameLeft == pluginNameRight;
39+
}
40+
41+
public string pluginName(T_ear ear)
42+
{
43+
if (!(isSharedBetweenEars() == (ear == T_ear.BOTH)))
44+
{
45+
Debug.Assert(isSharedBetweenEars() == (ear == T_ear.BOTH), $"This parameter is shared between both ears so must be called with ear=={T_ear.BOTH}");
46+
}
47+
return ear.HasFlag(T_ear.LEFT) ? pluginNameLeft : pluginNameRight;
48+
}
49+
50+
public string mixerName(T_ear ear)
51+
{
52+
Debug.Assert(isSharedBetweenEars() == (ear == T_ear.BOTH), $"This parameter is shared between both ears so must be called with ear=={T_ear.BOTH}");
53+
return ear.HasFlag(T_ear.LEFT) ? mixerNameLeft : mixerNameRight;
54+
}
55+
56+
}
57+
58+
public static class EnumHelper
59+
{
60+
// https://stackoverflow.com/a/9276348
61+
/// <summary>
62+
/// Gets an attribute on an enum field value
63+
/// </summary>
64+
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
65+
/// <param name="enumVal">The enum value</param>
66+
/// <returns>The attribute of type T that exists on the enum value</returns>
67+
/// <example><![CDATA[string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;]]></example>
68+
public static T GetAttribute<T>(this Enum enumVal) where T : System.Attribute
69+
{
70+
var type = enumVal.GetType();
71+
var memInfo = type.GetMember(enumVal.ToString());
72+
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
73+
return (attributes.Length > 0) ? (T)attributes[0] : null;
74+
}
75+
}
76+
77+
78+
79+
//public class Parameter<T> where T : Enum
80+
//{
81+
// //public T id;
82+
// public string pluginName;
83+
// public string mixerName;
84+
// public Type type;
85+
// public object value;
86+
//}
87+
88+
[Flags]
89+
public enum T_ear
90+
{
91+
LEFT = 1, // Left ear
92+
RIGHT = 2, // Right ear
93+
BOTH = LEFT | RIGHT, // Both ears
94+
};
95+
96+
//public class T_LevelsList: List<float> { }
97+
98+
//////////////////////////////////////////////////////////////
99+
// CLASS DEFINITIONS FOR INTERNAL USE OF THE WRAPPER
100+
//////////////////////////////////////////////////////////////
101+
102+
//public class CEarAPIParameter<TDataType>
103+
//{
104+
// TDataType left;
105+
// TDataType right;
106+
107+
// public CEarAPIParameter(TDataType l, TDataType r) { left = l; right = r; }
108+
// public CEarAPIParameter(TDataType v) { left = v; right = v; }
109+
110+
// public void Set(T_ear ear, TDataType value)
111+
// {
112+
// switch (ear)
113+
// {
114+
// case T_ear.BOTH:
115+
// left = value;
116+
// right = value;
117+
// break;
118+
// case T_ear.LEFT:
119+
// left = value;
120+
// break;
121+
// case T_ear.RIGHT:
122+
// right = value;
123+
// break;
124+
// }
125+
// }
126+
127+
// public TDataType Get(T_ear ear)
128+
// {
129+
// switch (ear)
130+
// {
131+
// case T_ear.LEFT:
132+
// return left;
133+
// case T_ear.RIGHT:
134+
// return right;
135+
// }
136+
// return left;
137+
// }
138+
//}
139+
140+
//////////////////////////////////////////////////////////////
141+
// AUXILIARY FUNCTIONS FOR INTERNAL USE OF THE WRAPPER
142+
//////////////////////////////////////////////////////////////
143+
144+
public static class CommonFunctions
145+
{
146+
/// <summary>
147+
/// Auxiliary function
148+
/// </summary>
149+
/// <param name="v"></param>
150+
/// <returns></returns>
151+
public static bool Float2Bool(float v)
152+
{
153+
if (v == 1.0f)
154+
return true;
155+
else
156+
return false;
157+
}
158+
159+
/// <summary>
160+
/// Auxiliary function
161+
/// </summary>
162+
/// <param name="v"></param>
163+
/// <returns></returns>
164+
public static float Bool2Float(bool v)
165+
{
166+
if (v)
167+
return 1.0f;
168+
else
169+
return 0.0f;
170+
}
171+
172+
173+
}
174+
}

0 commit comments

Comments
 (0)