home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / sfx486 / sfx486.doc next >
Encoding:
Text File  |  1992-06-28  |  16.4 KB  |  539 lines

  1.  
  2.  
  3.  
  4.          ╓────────────────────────
  5.          ║
  6.          ║                         █▀▀▀▀▀▀▀▀   ▀▄               ▄▀
  7.          ║                        ▒█           ▒▒▀▄           ▄▀
  8.          ╚══════════════╗         ▒█             ▒▒▀▄       ▄▀
  9.                         ║         ▒█▀▀▀▀▀▀▀▀       ▒▒▀▄   ▄▀
  10.                         ║ ╓────┐ ╖   ┌ ╓──╖ ╓──┐     ▒▒▀▄▀
  11.                         ║ ║    │ ║   │ ║  ║ ║  │      ▄▀ ▀▄
  12.    ═════════════════════╝ ╚════╛ ╚═══╛ ╜  ╙ ╙──┘    ▄▀   ▒▒▀▄
  13.                                   ▒█              ▄▀       ▒▒▀▄
  14.                                   ▒█            ▄▀           ▒▒▀▄
  15.                                   ▒▒                           ▒▒
  16.  
  17.  
  18.            library for 486 Systems    (Beta Release, June 1993)
  19.  
  20.                    David Smith, CompuServe 7141,2723
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.         Thanks for helping me out with this beta release of SoundFX 486.
  28. To sample one of the 70 sounds, type: SFX486  and you will pop into a
  29. menu.  Simply highlight the noise you want to hear, and press ENTER.
  30.  
  31.         To exit at anytime, hit Alt-X  or  ESC several times.
  32.  
  33.         Back in 1990, when I first started SOUNDFX, I used ASM because
  34. of how quick it was.  I usually program in C, but using the function
  35. call sound() just was not fast enough.  The function is useful for a
  36. blip or boop on an XT or 286, but cannot make high-quality laser
  37. Star Wars space sounds as well as Assembler (actually, you can address
  38. PORT 61 through an "asm" declaration or simple port addressing, but
  39. either way, you are using ASSEMBLER calls).
  40.  
  41.         Today, it's 1993, going on 1994.  The Pentium is out, my friend
  42. just purchased a 486-66, and my old sounds go BLIP instead of
  43. BLOOOOOOOOOOOIIIIIIIIIIP.
  44.  
  45.         Thus arrives 486SFX, sound effects engineered for a 386-33 and
  46. above.  Unfortunately, I don't own a 486-50, 486-66 or the Pentium.
  47. My simple little 386-40 will have to suffice.  But now, higher level
  48. languages can be used for sound effects.
  49.         In fact, over 20 registered users of SOUND EFFECTS have complained
  50. about how the old stuff just doesn't sound good anymore.  They purchased
  51. a new system, and their boot-up effects or cute games are just too "blippy",
  52. and the sounds only last a millisecond compared to their XT or 286's.
  53.  
  54.         Check it out, and see what you think.
  55.  
  56.  
  57.  
  58. ===== SOUND EFFECTS 486 LIBRARY FOR PROGRAMMERS OF C =======================
  59.  
  60.         Enclosed is the library of all the sounds.  You can use it
  61.         in your own programs to enhance them.  Add spacey sounds
  62.         to your games, spreadsheets, or have the introduction of
  63.         your program be outstanding.
  64.  
  65.     They are written in Turbo C++ and can be used in this manner:
  66.  
  67.         extern void fart(void);
  68.  
  69.         main()
  70.         {
  71.              fart();
  72.              exit;
  73.         }
  74.  
  75.     To compile, include SFX486.LIB in your project, or use the
  76.     command line:
  77.  
  78.     TCC  myprog.c  SFX486.LIB    (whereas MYPROG.C is your program,
  79.                                   and using Turbo C++)
  80.  
  81.     If you are unsure of how to use libraries or functions in your
  82.     programs, please consult your "C" reference manual.  Here are
  83.     the possible functions and their usage:
  84.  
  85.         void makesound(int freq, int duration, int nsound)
  86.  
  87.                 consists of the lines:
  88.  
  89.                 sound(freq);
  90.                 delay(duration);
  91.                 if(nsound==1) nosound();
  92.  
  93.                 Makesound plays freq, then pauses duration,
  94.                 then turns off the sound if nsound=1
  95.  
  96.                         EXAMPLE: makesound(100, 50, 1);
  97.  
  98.  
  99.         void BIG_COOL(int Time,int Freq1,int Freq2,int Freq3,int Freq4,int D1,int D2,int D3,int D4);
  100.  
  101.                 Time is how many loops the sound goes through
  102.                 Freq1 - Freq4 are different frequencies you can specify
  103.                 D1 - D4 are delays between the sounds
  104.  
  105.                         EXAMPLE: BIG_COOL(100,20,4000,48,210,10,50,1,9);
  106.  
  107.  
  108.         void BIG_SWITCH(int First, int Second, int Loops, int Step1, int Step2);
  109.  
  110.                 This switches frequencies before it sends them through
  111.                 sound();   The effect is a vibration or shrill (really cool
  112.                 if you use it right!)
  113.  
  114.                 First is the first frequency
  115.                 Second is the second frequency
  116.                 Loops is how many loops the sound goes through
  117.                 Step1 is how much you want to decrease First after each pass
  118.                 Step2 is how much you want to increase Second after each pass
  119.  
  120.                 EXAMPLE: BIG_SWITCH(2039,41,170,10,20);
  121.  
  122.  
  123.  
  124.  
  125.     The remaining sounds are cool stuff from the demo program: SFX486.EXE
  126.     To hear any of them, just try out the program and listen to your
  127.     favorites, then use them in your own code.
  128.  
  129.     Of course, there's a ShareWare screen attached.  But if you like the
  130.     sounds, send $15.00 (plus $2.00 for shipping) to:
  131.  
  132.         David Smith
  133.        1104 Mason Dr
  134.        Hurst TX 76053
  135.  
  136.     This removes the ShareWare screen, plus gives you some MORE sounds
  137.     that are not included here.  That's only 14 cents a piece, which
  138.     is pretty reasonable.  Try them out and judge for yourself.
  139.  
  140.         To use them in your programs, take out all the "void"s,
  141.         and simply call the function...
  142.  
  143.  
  144.  
  145.           void delicious(void);
  146.           void affect(void);
  147.           void karate(void);
  148.           void clatter2(void);
  149.           void clatter(void);
  150.           void flanker(void);
  151.           void expire(void);
  152.           void swanson(void);
  153.           void sharkys(void);
  154.           void joseph(void);
  155.           void photons(void);
  156.           void distress(void);
  157.           void bulges(void);
  158.           void tender(void);
  159.           void temper(void);
  160.           void ontimes(void);
  161.           void formats(void);
  162.           void space(void);
  163.           void illume(void);
  164.           void fooling(void);
  165.           void style(void);
  166.           void force(void);
  167.           void expanse(void);
  168.           void direct(void);
  169.           void vapor(void);
  170.           void maligned(void);
  171.           void glimmer(void);
  172.           void plasma(void);
  173.           void cautious(void);
  174.           void tingle(void);
  175.           void compress(void);
  176.           void fervor(void);
  177.           void update(void);
  178.           void beamer(void);
  179.           void harddisk(void);
  180.           void determine(void);
  181.           void settle(void);
  182.           void medley(void);
  183.           void yomomma(void);
  184.           void thrill(void);
  185.           void ditto(void);
  186.           void visual(void);
  187.           void demon(void);
  188.           void error(void);
  189.           void shirk(void);
  190.           void blink(void);
  191.           void chase(void);
  192.           void magical(void);
  193.           void stronger(void);
  194.           void awaken(void);
  195.           void flicker(void);
  196.           void arcade1(void);
  197.           void bees(void);
  198.           void deadbird(void);
  199.           void downup(void);
  200.           void echos(void);
  201.           void fart(void);
  202.           void fire(void);
  203.           void high(void);
  204.           void motors(void);
  205.           void pulse(void);
  206.           void ringing(void);
  207.           void siren(void);
  208.           void wars(void);
  209.           void bomb(void);
  210.           void arcade2(void);
  211.           void bloop(void);
  212.           void Beep(void);
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236. ========= HOW TO MAKE SOUNDS ================================================
  237.  
  238.         Making sound is relatively easy.  And there are several ways to
  239.         do it:
  240.  
  241.                 1) Turn on the port in Assembler
  242.                 2) Turn on the port via a higher level language
  243.                    like C, PASCAL, or BASIC
  244.  
  245.  
  246.  
  247.  
  248. ------- What PORT do we use?
  249.  
  250.         Port 61 is the speaker PORT.  In assembler, if we want to
  251.         turn on the speaker, we use the following code:
  252.  
  253.         mov     bx,1000              ;frequency value
  254.         mov     ax,bx                ;place it in (ax)
  255.         out     42h,al               ;send LSB
  256.         mov     al,ah                ;place MSB in al
  257.         out     42h,al               ;now we send it
  258.         in      al,61h               ;get value from port
  259.         or      al,00000011          ;ORing turns on speaker
  260.         out     61h,al               ;send it to port
  261.  
  262.         This turns on the speaker, and sends it the frequency value.
  263.         To turn off the speaker, we would use:
  264.  
  265.         in      al,61h               ;get value from speaker port
  266.         and     al,11111100          ;ANDing turns speaker off
  267.         out     61h,al               ;send it
  268.  
  269.  
  270. Higher level languages use a simpler and much friendlier interface,
  271. the Sound() and Nosound() functions.  This does your port addressing
  272. for you, and eliminates the necessity of assembly code.  The downside
  273. of this, of course, is higher level languages are slower than
  274. assembler, and the loops they perform won't be as quick as one in
  275. ASM code.
  276.  
  277.        Or you can simulate ASM code by the following  (in C):
  278.  
  279. main()
  280. {
  281.  short value;                     /*  Value received by the port  */
  282.  int freq=400;                    /*  Our frequency               */
  283.  unsigned i;
  284.  
  285.  
  286.    outportb(0x43, 0xb6);           /* Initialize port              */
  287.    i = (unsigned)freq%256;
  288.    outportb(0x42, i);              /* Send high bit                */
  289.    i = (unsigned)freq/256;
  290.    outportb(0x42, i);              /* Send low bit                 */
  291.  
  292.    value = inportb(0x61);          /* Get value from port 61       */
  293.    value |= 0x03;                  /* AND the value                */
  294.    outportb(0x61, value);          /* Send value to port 61        */
  295. }
  296.  
  297.  
  298.         Notice the simularity to the above assembler code?  Turning on
  299. the PC speaker involves quite a bit of code (doing it the hard way).
  300. The easier alternative, of course, is:
  301.  
  302.         in C:                   sound(400);
  303.         or in Pascal:           sound(400);   (look real similar, huh?)
  304.  
  305.  
  306.         To enhance the blip sound, we can:
  307.  
  308.         ∙   Loop it several times, changing the frequency each loop
  309.         ∙   While looping, turn sound on and off
  310.         ∙   Send variable frequencies through the sound() function
  311.         ∙   Create multiple loops, each with different frequencies
  312.         ∙   Increment/decrement frequencies once they reach a number
  313.  
  314.         ∙   Use all of the above for an spacey effect
  315.  
  316.  
  317.  
  318.  
  319.         Let's look at an assembler program from Sound Effects 7 called
  320.         ARCADE1:
  321.  
  322. ------------- ARCADE1.ASM --------------------------------------------------
  323.             cli                          ;off the interrupts
  324.             mov     di,2                 ;repeat entire thing twice
  325.     agin1:  mov     bp,20                ;20 cycles of sound
  326.             mov     al,10110110          ;magic number
  327.             out     43h,al               ;send it to timer
  328.             mov     bx,1000              ;start frequency high
  329.     agin2:  mov     ax,bx                ;place it in (ax)
  330.             out     42h,al               ;send LSB
  331.             mov     al,ah                ;place MSB in al
  332.             out     42h,al               ;now we send it
  333.             in      al,61h               ;get value from port
  334.             or      al,00000011          ;ORing turns on speaker
  335.             out     61h,al               ;send it to port
  336.             mov     cx,35000             ;our delay count
  337.     looperx:loop    looperx              ;do nothing loop so we can hear sound
  338.             add     bx,50                ;lower frequency for next pass
  339.             in      al,61h               ;get value from speaker port
  340.             and     al,11111100          ;ANDing turns speaker off
  341.             out     61h,al               ;send it
  342.             dec     bp                   ;decrement cycle count
  343.             jnz     agin2                ;if not = 0 do again
  344.             mov     cx,60000             ;else load cx for 2nd delay
  345.     looperf:loop    looperf              ;do nothing loop
  346.             dec     di                   ;decrement repeat count
  347.             jnz     agin1                ;do entire thing again if not 0
  348.             sti                          ;else turn interrupts on and leave
  349. ----------------------------------------------------------------------------
  350.  
  351.  
  352.         This is basically what you saw above, with alternating frequencies
  353.         and a loop to ensure the sound does not fly by too fast for us
  354.         to hear.
  355.  
  356.         As you can see, the logic is:
  357.  
  358.         MAIN LOOP 2 times
  359.                 SECOND LOOP 20 times
  360.                         put 1000 through port 61
  361.                         delay 35000
  362.                         add 50 to frequency
  363.                 continue SECOND LOOP
  364.                 delay 60000
  365.         continue MAIN LOOP
  366.  
  367.  
  368.         and translating it to C gives us:
  369.  
  370. -------------- ARCADE1.C ----------------------------------------------------
  371. {
  372. int count, count2, freq=1000;                   /* approximations */
  373.  
  374.      for(count=0; count < 2; count++)
  375.         {
  376.            for(count2=0; count2 < 20; count2++)
  377.               {
  378.                  sound(freq);
  379.                  delay(350);                    /* approximations */
  380.                  freq+=50;                      /* approximations */
  381.               }
  382.               delay(800);
  383.         }
  384. }
  385. -----------------------------------------------------------------------------
  386.  
  387.  
  388.  
  389.  
  390.         To add cool special effects, we gotta be creative in the loops
  391. and frequencies:
  392.  
  393. ------------- GLIMMER.C ----------------------------------------------------
  394. {
  395. int a,b;
  396.  
  397.   for(count=1 ;count <6 ;count++)
  398.     {
  399.           a = 10;
  400.           b = 4000;
  401.        for(count2=1 ;count2 <201 ;count2++)
  402.          {
  403.               sound (a);
  404.               delay (2);
  405.               sound (b);
  406.               delay (2);
  407.               a = a + 10;
  408.               b = b - 10;   }
  409.           nosound();   }
  410. }
  411. ----------------------------------------------------------------------------
  412.  
  413.  
  414.         NOTE: Glimmer is in your runnable code: SFX486.EXE
  415.  
  416.  
  417. ------------- GLIMMER.PAS --------------------------------------------------
  418. procedure glimmer;
  419.    begin
  420.       for count := 1 to 5 do
  421.         begin
  422.           a := 10;
  423.           b := 4000;
  424.           for count2 := 1 to 200 do
  425.             begin
  426.               sound (a);
  427.               delay (2);
  428.               sound (b);
  429.               delay (2);
  430.               a := a + 10;
  431.               b := b - 10;
  432.             end;
  433.           nosound;
  434.         end;
  435.    end;
  436. ----------------------------------------------------------------------------
  437.  
  438.  
  439.         or we can reset the frequencies once they reach a certain
  440.         value (or when one reaches a value):
  441.  
  442.  
  443. ------------- AWAKEN.C -----------------------------------------------------
  444. {
  445. int reverse=0, freqhi, freqlo, i;
  446.  
  447.     freqhi=6000;
  448.     freqlo=90;
  449.  
  450.     for(i=0;i<1400;i++)
  451.     {
  452.         sound(freqhi);
  453.         delay(5);
  454.         sound(freqlo);
  455.         delay(5);
  456.         if(reverse){ freqhi+=30;  freqlo-=10; }
  457.         else{        freqhi-=30;  freqlo+=10; }
  458.  
  459.         if(freqhi<100) reverse=1;
  460.         if(freqhi>5999) reverse=0;
  461.     }
  462.  
  463. nosound();
  464. }
  465. ----------------------------------------------------------------------------
  466.  
  467.  
  468.         NOTE: Awaken is in your runnable code: SFX486.EXE
  469.  
  470.  
  471.  
  472.  
  473.  
  474. ============= IDEAS TO PLAY WITH ===========================================
  475.  
  476.     1.  Have two integers with different frequency values,
  477.         send them through the SOUND function, then exchange them
  478.         and run through again.
  479.  
  480.     2.  Have multiple layers of loops, each with their own
  481.         frequency integers.  One loop can decrement their
  482.         frequencies dependent upon another loop's frequency
  483.         value, and another one can start/stop their value
  484.         based upon another loop's step value.
  485.  
  486.     3.  Have random values for frequencies (make your own random
  487.         number generator, C's RANDOM function sucks!).
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.         Some of the sounds are not in the library yet (I am still
  505.         working on them!)  So if the menu does nothing or simply
  506.         closes up when you choose a sound, don't panic.
  507.         I will fill up the remaining sounds shortly.
  508.  
  509.         Sounds that definitely make a difference.
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.         Please give me your feedback.  How do these sounds play on
  517.         your computer?  Are they too fast, too slow, etc...?
  518.  
  519.         Send your comments or suggestions to:
  520.  
  521.         David Smith, CompuServe 71441,2723
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.