summaryrefslogtreecommitdiff
path: root/piano/pianoui.c
blob: 10da0b7fba8fadcfa2aeba47b1d37c960320f317 (plain)
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
enum TUNE{
    LOW=0, MEDIUM=(1<<3), HIGH=(2<<3)
};

int transkey(unsigned int index)
{
    int note, tune;

    note = index%7;
    index /= 7;
    switch(index){
    case 0:
        tune = HIGH;
        break;
    case 1:
        tune = MEDIUM;
        break;
    case 2:
        tune = LOW;
        break;
    default:
        return -1;
    }
    return note|tune;
}

int get_showcode(unsigned int note, int raise)
{
    int idx;
    if (note<=2){
        idx = note*2;
    }
    else{
        idx = note*2-1;
    }
    idx += raise;
    if (idx>=12){
        idx -= 12;
    }
    return idx+'a';
}