QBasic Tutorial 25 - Sound and Music - QB64


There are a few ways of making sounds and music in QBasic / QB64.

The first command is BEEP. BEEP just beeps and is used as an alert.

Next is the SOUND command. SOUND plays a frequency for a specified duration.
- Frequency 37 to 32767
- Duration 0 to 65535

Finally, there is PLAY. Here are some settings for PLAY.

O - Octave (0 - 6): O6
< or > - Moves Up or Down One Octave
P - Pauses (1 - 64): P1 Pause Whole Note
T - Tempo (32 - 255) in Quarter Notes Per Minute: T120
A, B, C, D, E, F, G - Plays The Note in the Current Octave
Playing Length(1 - 64): C2 Plays an C Half Note
+ or # Makes The Preceding Note Sharp
- (Minus) Makes the Preceding Note Flat

NOTE
QBasic uses the internal speaker to play sounds and music. Many computers do not come with an internal PC speaker. To get around this problem use DOSBox or QB64.


Ode to Joy Notes
PLAY "T120PLAY "d8d8e8c8d8e12f12e8c8d8e12f12e8d8c8d8p8"
PLAY "e8e8f8g8g8f8e8d8c8c8d8e8d8c12c4"

Code Download
QBT25_1.BAS
QBT25_2.BAS
QBT25_3.BAS
QBT25_4.BAS
QBT25_5.BAS
QBT25_6.BAS



QBasic / QB64 Links

QB64 is a free download at www.qb64.com

QB64 Wiki & Manual is found at qb64.com/wiki.html

QBasic 1.1 comes with OldDOS. A zip file of OldDOS can be found at www.pcxt-micro.com/download.html

QBasic 1.1 needs DOSBox to run on Windows Vista and greater, Mac, and Linux.
DosBox is a free download at www.dosbox.com

Free QB64/QBasic Code

QBasic.Net - www.qbasic.net

Pete's QBasic Site - www.petesqbsite.com/index.php

QB45 - qb45.org

Phatcode - games.phatcode.net