-
Notifications
You must be signed in to change notification settings - Fork 10
/
wavTrigger.h
167 lines (153 loc) · 4.16 KB
/
wavTrigger.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
// **************************************************************
// Filename: wavTrigger.h
// Date Created: 2/23/2014
//
// Comments: Robertsonics WAV Trigger serial control library
//
// Programmers: Jamie Robertson, info@robertsonics.com
//
// **************************************************************
//
// Revision History
//
// Date Description
// -------- -----------
//
// 02/22/14 First version created.
// LIMITATIONS: Hard-coded for AltSoftwareSerial Library.
// Also only supports commands TO the WAV Trigger. Will
// fix these things.
//
// 05/10/14 Tested with UNO. Added new functions for fades, cross-
// fades and starting multiple tracks in sample sync.
//
// 04/26/15 Added support for sample-rate / pitch bend control,
// and compile macro switches for hardware serial ports.
//
// 11/06/16 Support for v1.30 firmware features, including two-way
// communication with track status reporting.
//
// Changed "EOM" to "EOMWT" to not clash with USBHost_t36 library -BDL
// Expanded __WT_USE_SERIAL#__ to all 8 supported by Teensy4.1 -BDL
#ifndef WAVTRIGGER_H
#define WAVTRIGGER_H
#include "config.h"
#define CMD_GET_VERSION 1
#define CMD_GET_SYS_INFO 2
#define CMD_TRACK_CONTROL 3
#define CMD_STOP_ALL 4
#define CMD_MASTER_VOLUME 5
#define CMD_TRACK_VOLUME 8
#define CMD_AMP_POWER 9
#define CMD_TRACK_FADE 10
#define CMD_RESUME_ALL_SYNC 11
#define CMD_SAMPLERATE_OFFSET 12
#define CMD_TRACK_CONTROL_EX 13
#define CMD_SET_REPORTING 14
#define CMD_SET_TRIGGER_BANK 15
#define TRK_PLAY_SOLO 0
#define TRK_PLAY_POLY 1
#define TRK_PAUSE 2
#define TRK_RESUME 3
#define TRK_STOP 4
#define TRK_LOOP_ON 5
#define TRK_LOOP_OFF 6
#define TRK_LOAD 7
#define RSP_VERSION_STRING 129
#define RSP_SYSTEM_INFO 130
#define RSP_STATUS 131
#define RSP_TRACK_REPORT 132
#define MAX_MESSAGE_LEN 32
#define MAX_NUM_VOICES 14
#define VERSION_STRING_LEN 21
#define SOM1 0xf0
#define SOM2 0xaa
#define EOMWT 0x55
#ifdef __WT_USE_ALTSOFTSERIAL__
#include "../AltSoftSerial/AltSoftSerial.h"
#else
#include <HardwareSerial.h>
#ifdef __WT_USE_SERIAL1__
#define WTSerial Serial1
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL2__
#define WTSerial Serial2
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL3__
#define WTSerial Serial3
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL4__
#define WTSerial Serial4
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL5__
#define WTSerial Serial5
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL6__
#define WTSerial Serial6
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL7__
#define WTSerial Serial7
#define __WT_SERIAL_ASSIGNED__
#endif
#ifdef __WT_USE_SERIAL8__
#define WTSerial Serial8
#define __WT_SERIAL_ASSIGNED__
#endif
#ifndef __WT_SERIAL_ASSIGNED__
#define WTSerial Serial
#endif
#endif
class wavTrigger
{
public:
wavTrigger() {;}
~wavTrigger() {;}
void start(void);
void update(void);
void flush(void);
void setReporting(bool enable);
void setAmpPwr(bool enable);
bool getVersion(char *pDst, int len);
int getNumTracks(void);
bool isTrackPlaying(int trk);
void masterGain(int gain);
void stopAllTracks(void);
void resumeAllInSync(void);
void trackPlaySolo(int trk);
void trackPlaySolo(int trk, bool lock);
void trackPlayPoly(int trk);
void trackPlayPoly(int trk, bool lock);
void trackLoad(int trk);
void trackLoad(int trk, bool lock);
void trackStop(int trk);
void trackPause(int trk);
void trackResume(int trk);
void trackLoop(int trk, bool enable);
void trackGain(int trk, int gain);
void trackFade(int trk, int gain, int time, bool stopFlag);
void samplerateOffset(int offset);
void setTriggerBank(int bank);
private:
void trackControl(int trk, int code);
void trackControl(int trk, int code, bool lock);
#ifdef __WT_USE_ALTSOFTSERIAL__
AltSoftSerial WTSerial;
#endif
uint16_t voiceTable[MAX_NUM_VOICES];
uint8_t rxMessage[MAX_MESSAGE_LEN];
char version[VERSION_STRING_LEN];
uint16_t numTracks;
uint8_t numVoices;
uint8_t rxCount;
uint8_t rxLen;
bool rxMsgReady;
bool versionRcvd;
bool sysinfoRcvd;
};
#endif