Weekly Qbasic and Qb64 Lesson Topics
October 20, 2018, 06:07:59 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

PLAY


Pages: [1]
  Print  
Author Topic: PLAY  (Read 494 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: January 16, 2011, 11:02:46 pm »

Play is a very simple command, I enjoy doing stuff with it, in QB4.5 you can get more details, useing help,..
PLAY   For more details.
basicly :
PLAY "abcdefg"
plays those notes, there are many variations, that can be used in the syntax,...aslo SOUND, but I will go into that next week,..
here is a sample:
--------code below-------
Code:
                 CLS
REM Use A B C D E F G to play notes, Q move up octv Z down also X ,S
COLOR 10, 1, 5
PRINT "THIS WILL HAVE COLORS"
LET MyName$ = "GARRY"
PRINT MyName$
PLAY "abcdeffgbdecaaa"
PRINT "MY MUSIC,By Garry"
'PLAY "MB aaggbbcaaggbbceef<gabcde<fgegfedbcaa<abcdeefg"
PLAY "L16 AGBDE"
PRINT "press q to quit"
'PLAY "L7 aaAgfaeegG"
PRINT "PLEASE wait for the music to stop"
PRINT "NOW, after the music stops, press A,B,C,D,E,F,or G"
PRINT "or p, this is case sensitive."
DO
    A$ = INKEY$
    IF A$ = "q" THEN END
    IF A$ = "p" THEN PLAY "abcdefg"
    IF A$ = "A" THEN PLAY "a10"
    IF A$ = "A" THEN PRINT "A"
    IF A$ = "B" THEN PLAY "b10"
    IF A$ = "B" THEN PRINT "B"
    IF A$ = "C" THEN PLAY "c10"
    IF A$ = "C" THEN PRINT "C"
    IF A$ = "D" THEN PLAY "d10"
    IF A$ = "D" THEN PRINT "D"
    IF A$ = "E" THEN PLAY "E10"
    IF A$ = "E" THEN PRINT "E"
    IF A$ = "F" THEN PLAY "F10"
    IF A$ = "F" THEN PRINT "F"
    IF A$ = "G" THEN PLAY "G10"
    IF A$ = "G" THEN PRINT "G"
    IF A$ = "Q" THEN PLAY ">A10"
    IF A$ = "Z" THEN PLAY "<A10"
    IF A$ = "X" THEN PLAY "<G8"
    IF A$ = "S" THEN PLAY ">G8"
    IF A$ = "N" THEN PLAY "L4A"
LOOP
 
---------end code---------

CreativeMinds
http://www.garryspages.webs.com
« Last Edit: July 17, 2011, 08:31:08 pm by GarrisonRicketson » Report Spam   Logged

Social Buttons

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: June 19, 2011, 08:40:20 pm »

Here are 2 more examples, one dose not use a image, the other dose:
Code:
REM Simple Note player
DEFLNG A-Z

SCREEN 12

DO
    Keycode& = _KEYHIT
    SELECT CASE Keycode&
        CASE IS = 97
            PLAY "a10": Note$ = "A"
        CASE IS = 98
            PLAY "b10": Note$ = "B"
        CASE IS = 99
            PLAY "c10": Note$ = "C"
        CASE IS = 100
            PLAY "d10": Note$ = "D"
        CASE IS = 101
            PLAY "e10": Note$ = "E"
        CASE IS = 102
            PLAY "f10": Note$ = "F"
        CASE IS = 103
            PLAY "g10": Note$ = "G"
    END SELECT

    LOCATE 10, 10: PRINT Note$
    None$ = INKEY$
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM
----------------------------------------------
Code:

Backy& = _LOADIMAGE("Piano-01.png, 32)
Mixpage& = _NEWIMAGE(120, 92, 32)
Video& = _NEWIMAGE(600, 400, 32)


DO
    GOSUB Unpressed
    Keycode& = _KEYHIT
    SELECT CASE Keycode&
        CASE IS = 97
            PLAY "a10": Note$ = "A": x1 = 1
        CASE IS = 98
            PLAY "b10": Note$ = "B": x1 = 17
        CASE IS = 99
            PLAY "c10": Note$ = "C": x1 = 33
        CASE IS = 100
            PLAY "d10": Note$ = "D": x1 = 49
        CASE IS = 101
            PLAY "e10": Note$ = "E": x1 = 65
        CASE IS = 102
            PLAY "f10": Note$ = "F": x1 = 81
        CASE IS = 103
            PLAY "g10": Note$ = "G": x1 = 97
    END SELECT

    IF Keycode& <> 0 THEN GOSUB Pressed
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM

Unpressed:
_PUTIMAGE (0, 0)-(119, 91), Backy&, Mixpage&, (0, 0)-(119, 91) 'place backy to mix
_PUTIMAGE , Mixpage&, Video&
SCREEN Video&
_DISPLAY
RETURN

Pressed:
x2 = x1 + 15
_PUTIMAGE (x1, 79)-(x2, 89), Backy&, Mixpage&, (122, 0)-(137, 10) 'show key down
_PUTIMAGE , Mixpage&, Video&
SCREEN Video&
_DISPLAY
_DELAY .05
RETURN
You can use the attached image,  for this. The above.

Yes Quark, you can attach the image, with the code,..
I have attatched the one, for the piano,...However The SMF, dose not accept BMP
Attach:    (more attachments)
Allowed file types: doc, gif, jpg, mpg, pdf, png, txt, zip, jpeg, docx, xls
Maximum attachment size allowed: 1200 KB, per post: 8
 So I changed it to a .PNG
You will either need to change it back to a .bmp or change the filename in the code:
Code:
Backy& = _LOADIMAGE("Piano-01.bmp", 32) 
Change this to:
Quote
Backy& = _LOADIMAGE("Piano-01.png", 32)
From Garry
« Last Edit: April 14, 2012, 07:53:43 am by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #2 on: July 17, 2011, 08:39:35 pm »

I edited and updated the original post here:
Original Post   Like wise for more details on the Play command,
Play command
From Garry
Creative Minds
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 on: July 19, 2011, 07:22:13 pm »

A little more on PLAY, I just found out, about this, right here in my QB64 directory on my computer  ,..
qb64/samples/qb64/original/carols.bas   , is the complete path,....It
is a pretty neat demo of useing play, print, also I like the Index/menu, in it, it
is very easy to understand, the code used,...There is some interesting
things in this program, but it is a different subject,...But I notice
he uses ,
GOTO    , and   
 
GOSUB
, I have seen discussions on
this before, and it gets controversial, I had started a program, and I
wanted a menu, so I used goto,...it seemed to work ok, but I got told
that I shouldn't use goto,  ...But lets not go into that here,...I
know there is a thread on this (GOTO), some where here, on qb64.net, I
will look for it,
 Thanks, a bunch on the info in  samples, carols.bas, relateing to the PLAY command.
From Garry
« Last Edit: July 22, 2011, 08:03:27 am by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 on: April 14, 2012, 07:54:52 am »

 I just updated this thread a little.
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy