-
Notifications
You must be signed in to change notification settings - Fork 16
/
ModuleChords.cpp
29 lines (24 loc) · 982 Bytes
/
ModuleChords.cpp
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
#include "Arduino.h"
#include "ModuleChords.h"
#include "defines.h"
#include "GlobalScales.h"
#include "GlobalChords.h"
ModuleChords::ModuleChords()
{
// Initialize all inputs
this->root_note_input = NULL;
this->chord_input = NULL;
// Instantiate all outputs
this->note_1_output = new ModuleOutput(this);
this->note_2_output = new ModuleOutput(this);
this->note_3_output = new ModuleOutput(this);
}
uint16_t ModuleChords::compute()
{
uint16_t root_note_input = this->readInput(this->root_note_input, 0, 60);
uint16_t chord_input = this->readInput(this->chord_input, CONVERT_TO_5_BIT); // 0 - 31
this->note_1_output->value = NOTES[CHROMATIC[(uint8_t) min((root_note_input + CHORDS[chord_input][0]),60)]];
this->note_2_output->value = NOTES[CHROMATIC[(uint8_t) min((root_note_input + CHORDS[chord_input][1]),60)]];
this->note_3_output->value = NOTES[CHROMATIC[(uint8_t) min((root_note_input + CHORDS[chord_input][2]),60)]];
return(this->note_3_output->value);
}