PLAY (function): Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
The '''PLAY''' function returns the number of remaining notes in the background music queue. | The '''PLAY''' function returns the number of remaining notes/samples/seconds in the background music queue. | ||
{{PageSyntax}} | {{PageSyntax}} | ||
: {{Parameter| | : {{Parameter|remaining&}} = '''PLAY''' ({{Parameter|numericExpression&}}) | ||
{{PageParameters}} | {{PageParameters}} | ||
* {{Parameter| | * {{Parameter|remaining&}} is the number of notes/samples/seconds left to play in the background music queue. | ||
* {{Parameter|numericExpression&}} can be any numeric expression. | |||
* {{Parameter| | * '''See also the important version dependent notes in the Availability section.''' | ||
{{PageDescription}} | {{PageDescription}} | ||
* | * This function may be used to detect, if the background music queue is still playing. | ||
* When there is nothing left to play, then this function returns zero. | |||
* When there is nothing left to play, this returns zero. | |||
{{PageAvailability}} | {{PageAvailability}} | ||
* '''QB64-PE v3.1 | <!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | ||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''v0.934''' | |||
File:Qbpe.png|'''v3.1.0''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''yes''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
* In '''QB64''' and early '''QB64-PE''', this was just implemented as stub function which always returned zero. | |||
* Since '''QB64-PE v3.1.0''' the function is fully implemented, but unlike '''QuickBASIC''', in '''QB64-PE''' this function does not return the number of notes left, but the number of audio samples. | |||
* Since '''QB64-PE v3.8.0''', if {{Parameter|numericExpression&}} is a number other than zero, then the function will return the amount of time (seconds) left to play. | |||
{{PageExamples}} | {{PageExamples}} | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|PLAY}} "mb l4cf.l8el4fag.l8fl4gl8agl4f.l8fl4a>cl2dl4dl4c.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl2f>l4dc.<l8al4afg.l8fl4g>dc.<l8al4a>cl2dl4dc.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl1f" | {{Cl|PLAY}} {{Text|<nowiki>"mb l4cf.l8el4fag.l8fl4gl8agl4f.l8fl4a>cl2dl4dl4c.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl2f>l4dc.<l8al4afg.l8fl4g>dc.<l8al4a>cl2dl4dc.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl1f"</nowiki>|#FFB100}} | ||
{{Cl|PRINT}} "Playing tune..." | {{Cl|PRINT}} {{Text|<nowiki>"Playing tune..."</nowiki>|#FFB100}} | ||
{{Cl|DO}} | {{Cl|DO}} | ||
smplLeft& = {{Cl|PLAY (function)|PLAY}}({{Text|0|#F580B1}}) | |||
{{Cl|LOCATE}} , 1: {{Cl|PRINT}} " | timeLeft& = {{Cl|PLAY (function)|PLAY}}({{Text|1|#F580B1}}) | ||
{{Cl| | {{Cl|LOCATE}} {{Text|3|#F580B1}}, {{Text|1|#F580B1}}: {{Cl|PRINT}} {{Text|<nowiki>"Samples left to play ="</nowiki>|#FFB100}}; smplLeft&; {{Text|<nowiki>" "</nowiki>|#FFB100}}; | ||
{{Cl|LOCATE}} {{Text|4|#F580B1}}, {{Text|1|#F580B1}}: {{Cl|PRINT}} {{Text|<nowiki>"Seconds left to play ="</nowiki>|#FFB100}}; timeLeft&; {{Text|<nowiki>" "</nowiki>|#FFB100}}; | |||
{{ | {{Cl|DO...LOOP|LOOP WHILE}} smplLeft& | ||
{{Cl|PRINT}}: {{Cl|PRINT}}: {{Cl|PRINT}} {{Text|<nowiki>"And we are done!"</nowiki>|#FFB100}} | |||
{{Cl|END}} | {{Cl|END}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Line 40: | Line 52: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[PLAY]] | * [[PLAY]] | ||
* [[SOUND]] | * [[SOUND]] | ||
* [[BEEP]] | * [[BEEP]] | ||
* [[_SNDOPEN]] | * [[_SNDOPEN]] | ||
* [[_SNDRAW]] | * [[_SNDRAW]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 16:36, 18 June 2023
The PLAY function returns the number of remaining notes/samples/seconds in the background music queue.
Syntax
- remaining& = PLAY (numericExpression&)
Parameters
- remaining& is the number of notes/samples/seconds left to play in the background music queue.
- numericExpression& can be any numeric expression.
- See also the important version dependent notes in the Availability section.
Description
- This function may be used to detect, if the background music queue is still playing.
- When there is nothing left to play, then this function returns zero.
Availability
- In QB64 and early QB64-PE, this was just implemented as stub function which always returned zero.
- Since QB64-PE v3.1.0 the function is fully implemented, but unlike QuickBASIC, in QB64-PE this function does not return the number of notes left, but the number of audio samples.
- Since QB64-PE v3.8.0, if numericExpression& is a number other than zero, then the function will return the amount of time (seconds) left to play.
Examples
PLAY "mb l4cf.l8el4fag.l8fl4gl8agl4f.l8fl4a>cl2dl4dl4c.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl2f>l4dc.<l8al4afg.l8fl4g>dc.<l8al4a>cl2dl4dc.<l8al4afg.l8fl4gl8agl4f.l8dl4dcl1f" PRINT "Playing tune..." DO smplLeft& = PLAY(0) timeLeft& = PLAY(1) LOCATE 3, 1: PRINT "Samples left to play ="; smplLeft&; " "; LOCATE 4, 1: PRINT "Seconds left to play ="; timeLeft&; " "; LOOP WHILE smplLeft& PRINT: PRINT: PRINT "And we are done!" END |
See also