DC> I was wondering if anyone knows of something someone may
DC> have already written that relates pc speaker tones (from
DC> dos.h) to musical notes?
Not much call for that, being specific to DOS and Borland.
I have something in C which you may find useful, however.
This is really a C question, since there is nothing related
to either the C++ extensions or OOD involved.
You should see if you can get C_ECHO as well.
#include
#include
enum { CN, CS, DF, DN, DS, EF, EN, FN,
FS, GF, GN, GS, AF, AN, AS, BF, BN };
int main(void)
{
int Key, octave = 0, loop, note[7][17];
int O6[17] = {
4161, 4419, 4419, 4681, 4997, 4997, 5249, 5587, 5953,
5953, 6273, 6657, 6735, 7055, 7488, 7488, 7883 };
for(Key = 0; Key < 17; Key++)
note[6][Key] = O6[Key];
for(loop = 5; loop >= 0; loop--)
for(Key = 0; Key < 17; Key++)
note[loop][Key] = (int)(note[loop + 1][Key] / 2);
textattr(7);
clrscr();
textattr(31);
cprintf("\n\n\n\n\n\n\n\n Use keys A-G for A-G Natural. \n\r");
cprintf(" SHIFT/ACDFG for Sharp notes. \n\r");
cprintf(" CTRL/ABDEG for Flat notes. \n\r");
cprintf(" F1 - F6 select octave. \n\r");
cprintf(" Down or Up one octave. \n\r");
cprintf(" Other keys turn sound off. \n\r");
cprintf(" Press [ESCAPE] to quit. \n\r");
while(Key != 27)
{
Key = ((Key = getch()) != 0) ? Key : -getch();
switch(Key)
{
case '<': octave--; if(octave < 1) octave = 0; break;
case '>': octave++; if(octave > 5) octave = 6; break;
case -59: octave = 0; break;
case -60: octave = 1; break;
case -61: octave = 2; break;
case -62: octave = 3; break;
case -63: octave = 4; break;
case -64: octave = 5; break;
case -65: octave = 6; break;
case 'a': sound(note[octave][AN]); break;
case 'b': sound(note[octave][BN]); break;
case 'c': sound(note[octave][CN]); break;
case 'd': sound(note[octave][DN]); break;
case 'e': sound(note[octave][EN]); break;
case 'f': sound(note[octave][FN]); break;
case 'g': sound(note[octave][GN]); break;
case 'A': sound(note[octave][AS]); break;
case 'B': break;
case 'C': sound(note[octave][CS]); break;
case 'D': sound(note[octave][DS]); break;
case 'E': break;
case 'F': sound(note[octave][FS]); break;
case 'G': sound(note[octave][GS]); break;
case 1: sound(note[octave][AF]); break;
case 2: sound(note[octave][BF]); break;
case 3: break;
case 4: sound(note[octave][DF]); break;
case 5: sound(note[octave][EF]); break;
case 6: break;
case 7: sound(note[octave][GF]); break;
default: nosound(); break;
}
}
return 0;
}
> ] God's side of the tire is Never Flat........................
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|