QB64 sound 0,0

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
imeixner
Newbie
Posts: 2
Joined: Sat Jan 24, 2015 4:30 pm

QB64 sound 0,0

Post by imeixner »

I have to generate a continuous tone and to vary the frequency per cursor-keys.
The only way is to generate a longer sound and to stop it, if a key is pressed.

In QBASIC it works if I generate this tone for example by "sound 400,10000".
If a key is pressed, I stop this tone by "sound 0,0" and then generate an new tone with the modyfied frequency.

In QB64 "sound 0,0" does'nt stop the sound! So I do'nt know how I could stop it!

Thanks Ingomar
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: QB64 sound 0,0

Post by burger2227 »

Could you post an example for me to see what exactly you are doing.

SOUND also creates code execution delays in QB that won't happen in QB64.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: QB64 sound 0,0

Post by burger2227 »

I reported the incompatibility at QB64:

Code: Select all

SOUND 400, 500

SLEEP 10

PRINT "stop"
SOUND 0, 0  'stop previous
SOUND 300, 100 'new
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
imeixner
Newbie
Posts: 2
Joined: Sat Jan 24, 2015 4:30 pm

Re: QB64 sound 0,0

Post by imeixner »

Exactly!

Here is my program:
The frequency is varyied by the cursor-keys:
page up/down: 1 oktave
cursor right/left: 1 halftone
cursor up/down: 1/12 of a halftone



REM Frequenzvergleich
CLS
GOSUB kopf
farbe = 3
meldg$ = "Frequenz „ndern: Pfeil- und Bildtasten; Pause: Leertaste; Ende: Esc"
GOSUB meldung
boxx = 16: boxy = 9: breite = 46: hoehe = 7
COLOR 0, 7
GOSUB box: GOSUB textvor
tastmoeg$ = " IQMKHP" + CHR$(27)
DIM fakt(7)
fakt(0) = 1: fakt(1) = 1: fakt(2) = 2: fakt(3) = 1 / 2
fakt(4) = 2 ^ (1 / 12): fakt(5) = 2 ^ -(1 / 12)
fakt(6) = 2 ^ (1 / 144): fakt(7) = 2 ^ -(1 / 144)
freq = 440
tast = 0
DO
freq = freq * fakt(tast)
IF freq < 55 THEN freq = 55 ELSE IF freq > 7040 THEN freq = 7040
LOCATE 12, 40: PRINT USING "#####"; freq
SOUND 0, 0
SOUND freq, 10000
DO
tast$ = INKEY$
LOOP UNTIL tast$ > ""
tast$ = RIGHT$(tast$, 1)
tast = INSTR(tastmoeg$, tast$)
IF tast = 1 THEN SOUND 0, 0: SLEEP
LOOP UNTIL tast = 8
SOUND 0, 0
SYSTEM

textvor:
LOCATE 12, 29: PRINT "Frequenz:"; TAB(46); "Hz"
RETURN
kopf:
COLOR 7, 3: CLS
COLOR 15, 1
PRINT TAB(80); " ";
PRINT TAB(27); "*** F R E Q U E N Z ***"; TAB(80); " "
PRINT TAB(80); " ";
COLOR 3
PRINT TAB(29); "(C) 1999 by I. Meixner"; TAB(80); " ";
RETURN
meldung:
COLOR farbe, 1
LOCATE 25, 1: PRINT TAB(41 - LEN(meldg$) / 2); meldg$; TAB(80); " ";
RETURN
box:
LOCATE boxy, boxx: PRINT "É"; STRING$(breite - 2, "Í"); "»"
FOR ix = 1 TO hoehe - 2: LOCATE , boxx: PRINT "º"; SPC(breite - 2); "ºÛÛ": NEXT
LOCATE , boxx: PRINT "È"; STRING$(breite - 2, "Í"); "¼ÛÛ"
LOCATE , boxx + 2: PRINT STRING$(breite, "Û");
RETURN
Post Reply