forked from TMaxElectronics/MidiStick_Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
211 lines (170 loc) · 5.48 KB
/
types.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
Copyright (C) 2020,2021 TMax-Electronics.de
This file is part of the MidiStick Firmware.
the MidiStick Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the MidiStick Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the MidiStick Firmware. If not, see <https://www.gnu.org/licenses/>.
*/
#include <xc.h>
#include <stdint.h>
#ifndef types
#define types
#define VMS_MAX_BRANCHES 4
typedef struct _SynthVoice_ SynthVoice;
typedef struct _ChannelInfo_ ChannelInfo;
typedef struct _SINE_DATA_ SINE_DATA;
typedef struct _VMS_listDataObject_ VMS_listDataObject;
typedef struct _VMS_BLOCK_ VMS_BLOCK;
typedef struct _MapData_ MAPTABLE_DATA;
typedef struct _MapEntry_ MAPTABLE_ENTRY;
typedef struct _MapHeader_ MAPTABLE_HEADER;
typedef enum {TONE_NORMAL, TONE_NOISE, TONE_SINGE_SHOT} ToneType;
typedef enum {MOD_AM_NOISE, MOD_FM_NOISE, MOD_AM_SWEEP, MOD_FM_SWEEP} ModulationType;
typedef enum {VMS_EXP, VMS_EXP_INV, VMS_LIN, VMS_SIN, VMS_JUMP} VMS_MODTYPE;
typedef enum {maxOnTime, minOnTime, onTime, otCurrent, otTarget, otFactor, frequency, freqCurrent, freqTarget, freqFactor, noise, pTime, circ1, circ2, circ3, circ4, CC_102, CC_103, CC_104, CC_105, CC_106, CC_107, CC_108, CC_109, CC_110, CC_111, CC_112, CC_113, CC_114, CC_115, CC_116, CC_117, CC_118, CC_119, HyperVoice_Count, HyperVoice_Phase, KNOWNVAL_MAX} KNOWN_VALUE;
typedef enum {RISING, FALLING, ANY, NONE} DIRECTION;
typedef enum {INVERTED = 0, NORMAL = 1} NOTEOFF_BEHAVIOR;
typedef struct _DLLObject_ DLLObject;
struct _DLLObject_{
DLLObject * next;
DLLObject * prev;
uint32_t uid;
void * data;
};
struct _MapData_{
int16_t noteFreq;
uint8_t targetOT;
uint8_t flags;
VMS_BLOCK * VMS_Startblock; //this is the VMS_Block ID when in flash, and will be changed to be the pointer to the block when loaded into ram
}__attribute__((packed));
struct _MapEntry_{
uint8_t startNote;
uint8_t endNote;
MAPTABLE_DATA data;
}__attribute__((packed));
struct _MapHeader_{
uint8_t listEntries;
uint8_t programNumber;
char name[18];
} __attribute__((packed));
//struct to contain all variables and parameters for the voices
struct _SynthVoice_{
uint32_t freqTarget;
uint32_t freqCurrent;
int32_t freqFactor;
int32_t periodCurrent;
int32_t divCurrent;
uint32_t otCompressed;
uint32_t otTarget;
uint32_t otCurrent;
int32_t otFactor;
uint32_t outputOT;
uint32_t noiseTarget;
uint32_t noiseCurrent;
uint32_t noiseRaw;
int32_t noiseFactor;
uint8_t currNote;
uint8_t hyperVoiceCount;
uint16_t hyperVoicePhase;
int32_t hyperVoicePhaseFrac;
uint16_t hyperVoice_timings[2];
uint32_t on;
uint32_t noteAge;
uint8_t currNoteOrigin;
int32_t portamentoParam;
int32_t circ1;
int32_t circ2;
int32_t circ3;
int32_t circ4;
uint8_t id;
MAPTABLE_DATA * map;
uint32_t * hyperVoice_DCHXCONptr;
uint32_t * hyperVoice_DCHXECONptr;
uint32_t * tmrPR;
uint32_t * tmrCON;
uint32_t * tmrTMR;
uint32_t iecMask;
};
struct _ChannelInfo_{
uint32_t bendFactor;
unsigned sustainPedal;
unsigned damperPedal;
uint16_t bendMSB;
uint16_t bendLSB;
float bendRange;
uint16_t currOT;
int32_t portamentoTime;
uint32_t lastFrequency;
uint8_t parameters[18];
uint16_t currVolume;
uint16_t currStereoVolume;
uint8_t currStereoPosition;
uint16_t currVolumeModifier;
uint8_t currProgramm;
MAPTABLE_HEADER * currentMap;
};
struct _SINE_DATA_{
int32_t currCount;
};
struct _VMS_listDataObject_{
SynthVoice * targetVoice;
VMS_BLOCK * block;
void * data;
DIRECTION thresholdDirection;
uint32_t nextRunTime;
uint32_t period;
};
typedef struct{
KNOWN_VALUE sourceId : 8;
int32_t rangeStart : 12;
int32_t rangeEnd : 12;
} RangeParameters;
struct _VMS_BLOCK_{
uint32_t uid;
VMS_BLOCK * nextBlocks[VMS_MAX_BRANCHES];
VMS_BLOCK * offBlock;
NOTEOFF_BEHAVIOR behavior;
VMS_MODTYPE type;
KNOWN_VALUE target;
DIRECTION thresholdDirection;
int32_t targetFactor;
int32_t param1;
int32_t param2;
int32_t param3;
uint32_t period;
uint32_t flags;
};
typedef struct{
uint16_t v1Freq;
uint16_t v1OT;
uint16_t v1NoiseAmp;
uint16_t v1Flags;
uint16_t v2Freq;
uint16_t v2OT;
uint16_t v2NoiseAmp;
uint16_t v2Flags;
uint16_t v3Freq;
uint16_t v3OT;
uint16_t v3NoiseAmp;
uint16_t v3Flags;
uint16_t v4Freq;
uint16_t v4OT;
uint16_t v4NoiseAmp;
uint16_t v4Flags;
uint8_t v1HPVCount;
uint8_t v1HPVPhase;
uint8_t v2HPVCount;
uint8_t v2HPVPhase;
uint8_t v3HPVCount;
uint8_t v3HPVPhase;
uint8_t v4HPVCount;
uint8_t v4HPVPhase;
} RAW_WRITE_NOTES_Cmd;
#endif