[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
cpplexicalcast » VESA » jpg » MsDosSet » software » D » dynamic » CppBuilderGlossary » QbasicFAQ_Mouse » CMemcmp » QbasicFAQ_SoundTutorial
Qbasic Sound tutorial


Back to QBasic FAQ Main Page.

I felt that the article discussing SOUND in QBasic was much too brief for any beginner to understand. So, I'll write a short tutorial discussing this.
The syntax (the way it is used) is like so:

SOUND pitch, duration


Where pitch is how high or low you want the sound effect to go. This can range between 40-4000+, sometimes depending on which comptuer or compiler you use.

Where duration is how long you want the sound to persist. This can range between .01 (any lower and it can be too short to hear)and much longer. Here is an example:

SOUND 600, 3
SOUND 50, 1.5
  SOUND 600, 3
SOUND 50, 1.5
 SOUND 650, 3
  SOUND 600, 3
   SOUND 50, 1.5
SOUND 600, 3
 SOUND 700, 5
  SOUND 800, 5
   SOUND 900, 2


Here is another example that shows the possibilities with SOUND.
DO
FOR n = -180 TO 180 STEP .1
f = 440 + 50 * SIN(n)
SOUND f, 1
NEXT
LOOP


Run this in QBasic and hear what happens.
Play around and get the feel of this, too.


However, this command is not to be used to provide music for games, but simply for sound effects and alerts. If you want consistent music in the background of your game, you gotta learn to use PLAY.

Using the PLAY command would require you to be able to read and write notes. I certainly can't cover that now, since PLAY is a topic deserving a long discussion and since this is not even meant to be a tutorial--just a review.

email any requests or questions to me: drcomwiz@aol.com

last edited (March 31, 2006) by casio-games.tk, Number of views: 11244, Current Rev: 8 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.