-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.h
59 lines (41 loc) · 1.34 KB
/
app.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
#ifndef APP_H
#define APP_H
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include "scales.h"
#include "rtmidi_c.h"
typedef struct {
// If dispersion is lower than this value - ignore landmark set.
float dispersion_lower_bound;
// Scale dispersion values by this one.
float dispersion_upper_bound;
// If hand hasn't displacement as much as the square root of this value, relative to previous position, do nothing.
float d2_threshold;
// Indices per unit distance.
float index_rate;
// Maximum volume for emitted notes.
uint8_t max_volume;
Scale scale;
// Id for MIDI output port.
unsigned int midiout_port;
// If true, then NOTE_OFF messages are never sent. Otherwise, the last played note will be turned off before the next note is turned on.
bool let_ring;
// The MIDI program to use.
uint8_t program;
// Cooldown between successive midi messages, in milliseconds.
clock_t cooldown_millis;
} AppConfig;
void default_app_config(AppConfig* cfg, Scale sc);
typedef struct {
float lastpos[3];
tone_t last_played;
RtMidiOutPtr outdevice;
clock_t last_time;
} AppState;
AppState create_app_state();
void set_output_device(AppState* st, RtMidiOutPtr ptr);
void program_change(RtMidiOutPtr outdevice, uint8_t program);
// Try to load app config from an INI file.
bool app_config_from_ini(AppConfig* cfg, const char* path);
#endif