-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.c
54 lines (47 loc) · 1.13 KB
/
matrix.c
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
#include <stdio.h>
#include <stdlib.h>
// function that just keeps the note within range
int mod12(int note){
while (note >= 12) note -= 12;
while (note < 0) note += 12;
return note;
}
int main (int argc, char const *argv[])
{
int series[12][12], offset;
int n, m, i;
char* table[12] = {"C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"};
if(argc != 13)
{
printf("usage: %s note1 note2 ... note12\n", argv[0]);
return -1;
}
/* Loop until all available notes are entered */
for(n = 0; n < 12; ++n)
{
series[0][n] = mod12(atoi(argv[n+1]));
}
/* Create inversion in Column 1 */
for(m = 1; m < 12; ++m)
{
series[m][0] = mod12(series[m-1][0] + series[0][m-1] - series[0][m]);
}
/* Create all transpositions */
for(m = 1; m < 12; ++m)
{
for(n = 0; n < 12; ++n)
{
series[m][n] = mod12(series[0][n] + series[m][0] - series[0][0]);
}
}
for(m = 0; m < 12; ++m)
{
/*Print the pitch classes - row by row - using the translation table */
for(n = 0; n < 12; ++n)
{
printf(" %s ", table[series[m][n]]);
}
printf("\n");
}
return 0;
}