Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VAUnity
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VAUnity
Commits
73e836a9
Commit
73e836a9
authored
Dec 13, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating internal class names and using more object-oriented approach
parent
c0690de0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
107 deletions
+98
-107
VAUAudioRenderer.cs
VAUAudioRenderer.cs
+11
-6
VAUAudioReproduction.cs
VAUAudioReproduction.cs
+12
-7
VAUAuralizationMode.cs
VAUAuralizationMode.cs
+32
-11
VAUController.cs
VAUController.cs
+7
-0
VAUListener.cs
VAUListener.cs
+16
-60
VAURendererArtificialReverb.cs
VAURendererArtificialReverb.cs
+7
-7
VAUSoundReceiver.cs
VAUSoundReceiver.cs
+13
-16
No files found.
VAU
RendererControll
er.cs
→
VAU
AudioRender
er.cs
View file @
73e836a9
...
...
@@ -2,10 +2,15 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
VAU
RendererControll
er
:
MonoBehaviour
public
class
VAU
AudioRender
er
:
MonoBehaviour
{
public
string
RendererID
=
""
;
[
Tooltip
(
"Rendering module identifier"
)]
public
string
ID
=
""
;
[
Tooltip
(
"Mute/unmute rendering output"
)]
public
bool
OutputMuted
=
false
;
[
Tooltip
(
"Control rendering output gain"
)]
public
double
OutputGain
=
1.0
;
private
bool
OutputMutedShadow
;
...
...
@@ -13,8 +18,8 @@ public class VAURendererController : MonoBehaviour
void
Start
()
{
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
Renderer
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetRenderingModuleGain
(
Renderer
ID
,
OutputGain
);
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetRenderingModuleGain
(
ID
,
OutputGain
);
OutputMutedShadow
=
OutputMuted
;
OutputGainShadow
=
OutputGain
;
...
...
@@ -24,12 +29,12 @@ public class VAURendererController : MonoBehaviour
{
if
(
OutputMuted
!=
OutputMutedShadow
)
{
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
Renderer
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
ID
,
OutputMuted
);
OutputMutedShadow
=
OutputMuted
;
}
if
(
OutputGain
!=
OutputGainShadow
)
{
VAUAdapter
.
VA
.
SetRenderingModuleGain
(
Renderer
ID
,
OutputGain
);
VAUAdapter
.
VA
.
SetRenderingModuleGain
(
ID
,
OutputGain
);
OutputGainShadow
=
OutputGain
;
}
}
...
...
VAU
ReproductionController
.cs
→
VAU
AudioReproduction
.cs
View file @
73e836a9
...
...
@@ -2,19 +2,24 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
VAU
ReproductionController
:
MonoBehaviour
public
class
VAU
AudioReproduction
:
MonoBehaviour
{
public
string
ReproductionID
=
""
;
[
Tooltip
(
"Reproduction module identifier"
)]
public
string
ID
=
""
;
[
Tooltip
(
"Mute/unmute reproduction output"
)]
public
bool
OutputMuted
=
false
;
[
Tooltip
(
"Control reproduction output gain"
)]
public
double
OutputGain
=
1.0
;
private
bool
OutputMutedShadow
;
private
double
OutputGainShadow
;
void
Start
()
{
VAUAdapter
.
VA
.
SetReproductionModuleMuted
(
Reproduction
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetReproductionModuleGain
(
Reproduction
ID
,
OutputGain
);
VAUAdapter
.
VA
.
SetReproductionModuleMuted
(
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetReproductionModuleGain
(
ID
,
OutputGain
);
OutputMutedShadow
=
OutputMuted
;
OutputGainShadow
=
OutputGain
;
...
...
@@ -24,12 +29,12 @@ public class VAUReproductionController : MonoBehaviour
{
if
(
OutputMuted
!=
OutputMutedShadow
)
{
VAUAdapter
.
VA
.
SetReproductionModuleMuted
(
Reproduction
ID
,
OutputMuted
);
VAUAdapter
.
VA
.
SetReproductionModuleMuted
(
ID
,
OutputMuted
);
OutputMutedShadow
=
OutputMuted
;
}
if
(
OutputGain
!=
OutputGainShadow
)
{
VAUAdapter
.
VA
.
SetReproductionModuleGain
(
Reproduction
ID
,
OutputGain
);
VAUAdapter
.
VA
.
SetReproductionModuleGain
(
ID
,
OutputGain
);
OutputGainShadow
=
OutputGain
;
}
}
...
...
VAUAuralizationMode.cs
View file @
73e836a9
...
...
@@ -4,19 +4,40 @@ using System.Collections;
public
class
VAUAuralizationMode
:
MonoBehaviour
{
[
Tooltip
(
"Toggle direct sound"
)]
public
bool
DirectSound
=
true
;
public
bool
EarlyReflections
=
false
;
public
bool
DiffuseDecay
=
false
;
public
bool
SourceDirectivity
=
true
;
public
bool
AirAbsorption
=
false
;
public
bool
AtmosphericTemporalVariations
=
false
;
public
bool
Scattering
=
false
;
public
bool
Diffraction
=
false
;
public
bool
NearFieldEffects
=
false
;
public
bool
DopplerShifts
=
true
;
[
Tooltip
(
"Toggle early reflections"
)]
public
bool
EarlyReflections
=
false
;
[
Tooltip
(
"Toggle diffuse decay"
)]
public
bool
DiffuseDecay
=
false
;
[
Tooltip
(
"Toggle source directivity"
)]
public
bool
SourceDirectivity
=
true
;
[
Tooltip
(
"Toggle air absorption"
)]
public
bool
AirAbsorption
=
false
;
[
Tooltip
(
"Toggle atmospheric temporal variations"
)]
public
bool
AtmosphericTemporalVariations
=
false
;
[
Tooltip
(
"Toggle scattering"
)]
public
bool
Scattering
=
false
;
[
Tooltip
(
"Toggle diffraction"
)]
public
bool
Diffraction
=
false
;
[
Tooltip
(
"Toggle hear-field effects"
)]
public
bool
NearFieldEffects
=
false
;
[
Tooltip
(
"Toggle Doppler shifts"
)]
public
bool
DopplerShifts
=
true
;
[
Tooltip
(
"Toggle spherical spreading loss"
)]
public
bool
SphericalSpreadingLoss
=
true
;
pr
ivate
class
AuralizationMode
:
System
.
Object
pr
otected
class
AuralizationMode
:
System
.
Object
{
public
bool
DirectSound
=
true
;
public
bool
EarlyReflections
=
true
;
...
...
@@ -195,7 +216,7 @@ public class VAUAuralizationMode : MonoBehaviour
AuraStringChanged
(
externAuraString
);
}
AuralizationMode
UpdateAuraModeSettings
()
protected
AuralizationMode
UpdateAuraModeSettings
()
{
AuralizationMode
am
=
new
AuralizationMode
();
am
.
DirectSound
=
DirectSound
;
...
...
VAUController.cs
View file @
73e836a9
...
...
@@ -4,9 +4,16 @@ using UnityEngine;
public
class
VAUController
:
MonoBehaviour
{
[
Tooltip
(
"Mute global input"
)]
public
bool
InputMuted
=
false
;
[
Tooltip
(
"Control global input gain"
)]
public
double
InputGain
=
1.0
;
[
Tooltip
(
"Mute global output"
)]
public
bool
OutputMuted
=
false
;
[
Tooltip
(
"Control global output gain"
)]
public
double
OutputGain
=
1.0
;
private
bool
InputMutedShadow
;
...
...
VAUListener.cs
View file @
73e836a9
...
...
@@ -4,17 +4,12 @@ using System.Collections;
using
VA
;
[
Tooltip
(
"A human listener that can receive sound and will be rendered by an audio renderer"
)]
public
class
VAUListener
:
MonoBehaviour
{
[
Tooltip
(
"Descriptive name"
)]
public
string
Name
=
"HumanListener"
;
public
class
VAUListener
:
VAUSoundReceiver
{
[
Tooltip
(
"Number of reverbzones used for determining the current reverb."
)]
public
int
NumMaxReverbZones
=
2
;
public
string
VAAudioRenderer
=
"MyBinauralArtificialReverb"
;
[
Tooltip
(
"Add custom VAUHRIR dataset."
)]
public
VAUDirectivity
HRIR
=
null
;
[
Tooltip
(
"Anthropometric head width, for HRIR individualization or generic binaural cues"
)]
public
double
HeadWidth
=
0.12
;
...
...
@@ -26,10 +21,7 @@ public class VAUListener : MonoBehaviour {
private
double
ShadowHeadWidth
;
private
double
ShadowHeadHeight
;
private
double
ShadowHeadDepth
;
private
int
_ID
;
private
VANet
_VA
=
null
;
private
Quaternion
q
;
private
Transform
t
;
private
AudioReverbZone
[]
reverbZones
;
...
...
@@ -37,33 +29,24 @@ public class VAUListener : MonoBehaviour {
public
delegate
void
ReverbTimeChangedDelegate
(
double
reverbTime
);
public
event
ReverbTimeChangedDelegate
ReverbTimeChanged
;
public
int
ID
{
get
{
return
_ID
;
}
}
void
Start
()
{
_VA
=
VAUAdapter
.
VA
;
_ID
=
_VA
.
CreateSoundReceiver
(
Name
);
_VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
"all"
);
if
(
HRIR
)
_VA
.
SetSoundReceiverDirectivity
(
_ID
,
HRIR
.
ID
);
_ID
=
VAUAdapter
.
VA
.
CreateSoundReceiver
(
Name
);
VAUAdapter
.
VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
"all"
);
if
(
Directivity
)
VAUAdapter
.
VA
.
SetSoundReceiverDirectivity
(
_ID
,
Directivity
.
ID
);
else
if
(
VAUAdapter
.
DefaultHRIRID
!=
-
1
)
_
VA
.
SetSoundReceiverDirectivity
(
_ID
,
VAUAdapter
.
DefaultHRIRID
);
VAUAdapter
.
VA
.
SetSoundReceiverDirectivity
(
_ID
,
VAUAdapter
.
DefaultHRIRID
);
_
VA
.
SetSoundReceiverAnthropometricData
(
_ID
,
HeadWidth
,
HeadHeight
,
HeadDepth
);
VAUAdapter
.
VA
.
SetSoundReceiverAnthropometricData
(
_ID
,
HeadWidth
,
HeadHeight
,
HeadDepth
);
ShadowHeadWidth
=
HeadWidth
;
ShadowHeadHeight
=
HeadHeight
;
ShadowHeadDepth
=
HeadDepth
;
SetSoundReceiverPositionOrientation
();
_
VA
.
SetArtificialReverberationTime
(
VAAudioRenderer
,
0.3f
);
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
VAAudioRenderer
,
0.3f
);
reverbZones
=
FindObjectsOfType
(
typeof
(
AudioReverbZone
))
as
AudioReverbZone
[];
}
...
...
@@ -80,27 +63,13 @@ public class VAUListener : MonoBehaviour {
if
(
HeadWidth
!=
ShadowHeadWidth
||
HeadHeight
!=
ShadowHeadHeight
||
HeadDepth
!=
ShadowHeadDepth
)
{
_
VA
.
SetSoundReceiverAnthropometricData
(
_ID
,
HeadWidth
,
HeadHeight
,
HeadDepth
);
VAUAdapter
.
VA
.
SetSoundReceiverAnthropometricData
(
_ID
,
HeadWidth
,
HeadHeight
,
HeadDepth
);
ShadowHeadWidth
=
HeadWidth
;
ShadowHeadHeight
=
HeadHeight
;
ShadowHeadDepth
=
HeadDepth
;
}
}
// Uses the View- and Up-Vector to transmit the position of the listener to VA
void
SetSoundReceiverPositionOrientation
()
{
_VA
=
VAUAdapter
.
VA
;
t
=
GetComponent
<
Transform
>();
q
=
t
.
rotation
;
Vector3
up
=
q
*
Vector3
.
up
;
Vector3
view
=
q
*
Vector3
.
forward
;
Vector3
view_ogl
=
new
Vector3
(
view
.
x
,
view
.
y
,
-
view
.
z
);
Vector3
up_ogl
=
new
Vector3
(
up
.
x
,
up
.
y
,
-
up
.
z
);
_VA
.
SetSoundReceiverPosition
(
_ID
,
new
VAVec3
(
t
.
transform
.
position
.
x
,
t
.
transform
.
position
.
y
,
-
t
.
transform
.
position
.
z
));
_VA
.
SetSoundReceiverOrientationVU
(
_ID
,
new
VAVec3
(
view_ogl
.
x
,
view_ogl
.
y
,
view_ogl
.
z
),
new
VAVec3
(
up_ogl
.
x
,
up_ogl
.
y
,
up_ogl
.
z
));
}
void
SetActiveReverbZones
()
{
if
(
reverbZones
==
null
)
...
...
@@ -131,9 +100,9 @@ public class VAUListener : MonoBehaviour {
if
(
actReverbTime
<
0.3f
)
_
VA
.
SetRenderingModuleMuted
(
"MyBinauralArtificialReverb"
,
true
);
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
"MyBinauralArtificialReverb"
,
true
);
else
_
VA
.
SetRenderingModuleMuted
(
"MyBinauralArtificialReverb"
,
false
);
VAUAdapter
.
VA
.
SetRenderingModuleMuted
(
"MyBinauralArtificialReverb"
,
false
);
shadowReverbTime
=
actReverbTime
;
...
...
@@ -143,20 +112,7 @@ public class VAUListener : MonoBehaviour {
if
(
ReverbTimeChanged
!=
null
)
ReverbTimeChanged
(
actReverbTime
);
_VA
.
SetArtificialReverberationTime
(
VAAudioRenderer
,
actReverbTime
);
}
void
OnSoundReceiverAuralizationModeChanged
(
string
AuraMode
)
{
_VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
AuraMode
);
}
private
void
OnDestroy
()
{
if
(
GetComponent
<
VAUAuralizationMode
>()
!=
null
)
GetComponent
<
VAUAuralizationMode
>().
AuraStringChanged
-=
OnSoundReceiverAuralizationModeChanged
;
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
VAAudioRenderer
,
actReverbTime
);
_VA
.
DeleteSoundReceiver
(
_ID
);
}
}
VAURendererArtificialReverb.cs
View file @
73e836a9
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
VAURendererArtificialReverb
:
VAU
RendererControll
er
public
class
VAURendererArtificialReverb
:
VAU
AudioRender
er
{
public
double
RoomReverberationTime
=
1.2
;
// s
public
double
RoomSurfaceArea
=
220.0
;
// m^2
...
...
@@ -14,9 +14,9 @@ public class VAURendererArtificialReverb : VAURendererController
void
Start
()
{
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
Renderer
ID
,
RoomReverberationTime
);
VAUAdapter
.
VA
.
SetArtificialSurfaceArea
(
Renderer
ID
,
RoomSurfaceArea
);
VAUAdapter
.
VA
.
SetArtificialRoomVolume
(
Renderer
ID
,
RoomVolume
);
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
ID
,
RoomReverberationTime
);
VAUAdapter
.
VA
.
SetArtificialSurfaceArea
(
ID
,
RoomSurfaceArea
);
VAUAdapter
.
VA
.
SetArtificialRoomVolume
(
ID
,
RoomVolume
);
RoomReverberationTimeShadow
=
RoomReverberationTime
;
RoomSurfaceAreaShadow
=
RoomSurfaceArea
;
...
...
@@ -27,17 +27,17 @@ public class VAURendererArtificialReverb : VAURendererController
{
if
(
RoomReverberationTime
!=
RoomReverberationTimeShadow
)
{
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
Renderer
ID
,
RoomReverberationTime
);
VAUAdapter
.
VA
.
SetArtificialReverberationTime
(
ID
,
RoomReverberationTime
);
RoomReverberationTimeShadow
=
RoomReverberationTime
;
}
if
(
RoomSurfaceArea
!=
RoomSurfaceAreaShadow
)
{
VAUAdapter
.
VA
.
SetArtificialSurfaceArea
(
Renderer
ID
,
RoomSurfaceArea
);
VAUAdapter
.
VA
.
SetArtificialSurfaceArea
(
ID
,
RoomSurfaceArea
);
RoomSurfaceAreaShadow
=
RoomSurfaceArea
;
}
if
(
RoomVolume
!=
RoomVolumeShadow
)
{
VAUAdapter
.
VA
.
SetArtificialRoomVolume
(
Renderer
ID
,
RoomVolume
);
VAUAdapter
.
VA
.
SetArtificialRoomVolume
(
ID
,
RoomVolume
);
RoomVolumeShadow
=
RoomVolume
;
}
}
...
...
VAUSoundReceiver.cs
View file @
73e836a9
...
...
@@ -4,7 +4,6 @@ using System.Collections;
using
VA
;
[
Tooltip
(
"Entity that can receive sound and will be rendered by an audio renderer"
)]
public
class
VAUSoundReceiver
:
MonoBehaviour
{
[
Tooltip
(
"Descriptive name"
)]
...
...
@@ -16,8 +15,8 @@ public class VAUSoundReceiver : MonoBehaviour {
[
Tooltip
(
"Connect an directivity to this receiver"
)]
public
VAUDirectivity
Directivity
=
null
;
private
int
_ID
;
pr
ivate
VANet
_VA
=
null
;
[
Tooltip
(
"Internal VA identifier"
)]
pr
otected
int
_ID
;
private
Quaternion
q
;
private
Transform
t
;
...
...
@@ -32,13 +31,12 @@ public class VAUSoundReceiver : MonoBehaviour {
void
Start
()
{
_VA
=
VAUAdapter
.
VA
;
_ID
=
_VA
.
CreateSoundReceiver
(
Name
);
_VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
"all"
);
if
(
HRIR
)
_VA
.
SetSoundReceiverDirectivity
(
_ID
,
HRIR
.
ID
);
_ID
=
VAUAdapter
.
VA
.
CreateSoundReceiver
(
Name
);
VAUAdapter
.
VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
"all"
);
if
(
Directivity
)
VAUAdapter
.
VA
.
SetSoundReceiverDirectivity
(
_ID
,
Directivity
.
ID
);
else
if
(
VAUAdapter
.
DefaultHRIRID
!=
-
1
)
_
VA
.
SetSoundReceiverDirectivity
(
_ID
,
VAUAdapter
.
DefaultHRIRID
);
VAUAdapter
.
VA
.
SetSoundReceiverDirectivity
(
_ID
,
VAUAdapter
.
DefaultHRIRID
);
SetSoundReceiverPositionOrientation
();
}
...
...
@@ -55,22 +53,21 @@ public class VAUSoundReceiver : MonoBehaviour {
}
// Uses the View- and Up-Vector to transmit the position of the listener to VA
void
SetSoundReceiverPositionOrientation
()
protected
void
SetSoundReceiverPositionOrientation
()
{
_VA
=
VAUAdapter
.
VA
;
t
=
GetComponent
<
Transform
>();
q
=
t
.
rotation
;
Vector3
up
=
q
*
Vector3
.
up
;
Vector3
view
=
q
*
Vector3
.
forward
;
Vector3
view_ogl
=
new
Vector3
(
view
.
x
,
view
.
y
,
-
view
.
z
);
Vector3
up_ogl
=
new
Vector3
(
up
.
x
,
up
.
y
,
-
up
.
z
);
_VA
.
SetSoundReceiverPosition
(
_ID
,
new
VAVec3
(
t
.
transform
.
position
.
x
,
t
.
transform
.
position
.
y
,
-
t
.
transform
.
position
.
z
));
_VA
.
SetSoundReceiverOrientationVU
(
_ID
,
new
VAVec3
(
view_ogl
.
x
,
view_ogl
.
y
,
view_ogl
.
z
),
new
VAVec3
(
up_ogl
.
x
,
up_ogl
.
y
,
up_ogl
.
z
));
VAUAdapter
.
VA
.
SetSoundReceiverPosition
(
_ID
,
new
VAVec3
(
t
.
transform
.
position
.
x
,
t
.
transform
.
position
.
y
,
-
t
.
transform
.
position
.
z
));
VAUAdapter
.
VA
.
SetSoundReceiverOrientationVU
(
_ID
,
new
VAVec3
(
view_ogl
.
x
,
view_ogl
.
y
,
view_ogl
.
z
),
new
VAVec3
(
up_ogl
.
x
,
up_ogl
.
y
,
up_ogl
.
z
));
}
void
OnSoundReceiverAuralizationModeChanged
(
string
AuraMode
)
protected
void
OnSoundReceiverAuralizationModeChanged
(
string
AuraMode
)
{
_
VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
AuraMode
);
VAUAdapter
.
VA
.
SetSoundReceiverAuralizationMode
(
_ID
,
AuraMode
);
}
private
void
OnDestroy
()
...
...
@@ -78,6 +75,6 @@ public class VAUSoundReceiver : MonoBehaviour {
if
(
GetComponent
<
VAUAuralizationMode
>()
!=
null
)
GetComponent
<
VAUAuralizationMode
>().
AuraStringChanged
-=
OnSoundReceiverAuralizationModeChanged
;
_
VA
.
DeleteSoundReceiver
(
_ID
);
VAUAdapter
.
VA
.
DeleteSoundReceiver
(
_ID
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment