Breaking Eggs And Making Omelettes

Topics On Multimedia Technology and Reverse Engineering


Archives:

Sound Blaster Frequencies

December 19th, 2005 by Multimedia Mike

Remember when the original Creative Labs Sound Blaster was released? It was quite revolutionary for PC audio at the time since it was basically a stock AdLib FM synthesizer card and but with an 8-bit, monophonic digital to audio converter (DAC) that could output raw PCM data.


Classic Sound Blaster box

One of the more curious artifacts of the original Sound Blaster is the frequency divisor used to initialize the DAC for PCM playback.

The frequency divisor is a signed byte (range -128..127). If you Google for the formula to convert this to a frequency value you will find some conflicting formulas. I believe this is the true formula (formula #1):

  sample_rate = 256 - (1000000 / i)

Some sites contend that this is the right one (formula #2):

  sample_rate = (1000000) / (256 - divisor)

Here is some quick code that I wrote to compare the formulas.

#include <stdio.h>

int main()
{
    int i;

    for (i = -128; i < 128; i++) {
        if (!i)  /* refrain from dividing by zero */
            continue;
        printf ("divisor %4d (%02X), formula #1 = %d Hz, #2 = %d Hz\n",
            i, (i & 0xFF),
            256 - (1000000 / i),
            1000000 / (256 - i));
    }

    return 0;
}

The first formula progresses from 8068 Hz -> 1000256 Hz as the divisor runs from -128 -> -1. 0 is an invalid divisor (division by zero). The frequencies go negative when the divisor is positive. With the second formula, on the other hand, the frequency runs from 2604 Hz -> 7751 Hz as the divisor runs from -128 -> 127.

Further, when I examine my .VOC demuxer in the xine library I find that I used the first formula and it seems to work. The VOC format was originated by Creative and is closely tied to the original Sound Blaster. So much so that it stores the Sound Blaster frequency divisor.

Here is the full output from the above program:

divisor -128 (80), formula #1 = 8068 Hz, #2 = 2604 Hz
divisor -127 (81), formula #1 = 8130 Hz, #2 = 2610 Hz
divisor -126 (82), formula #1 = 8192 Hz, #2 = 2617 Hz
divisor -125 (83), formula #1 = 8256 Hz, #2 = 2624 Hz
divisor -124 (84), formula #1 = 8320 Hz, #2 = 2631 Hz
divisor -123 (85), formula #1 = 8386 Hz, #2 = 2638 Hz
divisor -122 (86), formula #1 = 8452 Hz, #2 = 2645 Hz
divisor -121 (87), formula #1 = 8520 Hz, #2 = 2652 Hz
divisor -120 (88), formula #1 = 8589 Hz, #2 = 2659 Hz
divisor -119 (89), formula #1 = 8659 Hz, #2 = 2666 Hz
divisor -118 (8A), formula #1 = 8730 Hz, #2 = 2673 Hz
divisor -117 (8B), formula #1 = 8803 Hz, #2 = 2680 Hz
divisor -116 (8C), formula #1 = 8876 Hz, #2 = 2688 Hz
divisor -115 (8D), formula #1 = 8951 Hz, #2 = 2695 Hz
divisor -114 (8E), formula #1 = 9027 Hz, #2 = 2702 Hz
divisor -113 (8F), formula #1 = 9105 Hz, #2 = 2710 Hz
divisor -112 (90), formula #1 = 9184 Hz, #2 = 2717 Hz
divisor -111 (91), formula #1 = 9265 Hz, #2 = 2724 Hz
divisor -110 (92), formula #1 = 9346 Hz, #2 = 2732 Hz
divisor -109 (93), formula #1 = 9430 Hz, #2 = 2739 Hz
divisor -108 (94), formula #1 = 9515 Hz, #2 = 2747 Hz
divisor -107 (95), formula #1 = 9601 Hz, #2 = 2754 Hz
divisor -106 (96), formula #1 = 9689 Hz, #2 = 2762 Hz
divisor -105 (97), formula #1 = 9779 Hz, #2 = 2770 Hz
divisor -104 (98), formula #1 = 9871 Hz, #2 = 2777 Hz
divisor -103 (99), formula #1 = 9964 Hz, #2 = 2785 Hz
divisor -102 (9A), formula #1 = 10059 Hz, #2 = 2793 Hz
divisor -101 (9B), formula #1 = 10156 Hz, #2 = 2801 Hz
divisor -100 (9C), formula #1 = 10256 Hz, #2 = 2808 Hz
divisor  -99 (9D), formula #1 = 10357 Hz, #2 = 2816 Hz
divisor  -98 (9E), formula #1 = 10460 Hz, #2 = 2824 Hz
divisor  -97 (9F), formula #1 = 10565 Hz, #2 = 2832 Hz
divisor  -96 (A0), formula #1 = 10672 Hz, #2 = 2840 Hz
divisor  -95 (A1), formula #1 = 10782 Hz, #2 = 2849 Hz
divisor  -94 (A2), formula #1 = 10894 Hz, #2 = 2857 Hz
divisor  -93 (A3), formula #1 = 11008 Hz, #2 = 2865 Hz
divisor  -92 (A4), formula #1 = 11125 Hz, #2 = 2873 Hz
divisor  -91 (A5), formula #1 = 11245 Hz, #2 = 2881 Hz
divisor  -90 (A6), formula #1 = 11367 Hz, #2 = 2890 Hz
divisor  -89 (A7), formula #1 = 11491 Hz, #2 = 2898 Hz
divisor  -88 (A8), formula #1 = 11619 Hz, #2 = 2906 Hz
divisor  -87 (A9), formula #1 = 11750 Hz, #2 = 2915 Hz
divisor  -86 (AA), formula #1 = 11883 Hz, #2 = 2923 Hz
divisor  -85 (AB), formula #1 = 12020 Hz, #2 = 2932 Hz
divisor  -84 (AC), formula #1 = 12160 Hz, #2 = 2941 Hz
divisor  -83 (AD), formula #1 = 12304 Hz, #2 = 2949 Hz
divisor  -82 (AE), formula #1 = 12451 Hz, #2 = 2958 Hz
divisor  -81 (AF), formula #1 = 12601 Hz, #2 = 2967 Hz
divisor  -80 (B0), formula #1 = 12756 Hz, #2 = 2976 Hz
divisor  -79 (B1), formula #1 = 12914 Hz, #2 = 2985 Hz
divisor  -78 (B2), formula #1 = 13076 Hz, #2 = 2994 Hz
divisor  -77 (B3), formula #1 = 13243 Hz, #2 = 3003 Hz
divisor  -76 (B4), formula #1 = 13413 Hz, #2 = 3012 Hz
divisor  -75 (B5), formula #1 = 13589 Hz, #2 = 3021 Hz
divisor  -74 (B6), formula #1 = 13769 Hz, #2 = 3030 Hz
divisor  -73 (B7), formula #1 = 13954 Hz, #2 = 3039 Hz
divisor  -72 (B8), formula #1 = 14144 Hz, #2 = 3048 Hz
divisor  -71 (B9), formula #1 = 14340 Hz, #2 = 3058 Hz
divisor  -70 (BA), formula #1 = 14541 Hz, #2 = 3067 Hz
divisor  -69 (BB), formula #1 = 14748 Hz, #2 = 3076 Hz
divisor  -68 (BC), formula #1 = 14961 Hz, #2 = 3086 Hz
divisor  -67 (BD), formula #1 = 15181 Hz, #2 = 3095 Hz
divisor  -66 (BE), formula #1 = 15407 Hz, #2 = 3105 Hz
divisor  -65 (BF), formula #1 = 15640 Hz, #2 = 3115 Hz
divisor  -64 (C0), formula #1 = 15881 Hz, #2 = 3125 Hz
divisor  -63 (C1), formula #1 = 16129 Hz, #2 = 3134 Hz
divisor  -62 (C2), formula #1 = 16385 Hz, #2 = 3144 Hz
divisor  -61 (C3), formula #1 = 16649 Hz, #2 = 3154 Hz
divisor  -60 (C4), formula #1 = 16922 Hz, #2 = 3164 Hz
divisor  -59 (C5), formula #1 = 17205 Hz, #2 = 3174 Hz
divisor  -58 (C6), formula #1 = 17497 Hz, #2 = 3184 Hz
divisor  -57 (C7), formula #1 = 17799 Hz, #2 = 3194 Hz
divisor  -56 (C8), formula #1 = 18113 Hz, #2 = 3205 Hz
divisor  -55 (C9), formula #1 = 18437 Hz, #2 = 3215 Hz
divisor  -54 (CA), formula #1 = 18774 Hz, #2 = 3225 Hz
divisor  -53 (CB), formula #1 = 19123 Hz, #2 = 3236 Hz
divisor  -52 (CC), formula #1 = 19486 Hz, #2 = 3246 Hz
divisor  -51 (CD), formula #1 = 19863 Hz, #2 = 3257 Hz
divisor  -50 (CE), formula #1 = 20256 Hz, #2 = 3267 Hz
divisor  -49 (CF), formula #1 = 20664 Hz, #2 = 3278 Hz
divisor  -48 (D0), formula #1 = 21089 Hz, #2 = 3289 Hz
divisor  -47 (D1), formula #1 = 21532 Hz, #2 = 3300 Hz
divisor  -46 (D2), formula #1 = 21995 Hz, #2 = 3311 Hz
divisor  -45 (D3), formula #1 = 22478 Hz, #2 = 3322 Hz
divisor  -44 (D4), formula #1 = 22983 Hz, #2 = 3333 Hz
divisor  -43 (D5), formula #1 = 23511 Hz, #2 = 3344 Hz
divisor  -42 (D6), formula #1 = 24065 Hz, #2 = 3355 Hz
divisor  -41 (D7), formula #1 = 24646 Hz, #2 = 3367 Hz
divisor  -40 (D8), formula #1 = 25256 Hz, #2 = 3378 Hz
divisor  -39 (D9), formula #1 = 25897 Hz, #2 = 3389 Hz
divisor  -38 (DA), formula #1 = 26571 Hz, #2 = 3401 Hz
divisor  -37 (DB), formula #1 = 27283 Hz, #2 = 3412 Hz
divisor  -36 (DC), formula #1 = 28033 Hz, #2 = 3424 Hz
divisor  -35 (DD), formula #1 = 28827 Hz, #2 = 3436 Hz
divisor  -34 (DE), formula #1 = 29667 Hz, #2 = 3448 Hz
divisor  -33 (DF), formula #1 = 30559 Hz, #2 = 3460 Hz
divisor  -32 (E0), formula #1 = 31506 Hz, #2 = 3472 Hz
divisor  -31 (E1), formula #1 = 32514 Hz, #2 = 3484 Hz
divisor  -30 (E2), formula #1 = 33589 Hz, #2 = 3496 Hz
divisor  -29 (E3), formula #1 = 34738 Hz, #2 = 3508 Hz
divisor  -28 (E4), formula #1 = 35970 Hz, #2 = 3521 Hz
divisor  -27 (E5), formula #1 = 37293 Hz, #2 = 3533 Hz
divisor  -26 (E6), formula #1 = 38717 Hz, #2 = 3546 Hz
divisor  -25 (E7), formula #1 = 40256 Hz, #2 = 3558 Hz
divisor  -24 (E8), formula #1 = 41922 Hz, #2 = 3571 Hz
divisor  -23 (E9), formula #1 = 43734 Hz, #2 = 3584 Hz
divisor  -22 (EA), formula #1 = 45710 Hz, #2 = 3597 Hz
divisor  -21 (EB), formula #1 = 47875 Hz, #2 = 3610 Hz
divisor  -20 (EC), formula #1 = 50256 Hz, #2 = 3623 Hz
divisor  -19 (ED), formula #1 = 52887 Hz, #2 = 3636 Hz
divisor  -18 (EE), formula #1 = 55811 Hz, #2 = 3649 Hz
divisor  -17 (EF), formula #1 = 59079 Hz, #2 = 3663 Hz
divisor  -16 (F0), formula #1 = 62756 Hz, #2 = 3676 Hz
divisor  -15 (F1), formula #1 = 66922 Hz, #2 = 3690 Hz
divisor  -14 (F2), formula #1 = 71684 Hz, #2 = 3703 Hz
divisor  -13 (F3), formula #1 = 77179 Hz, #2 = 3717 Hz
divisor  -12 (F4), formula #1 = 83589 Hz, #2 = 3731 Hz
divisor  -11 (F5), formula #1 = 91165 Hz, #2 = 3745 Hz
divisor  -10 (F6), formula #1 = 100256 Hz, #2 = 3759 Hz
divisor   -9 (F7), formula #1 = 111367 Hz, #2 = 3773 Hz
divisor   -8 (F8), formula #1 = 125256 Hz, #2 = 3787 Hz
divisor   -7 (F9), formula #1 = 143113 Hz, #2 = 3802 Hz
divisor   -6 (FA), formula #1 = 166922 Hz, #2 = 3816 Hz
divisor   -5 (FB), formula #1 = 200256 Hz, #2 = 3831 Hz
divisor   -4 (FC), formula #1 = 250256 Hz, #2 = 3846 Hz
divisor   -3 (FD), formula #1 = 333589 Hz, #2 = 3861 Hz
divisor   -2 (FE), formula #1 = 500256 Hz, #2 = 3875 Hz
divisor   -1 (FF), formula #1 = 1000256 Hz, #2 = 3891 Hz
divisor    1 (01), formula #1 = -999744 Hz, #2 = 3921 Hz
divisor    2 (02), formula #1 = -499744 Hz, #2 = 3937 Hz
divisor    3 (03), formula #1 = -333077 Hz, #2 = 3952 Hz
divisor    4 (04), formula #1 = -249744 Hz, #2 = 3968 Hz
divisor    5 (05), formula #1 = -199744 Hz, #2 = 3984 Hz
divisor    6 (06), formula #1 = -166410 Hz, #2 = 4000 Hz
divisor    7 (07), formula #1 = -142601 Hz, #2 = 4016 Hz
divisor    8 (08), formula #1 = -124744 Hz, #2 = 4032 Hz
divisor    9 (09), formula #1 = -110855 Hz, #2 = 4048 Hz
divisor   10 (0A), formula #1 = -99744 Hz, #2 = 4065 Hz
divisor   11 (0B), formula #1 = -90653 Hz, #2 = 4081 Hz
divisor   12 (0C), formula #1 = -83077 Hz, #2 = 4098 Hz
divisor   13 (0D), formula #1 = -76667 Hz, #2 = 4115 Hz
divisor   14 (0E), formula #1 = -71172 Hz, #2 = 4132 Hz
divisor   15 (0F), formula #1 = -66410 Hz, #2 = 4149 Hz
divisor   16 (10), formula #1 = -62244 Hz, #2 = 4166 Hz
divisor   17 (11), formula #1 = -58567 Hz, #2 = 4184 Hz
divisor   18 (12), formula #1 = -55299 Hz, #2 = 4201 Hz
divisor   19 (13), formula #1 = -52375 Hz, #2 = 4219 Hz
divisor   20 (14), formula #1 = -49744 Hz, #2 = 4237 Hz
divisor   21 (15), formula #1 = -47363 Hz, #2 = 4255 Hz
divisor   22 (16), formula #1 = -45198 Hz, #2 = 4273 Hz
divisor   23 (17), formula #1 = -43222 Hz, #2 = 4291 Hz
divisor   24 (18), formula #1 = -41410 Hz, #2 = 4310 Hz
divisor   25 (19), formula #1 = -39744 Hz, #2 = 4329 Hz
divisor   26 (1A), formula #1 = -38205 Hz, #2 = 4347 Hz
divisor   27 (1B), formula #1 = -36781 Hz, #2 = 4366 Hz
divisor   28 (1C), formula #1 = -35458 Hz, #2 = 4385 Hz
divisor   29 (1D), formula #1 = -34226 Hz, #2 = 4405 Hz
divisor   30 (1E), formula #1 = -33077 Hz, #2 = 4424 Hz
divisor   31 (1F), formula #1 = -32002 Hz, #2 = 4444 Hz
divisor   32 (20), formula #1 = -30994 Hz, #2 = 4464 Hz
divisor   33 (21), formula #1 = -30047 Hz, #2 = 4484 Hz
divisor   34 (22), formula #1 = -29155 Hz, #2 = 4504 Hz
divisor   35 (23), formula #1 = -28315 Hz, #2 = 4524 Hz
divisor   36 (24), formula #1 = -27521 Hz, #2 = 4545 Hz
divisor   37 (25), formula #1 = -26771 Hz, #2 = 4566 Hz
divisor   38 (26), formula #1 = -26059 Hz, #2 = 4587 Hz
divisor   39 (27), formula #1 = -25385 Hz, #2 = 4608 Hz
divisor   40 (28), formula #1 = -24744 Hz, #2 = 4629 Hz
divisor   41 (29), formula #1 = -24134 Hz, #2 = 4651 Hz
divisor   42 (2A), formula #1 = -23553 Hz, #2 = 4672 Hz
divisor   43 (2B), formula #1 = -22999 Hz, #2 = 4694 Hz
divisor   44 (2C), formula #1 = -22471 Hz, #2 = 4716 Hz
divisor   45 (2D), formula #1 = -21966 Hz, #2 = 4739 Hz
divisor   46 (2E), formula #1 = -21483 Hz, #2 = 4761 Hz
divisor   47 (2F), formula #1 = -21020 Hz, #2 = 4784 Hz
divisor   48 (30), formula #1 = -20577 Hz, #2 = 4807 Hz
divisor   49 (31), formula #1 = -20152 Hz, #2 = 4830 Hz
divisor   50 (32), formula #1 = -19744 Hz, #2 = 4854 Hz
divisor   51 (33), formula #1 = -19351 Hz, #2 = 4878 Hz
divisor   52 (34), formula #1 = -18974 Hz, #2 = 4901 Hz
divisor   53 (35), formula #1 = -18611 Hz, #2 = 4926 Hz
divisor   54 (36), formula #1 = -18262 Hz, #2 = 4950 Hz
divisor   55 (37), formula #1 = -17925 Hz, #2 = 4975 Hz
divisor   56 (38), formula #1 = -17601 Hz, #2 = 5000 Hz
divisor   57 (39), formula #1 = -17287 Hz, #2 = 5025 Hz
divisor   58 (3A), formula #1 = -16985 Hz, #2 = 5050 Hz
divisor   59 (3B), formula #1 = -16693 Hz, #2 = 5076 Hz
divisor   60 (3C), formula #1 = -16410 Hz, #2 = 5102 Hz
divisor   61 (3D), formula #1 = -16137 Hz, #2 = 5128 Hz
divisor   62 (3E), formula #1 = -15873 Hz, #2 = 5154 Hz
divisor   63 (3F), formula #1 = -15617 Hz, #2 = 5181 Hz
divisor   64 (40), formula #1 = -15369 Hz, #2 = 5208 Hz
divisor   65 (41), formula #1 = -15128 Hz, #2 = 5235 Hz
divisor   66 (42), formula #1 = -14895 Hz, #2 = 5263 Hz
divisor   67 (43), formula #1 = -14669 Hz, #2 = 5291 Hz
divisor   68 (44), formula #1 = -14449 Hz, #2 = 5319 Hz
divisor   69 (45), formula #1 = -14236 Hz, #2 = 5347 Hz
divisor   70 (46), formula #1 = -14029 Hz, #2 = 5376 Hz
divisor   71 (47), formula #1 = -13828 Hz, #2 = 5405 Hz
divisor   72 (48), formula #1 = -13632 Hz, #2 = 5434 Hz
divisor   73 (49), formula #1 = -13442 Hz, #2 = 5464 Hz
divisor   74 (4A), formula #1 = -13257 Hz, #2 = 5494 Hz
divisor   75 (4B), formula #1 = -13077 Hz, #2 = 5524 Hz
divisor   76 (4C), formula #1 = -12901 Hz, #2 = 5555 Hz
divisor   77 (4D), formula #1 = -12731 Hz, #2 = 5586 Hz
divisor   78 (4E), formula #1 = -12564 Hz, #2 = 5617 Hz
divisor   79 (4F), formula #1 = -12402 Hz, #2 = 5649 Hz
divisor   80 (50), formula #1 = -12244 Hz, #2 = 5681 Hz
divisor   81 (51), formula #1 = -12089 Hz, #2 = 5714 Hz
divisor   82 (52), formula #1 = -11939 Hz, #2 = 5747 Hz
divisor   83 (53), formula #1 = -11792 Hz, #2 = 5780 Hz
divisor   84 (54), formula #1 = -11648 Hz, #2 = 5813 Hz
divisor   85 (55), formula #1 = -11508 Hz, #2 = 5847 Hz
divisor   86 (56), formula #1 = -11371 Hz, #2 = 5882 Hz
divisor   87 (57), formula #1 = -11238 Hz, #2 = 5917 Hz
divisor   88 (58), formula #1 = -11107 Hz, #2 = 5952 Hz
divisor   89 (59), formula #1 = -10979 Hz, #2 = 5988 Hz
divisor   90 (5A), formula #1 = -10855 Hz, #2 = 6024 Hz
divisor   91 (5B), formula #1 = -10733 Hz, #2 = 6060 Hz
divisor   92 (5C), formula #1 = -10613 Hz, #2 = 6097 Hz
divisor   93 (5D), formula #1 = -10496 Hz, #2 = 6134 Hz
divisor   94 (5E), formula #1 = -10382 Hz, #2 = 6172 Hz
divisor   95 (5F), formula #1 = -10270 Hz, #2 = 6211 Hz
divisor   96 (60), formula #1 = -10160 Hz, #2 = 6250 Hz
divisor   97 (61), formula #1 = -10053 Hz, #2 = 6289 Hz
divisor   98 (62), formula #1 = -9948 Hz, #2 = 6329 Hz
divisor   99 (63), formula #1 = -9845 Hz, #2 = 6369 Hz
divisor  100 (64), formula #1 = -9744 Hz, #2 = 6410 Hz
divisor  101 (65), formula #1 = -9644 Hz, #2 = 6451 Hz
divisor  102 (66), formula #1 = -9547 Hz, #2 = 6493 Hz
divisor  103 (67), formula #1 = -9452 Hz, #2 = 6535 Hz
divisor  104 (68), formula #1 = -9359 Hz, #2 = 6578 Hz
divisor  105 (69), formula #1 = -9267 Hz, #2 = 6622 Hz
divisor  106 (6A), formula #1 = -9177 Hz, #2 = 6666 Hz
divisor  107 (6B), formula #1 = -9089 Hz, #2 = 6711 Hz
divisor  108 (6C), formula #1 = -9003 Hz, #2 = 6756 Hz
divisor  109 (6D), formula #1 = -8918 Hz, #2 = 6802 Hz
divisor  110 (6E), formula #1 = -8834 Hz, #2 = 6849 Hz
divisor  111 (6F), formula #1 = -8753 Hz, #2 = 6896 Hz
divisor  112 (70), formula #1 = -8672 Hz, #2 = 6944 Hz
divisor  113 (71), formula #1 = -8593 Hz, #2 = 6993 Hz
divisor  114 (72), formula #1 = -8515 Hz, #2 = 7042 Hz
divisor  115 (73), formula #1 = -8439 Hz, #2 = 7092 Hz
divisor  116 (74), formula #1 = -8364 Hz, #2 = 7142 Hz
divisor  117 (75), formula #1 = -8291 Hz, #2 = 7194 Hz
divisor  118 (76), formula #1 = -8218 Hz, #2 = 7246 Hz
divisor  119 (77), formula #1 = -8147 Hz, #2 = 7299 Hz
divisor  120 (78), formula #1 = -8077 Hz, #2 = 7352 Hz
divisor  121 (79), formula #1 = -8008 Hz, #2 = 7407 Hz
divisor  122 (7A), formula #1 = -7940 Hz, #2 = 7462 Hz
divisor  123 (7B), formula #1 = -7874 Hz, #2 = 7518 Hz
divisor  124 (7C), formula #1 = -7808 Hz, #2 = 7575 Hz
divisor  125 (7D), formula #1 = -7744 Hz, #2 = 7633 Hz
divisor  126 (7E), formula #1 = -7680 Hz, #2 = 7692 Hz
divisor  127 (7F), formula #1 = -7618 Hz, #2 = 7751 Hz

Posted in General | 4 Comments »

4 Responses

  1. Jim Leonard Says:

    My sound blaster library has the following:

    256-(1000000 DIV (LONGINT(hz)))

    …which has always worked for me. (DIV is integer division; remainder is discarded.)

    I have *no* idea where you found the second formula but it’s obviously incorrect :-)

  2. Andux Says:

    Clarification:

    Divisor = 256 – (1000000 DIV SampleRate)
    SampleRate = 1000000 / (256 – Divisor)

    Not sure that the divisor should be treated as a signed byte.

  3. Multimedia Mike Says:

    I still must maintain that my divisor -> sample rate formula is correct, including the signed byte. This is based on the fact that my xine-lib .VOC demuxer plays audio correctly. If I use a different formula then the audio sounds like whale songs. :)

  4. Jim Leonard Says:

    Okay, I’ve re-verified my own code with my own actual Sound Blaster card… don’t use signed integers. Here is some code:

    program sbrates;
    var
    f:text;
    hz:longint;
    divisor:byte;
    begin
    assign(f,’output.txt’);
    rewrite(f);
    for divisor:=0 to 255 do
    writeln(f,’Divisor ‘,divisor,’ produces ‘,
    1000000 div (256-divisor),’Hz sample rate.’);
    writeln(f,’All sample rates above 45454Hz are not actually supported by the hardware.’);
    close(f);
    end.

    …and here is the output. Notice the correct “wacky” rates the Sound Blaster is known for, such as 45454Hz and 22222Hz:

    Divisor 0 produces 3906Hz sample rate.
    Divisor 1 produces 3921Hz sample rate.
    Divisor 2 produces 3937Hz sample rate.
    Divisor 3 produces 3952Hz sample rate.
    Divisor 4 produces 3968Hz sample rate.
    Divisor 5 produces 3984Hz sample rate.
    Divisor 6 produces 4000Hz sample rate.
    Divisor 7 produces 4016Hz sample rate.
    Divisor 8 produces 4032Hz sample rate.
    Divisor 9 produces 4048Hz sample rate.
    Divisor 10 produces 4065Hz sample rate.
    Divisor 11 produces 4081Hz sample rate.
    Divisor 12 produces 4098Hz sample rate.
    Divisor 13 produces 4115Hz sample rate.
    Divisor 14 produces 4132Hz sample rate.
    Divisor 15 produces 4149Hz sample rate.
    Divisor 16 produces 4166Hz sample rate.
    Divisor 17 produces 4184Hz sample rate.
    Divisor 18 produces 4201Hz sample rate.
    Divisor 19 produces 4219Hz sample rate.
    Divisor 20 produces 4237Hz sample rate.
    Divisor 21 produces 4255Hz sample rate.
    Divisor 22 produces 4273Hz sample rate.
    Divisor 23 produces 4291Hz sample rate.
    Divisor 24 produces 4310Hz sample rate.
    Divisor 25 produces 4329Hz sample rate.
    Divisor 26 produces 4347Hz sample rate.
    Divisor 27 produces 4366Hz sample rate.
    Divisor 28 produces 4385Hz sample rate.
    Divisor 29 produces 4405Hz sample rate.
    Divisor 30 produces 4424Hz sample rate.
    Divisor 31 produces 4444Hz sample rate.
    Divisor 32 produces 4464Hz sample rate.
    Divisor 33 produces 4484Hz sample rate.
    Divisor 34 produces 4504Hz sample rate.
    Divisor 35 produces 4524Hz sample rate.
    Divisor 36 produces 4545Hz sample rate.
    Divisor 37 produces 4566Hz sample rate.
    Divisor 38 produces 4587Hz sample rate.
    Divisor 39 produces 4608Hz sample rate.
    Divisor 40 produces 4629Hz sample rate.
    Divisor 41 produces 4651Hz sample rate.
    Divisor 42 produces 4672Hz sample rate.
    Divisor 43 produces 4694Hz sample rate.
    Divisor 44 produces 4716Hz sample rate.
    Divisor 45 produces 4739Hz sample rate.
    Divisor 46 produces 4761Hz sample rate.
    Divisor 47 produces 4784Hz sample rate.
    Divisor 48 produces 4807Hz sample rate.
    Divisor 49 produces 4830Hz sample rate.
    Divisor 50 produces 4854Hz sample rate.
    Divisor 51 produces 4878Hz sample rate.
    Divisor 52 produces 4901Hz sample rate.
    Divisor 53 produces 4926Hz sample rate.
    Divisor 54 produces 4950Hz sample rate.
    Divisor 55 produces 4975Hz sample rate.
    Divisor 56 produces 5000Hz sample rate.
    Divisor 57 produces 5025Hz sample rate.
    Divisor 58 produces 5050Hz sample rate.
    Divisor 59 produces 5076Hz sample rate.
    Divisor 60 produces 5102Hz sample rate.
    Divisor 61 produces 5128Hz sample rate.
    Divisor 62 produces 5154Hz sample rate.
    Divisor 63 produces 5181Hz sample rate.
    Divisor 64 produces 5208Hz sample rate.
    Divisor 65 produces 5235Hz sample rate.
    Divisor 66 produces 5263Hz sample rate.
    Divisor 67 produces 5291Hz sample rate.
    Divisor 68 produces 5319Hz sample rate.
    Divisor 69 produces 5347Hz sample rate.
    Divisor 70 produces 5376Hz sample rate.
    Divisor 71 produces 5405Hz sample rate.
    Divisor 72 produces 5434Hz sample rate.
    Divisor 73 produces 5464Hz sample rate.
    Divisor 74 produces 5494Hz sample rate.
    Divisor 75 produces 5524Hz sample rate.
    Divisor 76 produces 5555Hz sample rate.
    Divisor 77 produces 5586Hz sample rate.
    Divisor 78 produces 5617Hz sample rate.
    Divisor 79 produces 5649Hz sample rate.
    Divisor 80 produces 5681Hz sample rate.
    Divisor 81 produces 5714Hz sample rate.
    Divisor 82 produces 5747Hz sample rate.
    Divisor 83 produces 5780Hz sample rate.
    Divisor 84 produces 5813Hz sample rate.
    Divisor 85 produces 5847Hz sample rate.
    Divisor 86 produces 5882Hz sample rate.
    Divisor 87 produces 5917Hz sample rate.
    Divisor 88 produces 5952Hz sample rate.
    Divisor 89 produces 5988Hz sample rate.
    Divisor 90 produces 6024Hz sample rate.
    Divisor 91 produces 6060Hz sample rate.
    Divisor 92 produces 6097Hz sample rate.
    Divisor 93 produces 6134Hz sample rate.
    Divisor 94 produces 6172Hz sample rate.
    Divisor 95 produces 6211Hz sample rate.
    Divisor 96 produces 6250Hz sample rate.
    Divisor 97 produces 6289Hz sample rate.
    Divisor 98 produces 6329Hz sample rate.
    Divisor 99 produces 6369Hz sample rate.
    Divisor 100 produces 6410Hz sample rate.
    Divisor 101 produces 6451Hz sample rate.
    Divisor 102 produces 6493Hz sample rate.
    Divisor 103 produces 6535Hz sample rate.
    Divisor 104 produces 6578Hz sample rate.
    Divisor 105 produces 6622Hz sample rate.
    Divisor 106 produces 6666Hz sample rate.
    Divisor 107 produces 6711Hz sample rate.
    Divisor 108 produces 6756Hz sample rate.
    Divisor 109 produces 6802Hz sample rate.
    Divisor 110 produces 6849Hz sample rate.
    Divisor 111 produces 6896Hz sample rate.
    Divisor 112 produces 6944Hz sample rate.
    Divisor 113 produces 6993Hz sample rate.
    Divisor 114 produces 7042Hz sample rate.
    Divisor 115 produces 7092Hz sample rate.
    Divisor 116 produces 7142Hz sample rate.
    Divisor 117 produces 7194Hz sample rate.
    Divisor 118 produces 7246Hz sample rate.
    Divisor 119 produces 7299Hz sample rate.
    Divisor 120 produces 7352Hz sample rate.
    Divisor 121 produces 7407Hz sample rate.
    Divisor 122 produces 7462Hz sample rate.
    Divisor 123 produces 7518Hz sample rate.
    Divisor 124 produces 7575Hz sample rate.
    Divisor 125 produces 7633Hz sample rate.
    Divisor 126 produces 7692Hz sample rate.
    Divisor 127 produces 7751Hz sample rate.
    Divisor 128 produces 7812Hz sample rate.
    Divisor 129 produces 7874Hz sample rate.
    Divisor 130 produces 7936Hz sample rate.
    Divisor 131 produces 8000Hz sample rate.
    Divisor 132 produces 8064Hz sample rate.
    Divisor 133 produces 8130Hz sample rate.
    Divisor 134 produces 8196Hz sample rate.
    Divisor 135 produces 8264Hz sample rate.
    Divisor 136 produces 8333Hz sample rate.
    Divisor 137 produces 8403Hz sample rate.
    Divisor 138 produces 8474Hz sample rate.
    Divisor 139 produces 8547Hz sample rate.
    Divisor 140 produces 8620Hz sample rate.
    Divisor 141 produces 8695Hz sample rate.
    Divisor 142 produces 8771Hz sample rate.
    Divisor 143 produces 8849Hz sample rate.
    Divisor 144 produces 8928Hz sample rate.
    Divisor 145 produces 9009Hz sample rate.
    Divisor 146 produces 9090Hz sample rate.
    Divisor 147 produces 9174Hz sample rate.
    Divisor 148 produces 9259Hz sample rate.
    Divisor 149 produces 9345Hz sample rate.
    Divisor 150 produces 9433Hz sample rate.
    Divisor 151 produces 9523Hz sample rate.
    Divisor 152 produces 9615Hz sample rate.
    Divisor 153 produces 9708Hz sample rate.
    Divisor 154 produces 9803Hz sample rate.
    Divisor 155 produces 9900Hz sample rate.
    Divisor 156 produces 10000Hz sample rate.
    Divisor 157 produces 10101Hz sample rate.
    Divisor 158 produces 10204Hz sample rate.
    Divisor 159 produces 10309Hz sample rate.
    Divisor 160 produces 10416Hz sample rate.
    Divisor 161 produces 10526Hz sample rate.
    Divisor 162 produces 10638Hz sample rate.
    Divisor 163 produces 10752Hz sample rate.
    Divisor 164 produces 10869Hz sample rate.
    Divisor 165 produces 10989Hz sample rate.
    Divisor 166 produces 11111Hz sample rate.
    Divisor 167 produces 11235Hz sample rate.
    Divisor 168 produces 11363Hz sample rate.
    Divisor 169 produces 11494Hz sample rate.
    Divisor 170 produces 11627Hz sample rate.
    Divisor 171 produces 11764Hz sample rate.
    Divisor 172 produces 11904Hz sample rate.
    Divisor 173 produces 12048Hz sample rate.
    Divisor 174 produces 12195Hz sample rate.
    Divisor 175 produces 12345Hz sample rate.
    Divisor 176 produces 12500Hz sample rate.
    Divisor 177 produces 12658Hz sample rate.
    Divisor 178 produces 12820Hz sample rate.
    Divisor 179 produces 12987Hz sample rate.
    Divisor 180 produces 13157Hz sample rate.
    Divisor 181 produces 13333Hz sample rate.
    Divisor 182 produces 13513Hz sample rate.
    Divisor 183 produces 13698Hz sample rate.
    Divisor 184 produces 13888Hz sample rate.
    Divisor 185 produces 14084Hz sample rate.
    Divisor 186 produces 14285Hz sample rate.
    Divisor 187 produces 14492Hz sample rate.
    Divisor 188 produces 14705Hz sample rate.
    Divisor 189 produces 14925Hz sample rate.
    Divisor 190 produces 15151Hz sample rate.
    Divisor 191 produces 15384Hz sample rate.
    Divisor 192 produces 15625Hz sample rate.
    Divisor 193 produces 15873Hz sample rate.
    Divisor 194 produces 16129Hz sample rate.
    Divisor 195 produces 16393Hz sample rate.
    Divisor 196 produces 16666Hz sample rate.
    Divisor 197 produces 16949Hz sample rate.
    Divisor 198 produces 17241Hz sample rate.
    Divisor 199 produces 17543Hz sample rate.
    Divisor 200 produces 17857Hz sample rate.
    Divisor 201 produces 18181Hz sample rate.
    Divisor 202 produces 18518Hz sample rate.
    Divisor 203 produces 18867Hz sample rate.
    Divisor 204 produces 19230Hz sample rate.
    Divisor 205 produces 19607Hz sample rate.
    Divisor 206 produces 20000Hz sample rate.
    Divisor 207 produces 20408Hz sample rate.
    Divisor 208 produces 20833Hz sample rate.
    Divisor 209 produces 21276Hz sample rate.
    Divisor 210 produces 21739Hz sample rate.
    Divisor 211 produces 22222Hz sample rate.
    Divisor 212 produces 22727Hz sample rate.
    Divisor 213 produces 23255Hz sample rate.
    Divisor 214 produces 23809Hz sample rate.
    Divisor 215 produces 24390Hz sample rate.
    Divisor 216 produces 25000Hz sample rate.
    Divisor 217 produces 25641Hz sample rate.
    Divisor 218 produces 26315Hz sample rate.
    Divisor 219 produces 27027Hz sample rate.
    Divisor 220 produces 27777Hz sample rate.
    Divisor 221 produces 28571Hz sample rate.
    Divisor 222 produces 29411Hz sample rate.
    Divisor 223 produces 30303Hz sample rate.
    Divisor 224 produces 31250Hz sample rate.
    Divisor 225 produces 32258Hz sample rate.
    Divisor 226 produces 33333Hz sample rate.
    Divisor 227 produces 34482Hz sample rate.
    Divisor 228 produces 35714Hz sample rate.
    Divisor 229 produces 37037Hz sample rate.
    Divisor 230 produces 38461Hz sample rate.
    Divisor 231 produces 40000Hz sample rate.
    Divisor 232 produces 41666Hz sample rate.
    Divisor 233 produces 43478Hz sample rate.
    Divisor 234 produces 45454Hz sample rate.
    Divisor 235 produces 47619Hz sample rate.
    Divisor 236 produces 50000Hz sample rate.
    Divisor 237 produces 52631Hz sample rate.
    Divisor 238 produces 55555Hz sample rate.
    Divisor 239 produces 58823Hz sample rate.
    Divisor 240 produces 62500Hz sample rate.
    Divisor 241 produces 66666Hz sample rate.
    Divisor 242 produces 71428Hz sample rate.
    Divisor 243 produces 76923Hz sample rate.
    Divisor 244 produces 83333Hz sample rate.
    Divisor 245 produces 90909Hz sample rate.
    Divisor 246 produces 100000Hz sample rate.
    Divisor 247 produces 111111Hz sample rate.
    Divisor 248 produces 125000Hz sample rate.
    Divisor 249 produces 142857Hz sample rate.
    Divisor 250 produces 166666Hz sample rate.
    Divisor 251 produces 200000Hz sample rate.
    Divisor 252 produces 250000Hz sample rate.
    Divisor 253 produces 333333Hz sample rate.
    Divisor 254 produces 500000Hz sample rate.
    Divisor 255 produces 1000000Hz sample rate.
    All sample rates above 45454Hz are not actually supported by the hardware.