HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue Jun 30, 2009 11:58 pm Post subject: Ionian Scales |
|
|
I was bored and haven't coded in like 3 months so i decided to wake up and code a small app. It calculates the frequencies of a major scale based on the formula
| Code: | | CalcFreq(hs, key) pow(1.059460646483, hs)*key |
Where hs is the halfsteps from A and key is the current scale (12 notes in the musical alphabet).
I might make a program that does all the modes (7 of them) and all the notes (12) just for kicks.
If you're into music theory like i am then you may find it interesting.
Well wtf i can't attach rars anymore. Fuck you cheat engine forums.
| Code: | #include <windows.h>
#include <cmath>
#include <stdio.h>
#define CalcFreq(hs, key) pow(1.059460646483, hs)*key
int main()
{
int major[8] = {0,2,4,5,7,9,10,12};
double key[12] = {110, 116.54, 123.47, 130.81, 138.59, 146.83, 155.56, 164.81, 174.61, 185, 196, 207.65};
printf("Starting Ionian (major) scales\n");
for(int k = 0; k<=11; k++)
{
printf("key[%i]\n", k+1);
for(int i = 0; i <=7; i++)
{
printf("Freq: %lf\n", CalcFreq(major[i], key[k]));
Beep(CalcFreq(major[i],key[k]),500);
}
for(int i = 7; i>=0; i--)
{
printf("Freq: %lf\n", CalcFreq(major[i], key[k]));
Beep(CalcFreq(major[i],key[k]),500);
}
for(int i = 0; i<=7; i+=2)
{
printf("Freq: %lf\n", CalcFreq(major[i], key[k]));
Beep(CalcFreq(major[i],key[k]),500);
}
printf("Freq: %lf\n", CalcFreq(major[7], key[k]));
Beep(CalcFreq(major[7],key[k]),500);
for(int i = 6; i>=0; i-=2)
{
printf("Freq: %lf\n", CalcFreq(major[i], key[k]));
Beep(CalcFreq(major[i],key[k]),500);
}
Sleep(500);
}
Sleep(10000);
return 0;
} |
It will run up the scale and play the tonic twice, then will play the chord with the tonic.
Compile that in VS and run. Should work in any compiler.
_________________
|
|