This repository was archived by the owner on Feb 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMidiClient.h
More file actions
48 lines (40 loc) · 1.28 KB
/
MidiClient.h
File metadata and controls
48 lines (40 loc) · 1.28 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
//Midi Client
//Receives midi information from the midi server
//converts the midi information to a synthesized sound
#pragma once
//these old c libraries need to be included to accomplish some of the tasks required
#include <cstdlib>
#include <cstring>
#include <cstdio>
//these things are std c++
#include <iostream>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
//these things are external libraries
//no need for RtMidi because midi data is sent from server.
using namespace std;
class MidiClient{
static const unsigned int buffer_size = 4096;
unsigned char buffer[buffer_size];
int serv_portno;
int valread; //when reading from server this tells how many bytes
string ip_address;
int sock_fd;
struct sockaddr_in serv_addr;
int establishConnection();
//receive hello from server, send hello from client
//receive ports from server, send # from client
//receive midi info from server, send response of info
//play midi data received as it is received.
int sendGreeting();
int configureMidiPort();
int listenToMidiInput();
void clearBuffer();
bool isSuccess(int length); //send valread to isSuccess and it will read buffer
public:
MidiClient(string ip_addr="127.0.0.1", int portno=4445);
void startClient();
};