-
Notifications
You must be signed in to change notification settings - Fork 1
/
scales.cpp
46 lines (36 loc) · 1.03 KB
/
scales.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright (c) 2014 Auston Sterling
See LICENSE for copying permissions.
-----Scales Listing-----
Auston Sterling
Contains constants and functions to be able to easily use or reference scales.
*/
#ifndef _scales_cpp_
#define _scales_cpp_
#include "scales.hpp"
namespace midi
{
//Returns the note given as a number in the major scale based at the input key
Note majorScale(Note key, char num)
{
num--;
char minus = 2*(num/7)+((num%7>2)?1:0);
return key + num*2 - minus;
}
//Returns the note given as a number in the natural minor scale based at the input key
Note natMinorScale(Note key, char num)
{
num--;
char minus = 2*(num/7)+((num%7>1)?1:0)+((num%7>4)?1:0);
return key + num*2 - minus;
}
//Returns the note given as a number in the harmonic minor scale based at the key
Note harMinorScale(Note key, char num)
{
num--;
char minus = 2*(num/7)+((num%7>1)?1:0)+((num%7>4)?1:0)-((num%7>5)?1:0);
return key + num*2 - minus;
}
} //Namespace
#endif