-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.cpp
48 lines (34 loc) · 875 Bytes
/
common.cpp
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
#include <jack/jack.h>
#include <jack/midiport.h>
#include "common.h"
#include <string>
#include <sstream>
#include <stdio.h>
#include <queue>
using namespace std;
queue<unsigned char *> cc_queue;
void queue_up_single_cc(int controller, int value)
{
unsigned char *buffer=new unsigned char[3];
buffer[0]=0xB0;
buffer[1]=controller;
buffer[2]=value;
cc_queue.push(buffer);
}
void send_out_any_waiting_cc_messages(void *midi_port_buf)
{
while (cc_queue.empty()==false)
{
unsigned char *buffer = jack_midi_event_reserve(midi_port_buf, 0, 3);
if(buffer==NULL)
{
return; //whoops, no more space to send message right now. wait for later.
}
unsigned char *b=cc_queue.front();
cc_queue.pop();
buffer[0]=b[0];
buffer[1]=b[1];
buffer[2]=b[2];
delete(b);
}
}