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
e0e0aa4d
Commit
e0e0aa4d
authored
Sep 08, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Adding some test files to connect Unity with VA
parents
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
tests/jst/VAAdapter.cs
0 → 100644
View file @
e0e0aa4d
using
UnityEngine
;
using
System
;
using
System.Collections
;
using
VA
;
public
class
VAAdapter
:
MonoBehaviour
{
private
VANet
m_VA
=
new
VANet
();
// Use this for initialization
void
Start
()
{
//var dllDirectory = @"Assets/Plugins/VAUnity/bin";
//var dllDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//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 );
m_VA
.
Connect
();
}
// Update is called once per frame
void
Update
()
{
}
}
tests/xavier/ConnectWithAPI.cs
0 → 100644
View file @
e0e0aa4d
using
UnityEngine
;
using
System
;
using
System.Runtime.InteropServices
;
public
class
ConnectWithAPI
:
MonoBehaviour
{
IntPtr
client
;
Transform
tra
;
Transform
firsT
;
string
sourceID
;
int
SoundSourceID
;
public
GameObject
cube
;
int
IDHRIR
;
int
IDListener
;
public
GameObject
firsTperson
;
bool
ok
=
false
;
void
Start
()
{
tra
=
GetComponent
<
Transform
>();
firsT
=
firsTperson
.
GetComponent
<
Transform
>();
client
=
CreateClient
();
if
((
API
.
Connection
(
client
,
"127.0.0.1"
,
12340
))==
1
)
{
if
(
API
.
GetState
(
client
)
!=
1
)
API
.
Initialize
(
client
);
ok
=
true
;
sourceID
=
CreateSource
();
playAndRepeat
();
SoundSourceID
=
NewSoundSource
();
API
.
SetSoundSourcePosition
(
client
,
SoundSourceID
,
cube
.
transform
.
position
.
x
,
cube
.
transform
.
position
.
y
,
-
cube
.
transform
.
position
.
z
);
API
.
SetSoundSourceSignalSource
(
client
,
SoundSourceID
,
sourceID
);
IDHRIR
=
loadHRIRDataset
();
IDListener
=
CreateListener
(
IDHRIR
);
API
.
SetListenerPosition
(
client
,
IDListener
,
tra
.
transform
.
position
.
x
,
tra
.
transform
.
position
.
y
,
tra
.
transform
.
position
.
z
);
API
.
SetListenerOrientationYPR
(
client
,
IDListener
,
tra
.
transform
.
eulerAngles
.
y
,
firsT
.
transform
.
eulerAngles
.
x
,
0
);
API
.
SetActiveListener
(
client
,
IDListener
);
// InvokeRepeating("here", 0, 0.01f);
}
}
void
Update
()
{
if
(
ok
==
true
)
here
();
if
(
Input
.
GetKeyDown
(
"p"
))
{
CancelInvoke
(
"here"
);
if
(
API
.
Disconnect
(
client
)
==
0
)
Debug
.
Log
(
"Disconnected"
);
UnityEditor
.
EditorApplication
.
isPlaying
=
false
;
}
}
void
here
()
{
API
.
SetListenerPosition
(
client
,
IDListener
,
tra
.
transform
.
position
.
x
,
tra
.
transform
.
position
.
y
,
-
tra
.
transform
.
position
.
z
);
API
.
SetListenerOrientationYPR
(
client
,
IDListener
,-
tra
.
transform
.
eulerAngles
.
y
,
-
firsT
.
transform
.
eulerAngles
.
x
,
0
);
Debug
.
Log
(
"-"
+
tra
.
transform
.
rotation
.
eulerAngles
.
y
.
ToString
());
Debug
.
Log
(
"-"
+
firsT
.
transform
.
rotation
.
eulerAngles
.
x
.
ToString
());
}
IntPtr
CreateClient
()
{
return
API
.
CreateClient
();
}
string
CreateSource
()
{
return
Marshal
.
PtrToStringAnsi
(
API
.
CreateAudiofileSignalSource
(
client
,
"C:\\Users\\javier\\Desktop\\VA ejemplos\\ita_demosound.wav"
,
"demo"
));
}
void
playAndRepeat
()
{
/*
-1< No action
0< Stop playback
1< Pause playback
2< Start/resume playback
*/
int
PlayState
=
2
;
bool
Lopping
=
true
;
API
.
SetAudiofileSignalSourcePlaybackAction
(
client
,
sourceID
,
PlayState
);
API
.
SetAudiofileSignalSourceIsLooping
(
client
,
sourceID
,
Lopping
);
}
int
NewSoundSource
()
{
string
Name
=
"new"
;
int
AuralizationMode
=
2047
;
double
Volume
=
1.0
;
return
API
.
CreateSoundSource
(
client
,
Name
,
AuralizationMode
,
Volume
);
}
int
loadHRIRDataset
()
{
string
FileName
=
"C:\\Users\\javier\\Desktop\\VA.win32-x64.vc12\\VA.win32-x64.vc12\\data\\HRIR\\ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff"
;
string
Name1
=
"default"
;
return
API
.
LoadHRIRDataset
(
client
,
FileName
,
Name1
);
}
int
CreateListener
(
int
IDHRIR
)
{
string
Name3
=
"Me"
;
int
AuralizationMode2
=
2047
;
return
API
.
CreateListener
(
client
,
Name3
,
AuralizationMode2
,
IDHRIR
);
}
void
OnGUI
()
{
GUI
.
Label
(
new
Rect
(
0
,
0
,
100
,
100
),
(
1.0f
/
Time
.
smoothDeltaTime
).
ToString
());
}
}
tests/xavier/VA.cs
0 → 100644
View file @
e0e0aa4d
This diff is collapsed.
Click to expand it.
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