Introduction
Hark back to the days of text based adventure games, and simple PC, speaker sound.
Background
In an effort to learn C#, my first project was a text-based adventure game based on "The Hyperion Project" tutorial from XNA Extreme 101 (3D Buzz). Along the way, I added a considerable amount of code to further enhance the project -- one of which was the addition of sound.
I found several examples, some of which were quite good -- unfortunately, most were incomplete, contained incorrect frequencies, and/or lacked any examples.
Obviously, the PC Speaker holds very little relevance in this day-and-age -- nevertheless, I hope that this will be useful to someone out there.
Note Assignment
and Frequencies
The following represents the complete scale -- however, please be aware that many of the lower notes will be extremely quiet and/or completely inaudible.
In addition, the commented notes fall below the frequency range of the Beep method (which is between 37Hz and 32767Hz).
#region ▌Notes Assignment & Frequencies▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
int D1s = (int) 38.89; int E1 = (int) 41.20;
int F1 = (int) 43.65;
int F1s = (int) 46.25; int G1 = (int) 49.00;
int G1s = (int) 51.91; int A1 = (int) 55.00;
int A1s = (int) 58.27; int B1 = (int) 61.74;
int C2 = (int) 65.41;
int C2s = (int) 69.30; int D2 = (int) 73.42;
int D2s = (int) 77.78; int E2 = (int) 82.41;
int F2 = (int) 87.31;
int F2s = (int) 92.50; int G2 = (int) 98.00;
int G2s = (int) 103.83; int A2 = (int) 110.00;
int A2s = (int) 116.54; int B2 = (int) 123.47;
int C3 = (int) 130.81;
int C3s = (int) 138.59; int D3 = (int) 146.83;
int D3s = (int) 155.56; int E3 = (int) 164.81;
int F3 = (int) 174.61;
int F3s = (int) 185.00; int G3 = (int) 196.00;
int G3s = (int) 207.65; int A3 = (int) 220.00;
int A3s = (int) 233.08; int B3 = (int) 246.94;
int C4 = (int) 261.63; int C4s = (int) 277.18; int D4 = (int) 293.66;
int D4s = (int) 311.13; int E4 = (int) 329.63;
int F4 = (int) 349.23;
int F4s = (int) 369.99; int G4 = (int) 392.00;
int G4s = (int) 415.30; int A4 = (int) 440.00;
int A4s = (int) 466.16; int B4 = (int) 493.88;
int C5 = (int) 523.25;
int C5s = (int) 554.37; int D5 = (int) 587.33;
int D5s = (int) 622.25; int E5 = (int) 659.26;
int F5 = (int) 698.46;
int F5s = (int) 739.99; int G5 = (int) 783.99;
int G5s = (int) 830.61; int A5 = (int) 880.00;
int A5s = (int) 932.33; int B5 = (int) 987.77;
int C6 = (int) 1046.50;
int C6s = (int) 1108.73; int D6 = (int) 1174.66;
int D6s = (int) 1244.51; int E6 = (int) 1318.51;
int F6 = (int) 1396.91;
int F6s = (int) 1479.98; int G6 = (int) 1567.98;
int G6s = (int) 1661.22; int A6 = (int) 1760.00;
int A6s = (int) 1864.66; int B6 = (int) 1975.53;
int C7 = (int) 2093.00;
int C7s = (int) 2217.46; int D7 = (int) 2349.32;
int D7s = (int) 2489.02; int E7 = (int) 2637.02;
int F7 = (int) 2793.83;
int F7s = (int) 2959.96; int G7 = (int) 3135.96;
int G7s = (int) 3322.44; int A7 = (int) 3520.00;
int A7s = (int) 3729.31; int B7 = (int) 3951.07;
int C8 = (int) 4186.01;
int C8s = (int) 4434.92; int D8 = (int) 4698.64;
int D8s = (int) 4978.03; #endregion
Note Durations
#region ▌Note Durations▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
int longa = 4000; int ddble = 3000; int dble = 2000; int whol = 1000; int half = 500; int qrtr = 250; int eghth = 125; int sxtnth = (int) 62.50; int thr2nd = (int) 31.25; #endregion
Sample
The following is just one of the examples contained in the source code.
Here is my attempt at accurately recreating the Main Theme from the game Space Quest (originally created by Mark Crowe, (C) Sierra Online).
#region ▌Sample▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Thread.Sleep(500);
Console.Beep(C5 , 400);
Console.Beep(C5 , sxtnth);
Console.Beep(F5 , 600);
Console.Beep(G5 , half);
Console.Beep(A5 , half);
Console.Beep(D6 , 130);
Console.Beep(C6 , 120);
Console.Beep(A5s, 150);
Console.Beep(C6 , whol);
Thread.Sleep(600);
Console.Beep(D6 , 130);
Console.Beep(C6 , 120);
Console.Beep(A5s, qrtr);
Console.Beep(C6 , 550);
Console.Beep(A5s, half);
Console.Beep(A5 , half);
Console.Beep(A5 , 140);
Console.Beep(F5 , 120);
Console.Beep(A5 , qrtr);
Console.Beep(G5 , 1250);
Console.WriteLine(" - ─ -──┤ Press Any Key ├──- ─ -\n");
Console.ReadLine();
#endregion
Special thanks to ...
The Michigan Technological University (specifically their Physics Department) publication
on the Frequencies for equal-tempered scale.