Created
May 14, 2020 16:24
-
-
Save pedrolcl/dd8a2e494365c55285107c96dc2ba57f to your computer and use it in GitHub Desktop.
Prints the key signature from the corresponding SMF meta-event values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
int main(int argc, char* argv[]) | |
{ | |
if (argc == 3) { | |
int sf = atoi(argv[1]); | |
int mi = atoi(argv[2]); | |
if (abs(sf) < 8 && mi < 2) { | |
char* maj[] = {"C flat", "G flat", "D flat", "A flat", "E flat", "B flat", | |
"F", "C", "G", "D", "A", "E", "B", "F sharp", "C sharp"}; | |
char* min[] = {"A flat", "E flat", "B flat", | |
"F", "C", "G", "D", "A", "E", "B", "F sharp", "C sharp", "G sharp", "D sharp", "A sharp"}; | |
printf ("sf=%d, m=%d => %s %s\n", sf, mi, mi == 0 ? maj[sf + 7] : min[sf + 7], mi == 0 ? "major" : "minor" ); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment