-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.cpp
More file actions
56 lines (43 loc) · 1.1 KB
/
audio.cpp
File metadata and controls
56 lines (43 loc) · 1.1 KB
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
/**
* @file audio.cpp
* @brief Functions for playing audio with the PT8211
*/
#include "audio.h"
#include "show.h"
#include <Audio.h>
#include <SD.h>
AudioPlaySdWav sdWav;
AudioAmplifier ampLeft;
AudioAmplifier ampRight;
AudioOutputPT8211 pt8211;
AudioConnection patchCord1(sdWav, 0, ampLeft, 0);
AudioConnection patchCord2(sdWav, 1, ampRight, 0);
AudioConnection patchCord3(ampLeft, 0, pt8211, 0);
AudioConnection patchCord4(ampRight, 0, pt8211, 1);
float gainLvl = 0.5;
void setupAudio() {
AudioMemory(8);
ampLeft.gain(gainLvl);
ampRight.gain(gainLvl);
}
uint32_t getAudioMS() {
ampLeft.gain(0);
ampRight.gain(0);
char audioFile[8] = "";
sprintf(audioFile, "%03d.WAV", getShowNumber());
sdWav.play(audioFile);
delay(1000);
uint32_t audioMS = sdWav.lengthMillis();
sdWav.stop();
ampLeft.gain(gainLvl);
ampRight.gain(gainLvl);
return audioMS;
}
void playAudio() {
char audioFile[8] = "";
sprintf(audioFile, "%03d.WAV", getShowNumber());
sdWav.play(audioFile);
}
void stopAudio() {
sdWav.stop();
}