Skip to content

Commit d88cc63

Browse files
committed
Added command to set input gain level
Signed-off-by: jamie robertson <jamie@robertsonics.com>
1 parent 71a2fa1 commit d88cc63

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Tsunami tsunami;
8989
audio is playing, you will hear the result immediately. If audio is not playing,
9090
the new gain will be used the next time a track is started.
9191

92+
**tsunami.inputGain(int gain)** - this function immediately sets the gain of the
93+
stereo input to the specified value. The range for gain is -70 to +4. If audio
94+
audio is playing, you will hear the result immediately.
95+
9296
**tsunami.samplerateOffset(int out, int offset)** - this function immediately sets sample-rate offset,
9397
or playback speed / pitch, of the specified stereo output. The range for
9498
for the offset is -32767 to +32676, giving a speed range of 1/2x to 2x, or a

Tsunami.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,23 @@ uint8_t o;
193193
TsunamiSerial.write(txbuf, 8);
194194
}
195195

196+
// **************************************************************
197+
void Tsunami::inputGain(int gain) {
198+
199+
uint8_t txbuf[8];
200+
unsigned short vol;
201+
202+
txbuf[0] = SOM1;
203+
txbuf[1] = SOM2;
204+
txbuf[2] = 0x07;
205+
txbuf[3] = CMD_MASTER_VOLUME;
206+
vol = (unsigned short)gain;
207+
txbuf[4] = (uint8_t)vol;
208+
txbuf[5] = (uint8_t)(vol >> 8);
209+
txbuf[6] = EOM;
210+
TsunamiSerial.write(txbuf, 7);
211+
}
212+
196213
// **************************************************************
197214
void Tsunami::setReporting(bool enable) {
198215

Tsunami.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define CMD_SET_TRIGGER_BANK 14
3737
#define CMD_SET_INPUT_MIX 15
3838
#define CMD_SET_MIDI_BANK 16
39+
#define CMD_INPUT_GAIN 18
3940

4041
#define TRK_PLAY_SOLO 0
4142
#define TRK_PLAY_POLY 1
@@ -99,6 +100,7 @@ class Tsunami
99100
int getNumTracks(void);
100101
bool isTrackPlaying(int trk);
101102
void masterGain(int out, int gain);
103+
void inputGain(int gain);
102104
void stopAllTracks(void);
103105
void resumeAllInSync(void);
104106
void trackPlaySolo(int trk, int out, bool lock);

0 commit comments

Comments
 (0)