-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScale.h
68 lines (46 loc) · 1.57 KB
/
Scale.h
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
#ifndef _scale_h_
#define _scale_h_
#define NOTENAME_LENGTH 4
#define CHROMATIC_LENGTH 11
#define CHROMATIC_INTERVALS {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
#include "Tones.h"
#ifndef _include_libs_arduino_
#define _include_libs_arduino_
#include <Arduino.h>
#endif;
class Scale {
private:
/* array of notes we can play - frequencies of the
the chromatic scale from B0 (31 Hz) to D#8 (4978 Hz) */
static uint32_t Notes[];
/* length of the Notes array */
static uint8_t Notes_length;
/* array of note names for the notes we can play */
static char NoteNames[][NOTENAME_LENGTH];
/* root note of the scale
position of the Notes array which is the
root note of this scale */
uint8_t root;
/* interval composition of the scale
1: half step 2: full step */
uint8_t intervals[CHROMATIC_LENGTH];
/* length of the intervals array
how many intervals is the scale composed of */
uint8_t intervals_length;
/* note composition of the scale - positions of the Notes array*/
/* max length of the scale is the length of the default chromatic scale */
uint8_t notes[NOTE_COUNT];
/* how many notes in the notes[] array of the scale */
uint8_t notes_length;
/* builds the note composition array for a scale object */
void build_scale();
public:
Scale();
Scale(uint8_t root_position, uint8_t intervals[], uint8_t length);
uint8_t length();
uint32_t note_frequency(uint8_t position);
char* note_name(uint8_t position);
/* prints to Serial debug information about this scale */
void print_debug();
};
#endif