-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
62 lines (52 loc) · 1.04 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
// Autor: Przemysław Czechowski
#include <Sound.h>
#include <defines.h>
#include <Notes.h>
#include <CantusFirmusGenerator.h>
Sound::Signal signal{};
CantusFirmusGenerator generator{};
volatile bool next_note = false;
#ifndef TEST
ISR(TIMER2_COMPA_vect) {
HW::audio_out(signal.next());
signal.position++;
signal.swap_if_reached_end();
}
ISR(TIMER0_COMPA_vect) {
static unsigned short count = 0;
++count;
if(count != 500/4)
{
return;
}
cli();
count = 0;
next_note = true;
sei();
}
#endif
int main()
{
DEBUG("starting main");
Sound::Wave sound = Sound::Wave{440.};
signal = Sound::Signal(sound);
HW::configure_pins();
DEBUG("starting loop");
while (true)
{
if(signal.needs_prepare())
{
signal.prepare();
//HW::toggle_led_if(100);
}
if(next_note)
{
sound = Sound::Wave{generator.GetNext()};
//sound.add(&base);
signal.sound = sound;
next_note = false;
}
}
return 0;
}
//---------------------------------------------------------------------------