Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong explanation in Play?
#1
Am I wrong again? (I often am)!
In the Wiki (and the Help file) I think there may be an error in the explanation for a pause in the Play function.
It says that Pn will pause for n quarter-notes, when it actually pauses for  1/n th. So p1 pauses longer than say, p16.
It's quite easy to adjust the string, but it's confusing. Huh
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
(10-23-2023, 11:33 AM)PhilOfPerth Wrote: Am I wrong again? (I often am)!
In the Wiki (and the Help file) I think there may be an error in the explanation for a pause in the Play function.
It says that Pn will pause for n quarter-notes, when it actually pauses for  1/n th. So p1 pauses longer than say, p16.
It's quite easy to adjust the string, but it's confusing. Huh

Well I tried adding p in the middle of a sample and all I got was illegal this and that, no matter what I tried so don't have proper code test.

But if 1 is whole note and 4 is quarter note then 8 must be eight and so on to 64 so I agree with your observation.

illegal code:
Code: (Select All)
Play "q0mll64"
Do
    For x = 1 To 50
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    a$ = a$ + "p" + _Trim$(Str$(i))
    For x = 50 To 1 Step -1
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    Print a$
    Play a$
    a$ = ""
Loop Until InKey$ <> ""
Play "v10l1c,l4egl2o5c,o4l4eg"
b = b + ...
Reply
#3
This is the "example 1", right? You added the line with `PLAY` "p" command, but what is `i` being assigned to?



Code: (Select All)

Dim As Integer i, j
Play "q0mll64"
For j = 0 To 6
For x = 1 To 50
a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
Next
i = 2 ^ j
a$ = a$ + "p" + _Trim$(Str$(i))
For x = 50 To 1 Step -1
a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
Next
Print a$
Play a$
a$ = ""
Next
Play "v10l1c,l4egl2o5c,o4l4eg"

LOL I like the end music, like the Atari2600 version of Pac-Man! Big Grin
Reply
#4
This is the "example 1", right? You added the line with `PLAY` "p" command, but what is `i` being assigned to?

Yes what is i? What was i thinking, not x LOL

Who uses x for index, not i
b = b + ...
Reply
#5
(10-23-2023, 02:59 PM)bplus Wrote:
(10-23-2023, 11:33 AM)PhilOfPerth Wrote: Am I wrong again? (I often am)!
In the Wiki (and the Help file) I think there may be an error in the explanation for a pause in the Play function.
It says that Pn will pause for n quarter-notes, when it actually pauses for  1/n th. So p1 pauses longer than say, p16.
It's quite easy to adjust the string, but it's confusing. Huh

Well I tried adding p in the middle of a sample and all I got was illegal this and that, no matter what I tried  so don't have proper code test.

But if 1 is whole note and 4 is quarter note then 8 must be eight and so on to 64 so I agree with your observation.

illegal code:
Code: (Select All)
Play "q0mll64"
Do
    For x = 1 To 50
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    a$ = a$ + "p" + _Trim$(Str$(i))
    For x = 50 To 1 Step -1
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    Print a$
    Play a$
    a$ = ""
Loop Until InKey$ <> ""
Play "v10l1c,l4egl2o5c,o4l4eg"
I have no problem getting "p" to be recognized. This is a simple check I used:
Play "cdp16ef"
Sleep 1
Play "cdp1ef"
As you'll notice, line 3 has a much longer pause than line 1
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#6
(10-23-2023, 11:18 PM)PhilOfPerth Wrote:
(10-23-2023, 02:59 PM)bplus Wrote:
(10-23-2023, 11:33 AM)PhilOfPerth Wrote: Am I wrong again? (I often am)!
In the Wiki (and the Help file) I think there may be an error in the explanation for a pause in the Play function.
It says that Pn will pause for n quarter-notes, when it actually pauses for  1/n th. So p1 pauses longer than say, p16.
It's quite easy to adjust the string, but it's confusing. Huh

Well I tried adding p in the middle of a sample and all I got was illegal this and that, no matter what I tried  so don't have proper code test.

But if 1 is whole note and 4 is quarter note then 8 must be eight and so on to 64 so I agree with your observation.

illegal code:
Code: (Select All)
Play "q0mll64"
Do
    For x = 1 To 50
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    a$ = a$ + "p" + _Trim$(Str$(i))
    For x = 50 To 1 Step -1
        a$ = a$ + "v" + LTrim$(Str$(x)) + "n" + LTrim$(Str$(x))
    Next
    Print a$
    Play a$
    a$ = ""
Loop Until InKey$ <> ""
Play "v10l1c,l4egl2o5c,o4l4eg"
I have no problem getting "p" to be recognized. This is a simple check I used:
Play "cdp16ef"
Sleep 1
Play "cdp1ef"
As you'll notice, line 3 has a much longer pause than line 1

Yes I agree with you, it could be better worded in Wiki, that 1-64 are fractions of one not numbers of quarter notes, good catch. mnr's fix of my botched mod of sample proves it.
b = b + ...
Reply
#7
https://hwiegman.home.xs4all.nl/qb45-man/index.html  <-- There's a basic copy of the old QB45 documentation, which is more or less the same as what we have.

Code: (Select All)
PLAY - a device I/O statement that plays music

Syntax
  PLAY commandstring
    - commandstring is a stringexpression that contains music commands:

------------------------- Set Octaves and Play Tones -------------------------
On  Sets current octave (n = 0-6)    |  < or >  Up or down one octave
Nn  Plays note n (n = 0-84, 0 is a  |  A-G  Plays A, B, ..., G in current
    rest)                            |      octave (+ = sharp, - = flat)
------------------------- Set Tone Duration and Tempo ------------------------
Ln  Sets length of a note (L1 is    |  MS  Each note plays 3/4 of length
    whole note, L4 is quarter note,  |  MN  Each note plays 7/8 of length
    etc.)  n = 1-64                  |  ML  Each note plays full length
Tn  Sets number of quarter notes per |  Pn  Pause for the duration of
    minute (n = 32-255, 120 default  |      n quarternotes (n = 1-64)
------------------------------- Set Operation --------------------------------
MF  Plays music in foreground        |  MB  Plays music in background
------------------------------ Execute Substrings ----------------------------
      X + VARPTR$(string-expression) |  Executes another command string

See Also  <SOUND>  <BEEP>  <ON PLAY(N)>
Other Uses of the PLAY Keyword
  <PLAY ON, PLAY OFF, AND PLAY STOP> - to enable, disable, or suspend play
                                      event trapping
  <PLAY FUNCTION> - to return the number of notes in the background music
                    queue

In this case, it appears that the even older QUICKBASIC documentation is much clearer and easier to understand.  From: https://www.qbasic.net/en/reference/qb11...AY-006.htm

Code: (Select All)
commandstring$    A string expression that contains one or more of the following PLAY commands:
Octave and tone commands:
Ooctave    Sets the current octave (0 - 6).
< or >     Moves up or down one octave.
A - G      Plays the specified note in the current octave.
Nnote      Plays a specified note (0 - 84) in the seven-octave
            range (0 is a rest).

Duration and tempo commands:
Llength    Sets the length of each note (1 - 64). L1 is whole note,
            L2 is a half note, etc.
ML         Sets music legato.
MN         Sets music normal.
MS         Sets music staccato.
Ppause     Specifies a pause (1 - 64). P1 is a whole-note pause,
            P2 is a half-note pause, etc.
Ttempo     Sets the tempo in quarter notes per minute (32 - 255).

Mode commands:
MF          Plays music in foreground.
MB          Plays music in background.

Suffix commands:
# or +      Turns preceding note into a sharp.
-           Turns preceding note into a flat.
.           Plays the preceding note 3/2 as long as specified.
To execute a PLAY command substring from a PLAY command string, use the "X" command:
PLAY "X"+ VARPTR$(commandstring$)

Which from the QuickBASIC notes, it's obvious that we're doing what we're supposed to. P1 is a whole note. P2 is a half note. P4 is a quarter note. The pause is (1 / n) notes.

QB64 is correct. It's just the documentation here could use some tweaking to clarify what it's actually doing better.
Reply
#8
Updated the wiki to reflect the same style wording as the old QuickBASIC documentation here: https://qb64phoenix.com/qb64wiki/index.php/PLAY

See if this isn't more concise and less confusing for you guys. Smile
Reply
#9
(10-24-2023, 02:12 PM)SMcNeill Wrote: Updated the wiki to reflect the same style wording as the old QuickBASIC documentation here: https://qb64phoenix.com/qb64wiki/index.php/PLAY

See if this isn't more concise and less confusing for you guys. Smile

Looks good to me, the real test is Phil because he is one into DRAW at moment. Good to have newbie first impressions, very valuable to Basic core IMHO.

Thankyou Phil and Steve of course!
b = b + ...
Reply




Users browsing this thread: 1 Guest(s)