-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.cpp
More file actions
70 lines (60 loc) · 1.18 KB
/
App.cpp
File metadata and controls
70 lines (60 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "App.h"
#include "SFML\Network.hpp"
#include "AufnehmButton.h"
App::App(void)
{
aButton = 0;
recorder = 0;
}
App::~App(void)
{
if(recorder)
delete recorder;
}
void App::setButton(AufnehmButton * butt)
{
aButton = butt;
}
bool App::toggleAufnahme()
{
if(recorder != 0)
{
recorder->stop();
processBuffer(recorder->getBuffer());
delete recorder;
recorder = 0;
aButton->setString("Aufnahme");
return false;
}
else
{
recorder = new sf::SoundBufferRecorder;
recorder->start(22050);
aButton->setString("Stop");
return true;
}
}
void App::processBuffer(const sf::SoundBuffer &buffer)
{
sf::Packet packetSamples, packetInfos;
packetSamples.append(buffer.getSamples(), buffer.getSampleCount() * buffer.getChannelCount() * 2);
packetInfos << buffer.getChannelCount();
sendBuffer(connector, packetSamples, packetInfos);
}
void App::sendBuffer(TCPconnection &connector, sf::Packet &sampleP, sf::Packet &infoP)
{
makeIPAdress();
connector.connectWithSocket(m_ipAddress, sampleP, infoP);
}
void App::ConnectorW8()
{
connector.waitForConnections();
}
void App::setIP(std::string &str)
{
m_ipString = str;
}
void App::makeIPAdress()
{
m_ipAddress = m_ipString;
}