-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.cc
72 lines (55 loc) · 1.66 KB
/
main.cc
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
#include "audio_stream.hh"
#include "drivers/uart.hh"
#include "drv/pmic.hh"
#include "stm32disco_buttons_conf.hh"
#include "stm32mp1xx.h"
#include "synth_list.hh"
using namespace STM32MP1Disco;
void main()
{
// Codec is powered by LDO1 on the Disco board
STPMIC1 pmic{I2C4};
pmic.setup_ldo1();
// UI
Uart<UART4_BASE> uart;
uart.write("\r\n\r\nStarting Audio Processor\r\n");
uart.write("Press User1 button to select a synth\r\n");
User1Button button1;
User2Button button2;
SynthList synths;
int current_synth = SynthList::Synths::DualFMOscillators;
uart.write("Using Synth: ");
uart.write(synths.name[current_synth]);
uart.write("\r\n");
AudioStream audio;
audio.start(synths.process_func[current_synth]);
constexpr uint32_t LoadTimerStartingValue = 5000000;
uint32_t display_load_timer = LoadTimerStartingValue;
while (true) {
button1.update();
button2.update();
// Select synth
if (button1.is_just_pressed()) {
current_synth++;
if (current_synth == SynthList::NumSynths)
current_synth = 0;
audio.set_process_function(synths.process_func[current_synth]);
uart.write("Using Synth: ");
uart.write(synths.name[current_synth]);
uart.write("\r\n");
// Let the new synth run for a bit, so we get an accurate load measurement
display_load_timer = LoadTimerStartingValue;
}
if (button2.is_just_pressed()) {
// we can do something here... send a signal to a synth, or adjust a parameter?
}
if (display_load_timer == 1) {
uart.write("Current load: ");
uart.write(audio.get_load_measurement());
uart.write("%\r\n\r\n");
}
if (display_load_timer)
display_load_timer--;
}
}
extern "C" void aux_core_main() {}