-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPorts.h
executable file
·88 lines (67 loc) · 2.57 KB
/
Ports.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef PORTS_H
#define PORTS_H
#include "Pixi.h"
#include "MidiOutput.h"
#include <stdlib.h>
#include <sys/time.h>
#define PORTS_OUTPUT_MODE_GATE 1
#define PORTS_OUTPUT_MODE_TRIG 2
#define PORTS_OUTPUT_MODE_SYNCTRIG 3
#define PORTS_OUTPUT_MODE_CVUNI 4
#define PORTS_OUTPUT_MODE_FLIPFLOP 10
#define PORTS_OUTPUT_MODE_RANDOM_SH 40
#define PORTS_OUTPUT_MODE_CVBI 50
#define PORTS_OUTPUT_MODE_LFO_SINE 71
#define PORTS_OUTPUT_MODE_LFO_SAW 81
#define PORTS_OUTPUT_MODE_LFO_RAMP 82
#define PORTS_OUTPUT_MODE_LFO_TRI 83
#define PORTS_OUTPUT_MODE_LFO_SQUARE 91
#define PORTS_INPUT_MODE_GATE 100
#define PORTS_INPUT_MODE_TRIG 101
#define PORTS_INPUT_MODE_CVUNI 102
#define PORTS_INPUT_MODE_CVBI 150
#define PORTS_TIMER_PERIOD 2000 //in microseconds
#define PORTS_TIMER_PERIOD_TOLERANCE 0.3 //
#define PORTS_TRIGGER_CYCLES 2000 / PORTS_TIMER_PERIOD //
#define PORTS_TRIGGER_LEVEL 0.5 / PORTS_TIMER_PERIOD //
#define BIPOLAR_POWER false
//forward delcaration
inline void pixiTimerCallback(int sig_num);
class Ports {
public:
Ports();
~Ports();
void start();
void startOSC(int port);
void pixiTimer();
void oscMessage(const char *path, const float value);
void handleChannelMsg(const char* str, int offset, int channel, float value);
bool stop;
bool restart;
private:
int currentBank = 0;
Pixi pixi;
MidiOutput midiOutput;
int channelModes[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int channelTrigCycles[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
bool channelSyncTriggerRequested[20] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
double channelValues[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
double channelLFOPhases[20]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // 0 to 1
double channelLFOFrequencies[20]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
double channelLFOPWMs[20]= {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
bool clockFrame=false;
struct timeval lastTimer;
struct timeval lastReset;
struct timeval now;
struct timeval elapsed;
struct timeval started;
int parseChannel(const char* path, int offset);
int parseOutputMode(const char* path, int offset);
int parseInputMode(const char* path, int offset);
bool channelIsInput(int channel);
bool channelIsLfo(int channel);
bool channelIsBipolar(int channel);
int parseInt(const char* a, int offset);
};
extern Ports portsInstance;
#endif // PORTS_H