Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
VAUnity
Commits
ba06a774
Commit
ba06a774
authored
Nov 17, 2016
by
Maurice Tayeb Andreas
Browse files
Mute und Loop von AudioSource auf SoundSource übertragen
Connection in Startfunktionen gelegt
parent
f5c3816b
Changes
4
Hide whitespace changes
Inline
Side-by-side
VACS.cs
View file @
ba06a774
...
...
@@ -80,7 +80,16 @@ namespace VA
public
int
LoadHRIRDataset
(
string
FilePath
,
string
Name
)
{
return
NativeLoadHRIRDataset
(
_NetClient
,
FilePath
,
Name
);
Console
.
WriteLine
(
"test"
);
try
{
return
NativeLoadHRIRDataset
(
_NetClient
,
FilePath
,
Name
);
}
catch
(
Exception
e
)
{
e
.
ToString
();
}
return
-
1
;
}
public
void
FreeHRIRDataset
(
int
HRIR
)
...
...
@@ -135,12 +144,19 @@ namespace VA
public
string
CreateAudiofileSignalSource
(
string
FilePath
,
string
Name
)
{
StringBuilder
sIdentifier
=
new
StringBuilder
(
256
);
int
b
=
NativeCreateAudiofileSignalSource
(
_NetClient
,
FilePath
,
Name
,
sIdentifier
);
//if(b==0)
//exeption
int
b
=
NativeCreateAudiofileSignalSource
(
_NetClient
,
FilePath
,
Name
,
sIdentifier
);
return
sIdentifier
.
ToString
();
}
public
void
SetSoundSourceVolume
(
int
iSoundSourceID
,
int
dGain
)
{
NativeSetSoundSourceVolume
(
_NetClient
,
iSoundSourceID
,
dGain
);
}
public
void
SetSoundSourceMuted
(
int
iSoundSourceID
,
bool
bMuted
)
{
NativeSetSoundSourceMuted
(
_NetClient
,
iSoundSourceID
,
bMuted
);
}
/*
* Native imported functions from C++ unmanaged library declared private, so they can not be accessed
...
...
VAUAdapter.cs
View file @
ba06a774
...
...
@@ -3,6 +3,7 @@ using UnityEditor;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
VA
;
// Adapter to VA (singleton)
...
...
@@ -13,7 +14,7 @@ public class VAUAdapter : MonoBehaviour {
public
static
int
Port
=
12340
;
public
static
string
DefaultHRIRPath
=
"$(DefaultHRIR)"
;
private
static
int
defaulthrir
;
private
static
VANet
_VA
=
n
ew
VANet
()
;
private
static
VANet
_VA
=
n
ull
;
// No public construction allowed
private
VAUAdapter
()
{}
...
...
@@ -22,10 +23,10 @@ public class VAUAdapter : MonoBehaviour {
{
get
{
bool
b
=
_VA
.
IsConnected
();
if
(!
_VA
.
IsConnected
())
if
(
_VA
==
null
)
{
Debug
.
Log
(
"Connected to VAServer throught VA."
);
_VA
=
new
VANet
();
Debug
.
Log
(
"Connected to VAServer through VANet-get."
);
Init
();
}
...
...
@@ -35,11 +36,16 @@ public class VAUAdapter : MonoBehaviour {
private
static
void
Init
()
{
Debug
.
Log
(
"Connected to VAServer through Init."
);
_VA
.
Connect
(
HostIP
,
Port
);
_VA
.
Reset
();
//defaulthrir = _VA.LoadHRIRDataset(DefaultHRIRPath, "DefaultHRIR");
try
{
_VA
.
Connect
(
HostIP
,
Port
);
_VA
.
Reset
();
defaulthrir
=
_VA
.
LoadHRIRDataset
(
DefaultHRIRPath
,
"DefaultHRIR"
);
}
catch
(
ExternalException
e
)
{
Debug
.
Log
(
e
.
ToString
());
}
}
public
static
int
DefaultHRIR
...
...
@@ -50,10 +56,7 @@ public class VAUAdapter : MonoBehaviour {
}
}
float
yaw
()
{
return
0f
;
}
// Use this for initialization
void
Awake
()
{
...
...
@@ -62,15 +65,13 @@ public class VAUAdapter : MonoBehaviour {
//var dllDirectory = @"C:/Users/Public/Documents/Unity Projects/Standard Assets Example Project/Assets/Plugins/VAUnity/bin"; // w
// var dllDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location + @"../../Plugins/VAUnity/bin";
//Environment.SetEnvironmentVariable( "PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory );
if
(
_VA
==
null
)
_VA
=
new
VANet
();
if
(!
_VA
.
IsConnected
())
{
Debug
.
Log
(
"Connected to VAServer through A
wake
."
);
Debug
.
Log
(
"Connected to VAServer through A
dapter
."
);
Init
();
}
//string audiofilepath = Application.dataPath.Remove(Application.dataPath.Length - 6) + AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip);
//string id = _VA.CreateAudiofileSignalSource(audiofilepath, "ita_test");
//Debug.Log(audiofilepath);
//Debug.Log(id);
}
...
...
@@ -80,8 +81,9 @@ public class VAUAdapter : MonoBehaviour {
}
void
OnDestroy
()
void
OnDestroy
()
{
Debug
.
Log
(
"Disconnected from Server."
);
_VA
.
Disconnect
();
}
}
VAUListener.cs
View file @
ba06a774
...
...
@@ -6,12 +6,15 @@ using VA;
public
class
VAUListener
:
MonoBehaviour
{
int
Listener
;
private
VANet
_VA
=
VAUAdapter
.
VA
;
public
string
listenername
=
"MyListener"
;
public
int
auramode
=
123
;
private
int
Listener
;
private
VANet
_VA
=
null
;
// Use this for initialization
void
Start
()
{
Listener
=
_VA
.
CreateListener
(
"MyListener"
,
123
,
VAUAdapter
.
DefaultHRIR
);
_VA
=
VAUAdapter
.
VA
;
Listener
=
_VA
.
CreateListener
(
listenername
,
auramode
,
VAUAdapter
.
DefaultHRIR
);
}
// Update is called once per frame
...
...
@@ -22,5 +25,10 @@ public class VAUListener : MonoBehaviour {
_VA
.
SetListenerOrientationYPR
(
Listener
,
-
t
.
transform
.
rotation
.
eulerAngles
.
x
,
-
t
.
transform
.
rotation
.
eulerAngles
.
y
,
t
.
transform
.
rotation
.
eulerAngles
.
z
);
}
//void OnDestroy()
//{
// _VA.DeleteListener(Listener);
//}
}
VAUSoundSource.cs
View file @
ba06a774
...
...
@@ -5,34 +5,30 @@ using System.Collections.Generic;
using
VA
;
public
class
VAUSoundSource
:
MonoBehaviour
{
private
int
SoundSource
;
public
int
AuralizationMode
=
1
;
[
Range
(
0.0f
,
100.0f
)]
public
double
Volume
=
70
;
public
int
Volume
=
70
;
public
string
SignalSource
=
""
;
private
VANet
_VA
=
VAUAdapter
.
VA
;
private
VANet
_VA
=
null
;
private
int
SoundSource
;
private
bool
islooping
;
private
bool
ismuted
;
// Use this for initialization
void
Start
()
{
SoundSource
=
_VA
.
CreateSoundSource
(
this
.
name
,
AuralizationMode
,
Volume
);
_VA
=
VAUAdapter
.
VA
;
SoundSource
=
_VA
.
CreateSoundSource
(
this
.
name
,
AuralizationMode
,
Volume
);
islooping
=
GetComponent
<
AudioSource
>().
loop
;
if
(
GetComponent
<
AudioSource
>()
!=
null
)
{
SignalSource
=
_VA
.
CreateAudiofileSignalSource
(
AssetDatabase
.
GetAssetPath
(
GetComponent
<
AudioSource
>().
clip
),
this
.
name
+
"_signal"
);
_VA
.
SetSoundSourceSignalSource
(
SoundSource
,
SignalSource
);
Debug
.
Log
(
SignalSource
);
Debug
.
Log
(
SignalSource
+
" connected to SoundSource "
+
SoundSource
);
_VA
.
SetAudiofileSignalSourcePlaybackAction
(
SignalSource
,
2
);
_VA
.
SetAudiofileSignalSourceIsLooping
(
SignalSource
,
islooping
);
}
//if( SignalSource == "" )
//{
// AudioClip AudioSourceClip = GetComponent<AudioSource>().clip;
// string SignalSourcePath = AssetDatabase.GetAssetPath(AudioSourceClip);
// Debug.Log(SignalSourcePath);
// //SignalSource = _VA.LoadAudiofileSignalSource(SignalSourcePath);
//}
//if ( SignalSource != "" )
// _VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
}
// Update is called once per frame
...
...
@@ -42,9 +38,16 @@ public class VAUSoundSource : MonoBehaviour {
Transform
t
=
GetComponent
<
Transform
>();
_VA
.
SetSoundSourcePosition
(
SoundSource
,
t
.
transform
.
position
.
x
,
t
.
transform
.
position
.
y
,
-
t
.
transform
.
position
.
z
);
_VA
.
SetSoundSourceOrientationYPR
(
SoundSource
,
-
t
.
transform
.
rotation
.
eulerAngles
.
x
,
-
t
.
transform
.
rotation
.
y
,
t
.
transform
.
rotation
.
eulerAngles
.
z
);
ismuted
=
GetComponent
<
AudioSource
>().
mute
;
_VA
.
SetSoundSourceMuted
(
SoundSource
,
ismuted
);
//_VA.NativeSetSoundSourceVolume(SoundSource, Volume);
}
//void OnDestroy()
//{
// _VA.DeleteSignalSource(SignalSource);
// _VA.DeleteSoundSource(SoundSource);
//}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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