-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.cpp
More file actions
80 lines (76 loc) · 2.29 KB
/
notes.cpp
File metadata and controls
80 lines (76 loc) · 2.29 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
plexus - a launchpad cv/gate sequencer/keyboard/arpeggiator
Copyright (C) 2017 Dougall IRVING
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "notes.h"
byte transpose = 0;
byte scale = 0;
#define SCALE_COUNT 16
#define SCALE_LENGTH 7
//given matrix position, get the scale step
const byte matrix_to_scale_step[GRID_SIZE]=
{
3,4,5,6,0,1,2,3,
0,1,2,3,4,5,6,0,
3,4,5,6,0,1,2,3,
0,1,2,3,4,5,6,0,
3,4,5,6,0,1,2,3,
0,1,2,3,4,5,6,0,
3,4,5,6,0,1,2,3,
0,1,2,3,4,5,6,0
};
//given matrix position, get the octave
const byte matrix_to_octave[GRID_SIZE]=
{
3,3,3,3,4,4,4,4,
3,3,3,3,3,3,3,4,
2,2,2,2,3,3,3,3,
2,2,2,2,2,2,2,3,
1,1,1,1,2,2,2,2,
1,1,1,1,1,1,1,2,
0,0,0,0,1,1,1,1,
0,0,0,0,0,0,0,1
};
const byte scales [SCALE_COUNT][SCALE_LENGTH] =
{
//heptatonia Prima
{0,2,4,5,7,9,11}, //ionian
{0,2,3,5,7,9,10}, //dorian
{0,1,3,5,7,8,10}, //phyrgian
{0,2,4,6,7,9,11}, //lydian
{0,2,4,5,7,9,10}, //Mixolydian
{0,2,3,5,7,8,10}, // Aeolian
{0,1,3,5,6,8,10}, //Locrain
{0,2,3,5,7,8,11}, // Harmonic Minor
//heptatonia Secunda
{0,2,4,5,7,8,10}, // major minor scale
{0,2,3,5,7,9,11}, // Melodic Minor
{0,1,3,5,7,9,10}, // phyrgian raised 6th
{0,2,4,6,8,9,11}, // lydian raised 5th
{0,2,4,6,7,9,10}, // lydian dominant
{0,2,4,5,6,8,10}, //Locrain sharp 2 - half diminished
{0,1,3,4,6,8,10}, //Locrain diminished 4- altered
//others
{0,1,3,5,7,8,11} //neapolitan minor
};
//converts a matrix location to an actual midi note number
byte get_note_number( const byte button )
{
const byte scale_step = matrix_to_scale_step[button];
byte note = matrix_to_octave[button] * 12;
note += scales[scale][scale_step];
note += transpose;
while (note > 60)
note -= 12;
return note;
}