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)
ITADataSources
Commits
1f61b7a6
Commit
1f61b7a6
authored
Nov 16, 2016
by
Anne Heimes
Browse files
ITA Sampleframe mit Netzwerkverbindung
parent
0c566b71
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/VistaNetTest/VistaNetClient.cpp
View file @
1f61b7a6
...
...
@@ -9,6 +9,10 @@
#include
<ITAStringUtils.h>
#include
<ITAStopwatch.h>
#include
<ITAStringUtils.h>
#include
<ITASampleFrame.h>
#include
<ITAAudiofileWriter.h>
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -49,15 +53,76 @@ int main(int argc, char** argv) {
VistaTCPSocket
*
pSocket
=
oServer
.
GetNextClient
();
unsigned
long
l
=
pSocket
->
WaitForIncomingData
(
0
);
std
::
cout
<<
"l = "
<<
l
<<
std
::
endl
;
if
(
l
==
sizeof
(
VistaType
::
byte
)
)
{
bool
bAck
;
pSocket
->
ReceiveRaw
(
&
bAck
,
l
);
std
::
cout
<<
"Client received acknowledge flag '"
<<
bAck
<<
"'"
<<
std
::
endl
;
}
//enpfangen bool array
bool
bArr
[
5
];
if
(
l
==
sizeof
(
bArr
))
{
pSocket
->
ReceiveRaw
(
&
bArr
,
l
);
std
::
cout
<<
"bool array is '"
;
for
(
int
i
=
0
;
i
<
5
;
i
++
){
std
::
cout
<<
bArr
[
i
]
<<
' '
;
}
std
::
cout
<<
std
::
endl
;
}
//empfangen Int-Array
int
iArr
[
6
];
//std::cout << "iArr = " << sizeof(iArr) << std::endl;
if
(
l
==
sizeof
(
iArr
))
{
pSocket
->
ReceiveRaw
(
&
iArr
,
l
);
std
::
cout
<<
"int array is '"
;
for
(
int
i
=
0
;
i
<
5
;
i
++
){
std
::
cout
<<
iArr
[
i
]
<<
' '
;
}
std
::
cout
<<
std
::
endl
;
}
//Empfangen der wave datei
//empfangen der Infos zur bertragung
int
iDetails
[
3
];
std
::
cout
<<
"iDetails = "
<<
sizeof
(
iDetails
)
<<
std
::
endl
;
if
(
l
==
sizeof
(
iDetails
))
{
pSocket
->
ReceiveRaw
(
&
iDetails
,
l
);
std
::
cout
<<
"iLength: "
<<
iDetails
[
0
]
<<
"
\n
iChannels: "
<<
iDetails
[
1
]
<<
"
\n
iFrequency: "
<<
iDetails
[
2
]
<<
std
::
endl
;
//oCommandChannelConnection.Close(false);
unsigned
long
m
=
pSocket
->
WaitForIncomingData
(
0
);
std
::
cout
<<
"l = "
<<
m
<<
std
::
endl
;
ITASampleFrame
oMusik
(
iDetails
[
1
],
iDetails
[
0
],
true
);
ITASampleFrame
otest
(
iDetails
[
1
],
iDetails
[
0
],
true
);
// schleife fr jeden channel
oCommandChannelConnection
.
Close
(
false
);
//pSocket->ReceiveRaw(oMusik[0].data(), iDetails[0] * iDetails[2]);
/*
pSocket->ReceiveRaw(oMusik[0].data(), m);
pData += m;
m = pSocket->WaitForIncomingData(0);
pSocket->ReceiveRaw(oMusik[0].data()+m, m);
*/
int
iDiff
=
0
;
while
(
iDiff
<
iDetails
[
0
])
{
m
=
pSocket
->
WaitForIncomingData
(
0
);
pSocket
->
ReceiveRaw
(
oMusik
[
0
].
data
()
+
iDiff
,
m
);
iDiff
+=
m
/
4
;
std
::
cout
<<
"Fortschritt = "
<<
iDiff
<<
" / "
<<
iDetails
[
0
]
<<
std
::
endl
;
}
writeAudiofile
(
"EmpfMus.wav"
,
&
oMusik
,
iDetails
[
2
],
ITAQuantization
::
ITA_INT16
);
oCommandChannelConnection
.
Close
(
false
);
}
return
0
;
}
tests/VistaNetTest/VistaNetServer.cpp
View file @
1f61b7a6
...
...
@@ -9,6 +9,9 @@
#include
<VistaInterProcComm/IPNet/VistaIPAddress.h>
#include
<ITAStringUtils.h>
#include
<ITASampleFrame.h>
#include
<ITAAudiofileWriter.h>
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -48,9 +51,43 @@ int main(int argc, char** argv) {
VistaConnectionIP
oConnection
(
VistaConnectionIP
::
CT_TCP
,
sRemoteAddress
,
iRequestedResultChannelPort
);
bool
bAck
=
oConnection
.
GetIsConnected
();
oConnection
.
Send
(
&
bAck
,
sizeof
(
bool
)
);
oConnection
.
WaitForSendFinish
(
0
);
// Bool senden
//bool bAck = oConnection.GetIsConnected();
//oConnection.Send(&bAck, sizeof( bool ) );
// Bool Array Senden
//bool bArr[5] = { 1, 0, 1, 0 };
//oConnection.Send(&bArr, sizeof(bArr));
// int array senden
//int iArr[6] = { 12, 2, 34, -5, 111 };
//oConnection.Send(&iArr, sizeof(iArr));
//einlesen waveDatei
ITASampleFrame
oMusik
;
oMusik
.
Load
(
"music.wav"
);
int
iLength
=
oMusik
.
GetLength
();
int
iChannels
=
oMusik
.
channels
();
int
iFrequency
=
44100
;
writeAudiofile
(
"sendMusik.wav"
,
&
oMusik
,
44100
,
ITAQuantization
::
ITA_INT16
);
//senden der infos vor bertragung
int
iDetails
[
3
]
=
{
iLength
,
iChannels
,
iFrequency
};
oConnection
.
Send
(
&
iDetails
,
sizeof
(
iDetails
));
oConnection
.
WaitForSendFinish
(
0
);
//senden des Objektes
std
::
cout
<<
iLength
*
sizeof
(
float
)
<<
std
::
endl
;
oConnection
.
Send
(
oMusik
[
0
].
data
(),
iLength
*
sizeof
(
float
));
oConnection
.
WaitForSendFinish
(
0
);
//oConnection.Send(&oFrame, sizeof(oFrame));
//std::cout << sizeof(oFrame) << std::endl;
std
::
cout
<<
"Result channel connection successfully established"
<<
std
::
endl
;
...
...
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