-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path534.html
More file actions
211 lines (211 loc) · 12.5 KB
/
Copy path534.html
File metadata and controls
211 lines (211 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SmallBASIC | PLAY</title>
<meta name="description" content="Play musical notes.">
<link rel="canonical" href="534">
<link rel="keywords" href="PLAY string">
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" type="image/png" href="/images/sb-desktop-32x32.png">
<script src="/clipboard.js"></script>
</head>
<body>
<button onclick="topFunction()" id="BackToTopBtn" title="Go to top">⯅</button>
<script src="/backtotop.js"></script>
<div class="wrapAll clearfix">
<nav class="navigation">
<div class="logo">
<a href="/"><img src='/images/sb-logo.png?v=2' alt="logo"></a>
</div>
<div class="navlinks">
<a href="/pages/download.html">Download</a>
<a href="/pages/news.html">News</a>
<a href="/pages/community.html">Community</a>
<a href="/pages/articles.html">Resources</a>
<a class='active' href="/pages/reference.html">Language Reference</a>
<a href="/pages/guide.html">SmallBASIC Manual</a>
</div>
</nav>
<div class="mainsection">
<div class="tabs clearfix">
<div class="tabsRight">
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/blob/master/_build/reference/534-console-play.markdown">Edit</a>
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/commits/master/_build/reference/534-console-play.markdown">History</a>
</div>
</div>
<div class="article">
<h1>PLAY</h1>
<blockquote>PLAY string</blockquote>
<div class="siteSub">
<p>
<a href="/">Home</a> >
<a href="/pages/reference.html">Reference</a> >
<a href="/pages/console.html">Console</a>
</p>
</div>
<p>Play musical notes, a mp3 or ogg sound file. The music string is
composed of the following building blocks:</p>
<table>
<colgroup>
<col style="width: 32%" />
<col style="width: 67%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">String</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">A-G[-</td>
<td style="text-align: left;">+</td>
</tr>
<tr class="even">
<td style="text-align: center;">On</td>
<td style="text-align: left;">Octave n = 0..6, n = < moves down one
octave, n = > moves up one octave</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Nn</td>
<td style="text-align: left;">Play note n = 0..84 (0 = pause)</td>
</tr>
<tr class="even">
<td style="text-align: center;">Pn</td>
<td style="text-align: left;">Pause n = 1..64</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Ln</td>
<td style="text-align: left;">Length of note n = 1..64 (1/nnn)</td>
</tr>
<tr class="even">
<td style="text-align: center;">Tn</td>
<td style="text-align: left;">Tempo n = 32..255. Number of 1/4 notes per
minute.</td>
</tr>
<tr class="odd">
<td style="text-align: center;">MS</td>
<td style="text-align: left;">Staccato (1/2)</td>
</tr>
<tr class="even">
<td style="text-align: center;">MN</td>
<td style="text-align: left;">Normal (3/4)</td>
</tr>
<tr class="odd">
<td style="text-align: center;">ML</td>
<td style="text-align: left;">Legato</td>
</tr>
<tr class="even">
<td style="text-align: center;">Vn</td>
<td style="text-align: left;">Volume n = 0..100</td>
</tr>
<tr class="odd">
<td style="text-align: center;">MF</td>
<td style="text-align: left;">Play on foreground</td>
</tr>
<tr class="even">
<td style="text-align: center;">MB</td>
<td style="text-align: left;">Play on background</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Q</td>
<td style="text-align: left;">Clear sound queue</td>
</tr>
</tbody>
</table>
<p>To play a sound file use <code>file://filename</code> as string. When
playing on background, program execution continuous. If the end of the
program is reach, the playback will stop.</p>
<h3 id="example-1-play-a-note">Example 1: Play a note</h3>
<div class="sourceCode" id="cb1"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">play</span> <span class="st">"L2A"</span> <span class="co">' note A with length 1/2</span></span></code></pre></div>
<h3 id="example-2-play-multiple-notes">Example 2: Play multiple
notes</h3>
<div class="sourceCode" id="cb2"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">' Set volume to 50%</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">play</span> <span class="st">"V10"</span> </span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co">' Play Menuet by J. Sebastian Bach</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="fu">play</span> <span class="st">"T180L8O3MN O4D4O3MLGABO4C O4D4O3MNG4MLG4 O4MNE4MLCDEF# O4G4O3MNG4MLG4 O4MNC4MLDCO3BA O3MNB4MLO4CO3BAG O3MNA4MLBAGF# G2.MN"</span></span></code></pre></div>
<h3 id="example-3-play-notes-on-background">Example 3: Play notes on
background</h3>
<div class="sourceCode" id="cb3"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">play</span> <span class="st">"MBL2A"</span> <span class="co">' note A with length 1/2 on background</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">pause</span> <span class="co">' make sure, that program will not end</span></span></code></pre></div>
<h3 id="example-4-play-a-sound-file">Example 4: Play a sound file</h3>
<div class="sourceCode" id="cb4"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">' Copy a mp3 file to the working directory and name it test.mp3</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">play</span> <span class="st">"file://test.mp3"</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="kw">pause</span> <span class="co">' make sure, that program will not end</span></span></code></pre></div>
<div class="lavenderBox">
<div class="header">Code samples using PLAY</div>
<div class="linklist">
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/getting started/005 challenge.bas">005 challenge.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/2048.bas">2048.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/3d rotating cube with message.bas">3d rotating cube with message.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/3d wire cube v1.bas">3d wire cube v1.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/3d wire cube.bas">3d wire cube.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/3dtictac.bas">3dtictac.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/3dttt.bas">3dttt.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mobile/3dttt.bas">3dttt.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/4tune.bas">4tune.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/7gables.bas">7gables.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/utilities/agendus.bas">agendus.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/analog clock.bas">analog clock.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/anball 1.0.bas">anball 1.0.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mathematics/bairstow.bas">bairstow.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Misc Bpf/Balleta 2-11-15.bas">Balleta 2-11-15.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/betrayal: crows ii.bas">betrayal: crows ii.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/biorythms.bas">biorythms.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/blackbox.bas">blackbox.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/Blackbox.bas">Blackbox.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/blackjack.bas">blackjack.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/BlackJack.bas">BlackJack.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/bolmo.bas">bolmo.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/bonkers.bas">bonkers.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/bowling7.bas">bowling7.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 2/bplus paddleball.bas">bplus paddleball.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 2/btn 21.bas">btn 21.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/checkers.bas">checkers.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/chess.bas">chess.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/clock.bas">clock.bas </a>
</div>
</div>
<div class="lavenderBox">
<div class="header">Console</div>
<div class="linklist">
<a href="/reference/521.html">AT </a>
<a href="/reference/522.html">BEEP </a>
<a href="/reference/538.html">CAT </a>
<a href="/reference/524.html">CLS </a>
<a href="/reference/1015.html">DEFINEKEY </a>
<a href="/reference/525.html">FORM </a>
<a href="/reference/539.html">INKEY </a>
<a href="/reference/527.html">INPUT </a>
<a href="/reference/528.html">LINEINPUT </a>
<a href="/reference/529.html">LINPUT </a>
<a href="/reference/530.html">LOCATE </a>
<a href="/reference/531.html">LOGPRINT </a>
<a href="/reference/532.html">NOSOUND </a>
<a href="/reference/533.html">PEN </a>
<a href="/reference/534.html"><strong>PLAY</strong> </a>
<a href="/reference/535.html">PRINT </a>
<a href="/reference/536.html">SOUND </a>
<a href="/reference/540.html">TAB </a>
</div>
</div>
</div>
<div class="pagefooter">
This page was last edited on Fri, 15 Sep 2023 13:26:39 +0200
|
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
processed with
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.12.1</a>
</div>
</div>
</div>
</body>
</html>