Wiki source code of DirectSound.en.txt

Last modified by John Stroy on 2012/06/24 09:45

Show last authors
1 = Notes =
2
3 Translation of [[DirectSound\.txt]] to English. Props to Doorknob for translating it.
4
5 = Contents =
6
7 ##{{{☆☆☆ DirectSound System ☆☆☆
8 Starts WAVE file playback.
9 Also applies to OGG files.
10
11 ☆☆☆
12 DSINIT No Argument
13
14 Return value (stat)
15 Success:1 or DS_OK
16 Failure:0 or DS_ERR
17
18 Function
19 Initializes (also has a double meaning to format, choose whichever fits better) DirectSound. If initialized through HMMINIT there is no need to use this. When you clearly want to initialize call this function.
20
21
22 ☆☆☆
23 DSEND No Argument
24
25 Return value (stat)
26 1 always comes back.
27
28 Function
29 Exits DirectSound.
30
31
32 ☆☆☆
33 DSLOADFNAME p1, p2, p3, p4
34
35 Argument
36 p1:File name
37 p2:Buffer number(value from 0 to 1023) Default 0
38 p3:File seek position Default 0
39 If p4 is set at 0 when a window is not active it makes it so that sound also becomes inactive. When set at 1 sound will play regardless of the condition of a window.
40
41 Return value (stat)
42 Success:1 or DS_OK
43 Failure:0 or DS_ERR
44
45 Function
46 With a WAVE file name specified by p1, from p3 position, p2 buffer loads.
47
48 Example)hmminit 1 ;Initializes DirectSound.
49 dsloadfname "wave.wav", 10 ;Loads the start of a file in buffer 10.
50
51
52 ☆☆☆
53 DSLOADFNAME2 p1, p2, p3, p4
54
55 Argument
56 p1:File name
57 p2:Seek position Default 0
58 p3:Buffer size Default 2
59 If p4 is set at 0 when a window is not active it makes it so that sound also becomes inactive. When set at 1 sound will play regardless of the condition of a window.
60
61 Return value(stat)
62 Success:1 or DS_OK
63 Failure:0 or DS_ERR
64
65 Function
66 To have a stream you want to playback specify a WAVE file name in p1 and from p2 position, 1024 buffer will be read.
67 p3 determines how many seconds the stream buffer will create.
68 To explain, in p3 it tells how many seconds a WAVE file will be segmented.
69
70 Example)hmminit 1
71 fname = "stream.wav" ;This WAVE file is 5 minutes long.
72 dsloadfname2 "stream.wav", 0, 4 ;Every 4 seconds reads buffer 1024.
73 dsplay 1024 ;Playback. 1024 is an exclusively used stream buffer.
74
75
76 ☆☆☆
77 DSLOADMEMORY p1, p2, p3
78
79 Argument
80 p1:WAVE data
81 p2:Buffer number(value from 0 to 1023) Default 0
82 If p4 is set at 0 when a window is not active it makes it so that sound also becomes inactive. When set at 1 sound will play regardless of the condition of a window.
83
84 Return value(stat)
85 Success:1 or DS_OK
86 Failure:0 or DS_ERR
87
88 Function
89 p1 WAVE data loads p2 buffer.
90
91 Example)hmminit 1
92 fname = "wave.wav"
93 exist fname
94 wavesize = strsize
95 sdim wavebuf, wavesize
96 bload fname, wavebuf, wavesize
97 dsloadmemory wavebuf, 0
98
99 ☆☆☆
100 DSOGGLOADFNAME p1, p2, p3
101
102 Argument
103 p1:File name
104 p2:Buffer number (value from 0 to 1023) Default 0
105 p3:Window when in active status playback flag  Default 0
106
107 Return value(stat)
108 Success:1 or DS_OK
109 Failure:0 or DS_ERR
110
111 Function
112 With OGG file name assigned by p1, reads p2 buffer. If p3 is set at 0 when a window is not active it makes it so that sound also becomes inactive. When set at 1 sound will play regardless of the condition of a window. Playback is possible using the DSPLAY instruction.
113
114 Until this instruction has finished loading, it will not advance to the next instruction. When playing back large files, during real time screen update it may have a harmful effect and so in replacement to this instruction, it may be better to use DSOGGLOADFNAMETHREAD instruction instead.
115
116
117 ☆☆☆
118 DSOGGLOADFNAMETHREAD p1, p2, p3
119
120 Argument
121 p1:File name
122 p2:Buffer name (value from 0 to 1023) Default 0
123 p3:Window when in active status playback flag  Default 0
124
125 Return value(stat)
126 Success:1 or DS_OK
127 Failure:0 or DS_ERR
128
129 Function
130 With OGG file name assigned by p1, reads p2 buffer. If p3 is set at 0 when a window is not active it makes it so that sound also becomes inactive. When set at 1 sound will play regardless of the condition of a window. Playback is possible using the DSPLAY instruction.
131
132 This instruction regardless of whether the loading has finished or not, advances to the next instruction immediately. If you want to check whether or not loading has been completed, use the DSOGGLOADINGCHECK instruction.
133
134
135 ☆☆☆
136 DSOGGLOADINGCHECK p1
137
138 Argument
139 p1:Buffer number (value from 0 to 1023) Default 0
140
141 Function
142 Buffer designated by p1 will check the status of OGG file during loading.
143
144 Return value (stat)
145 Loading:1
146 Finished loading:0
147
148
149 ☆☆☆
150 DSPLAY p1, p2
151
152 Argument
153 p1:Buffer number (value from 0 to 1023)
154 p2:Loop flag  Default 0
155 At 0 does not loop.
156   At 1 loops.
157
158 Return value(stat)
159 Success:1 or DS_OK
160 Failure:0 or DS_ERR
161
162 Function
163 Playbacks p1 buffer.
164
165 Example)hmminit 1
166 dsloadfname "wave.wav", 0
167 dsplay 0
168
169
170 ☆☆☆
171 DSSTOP p1
172
173 Argument
174 p1:Buffer number (value from 0 to 1024)
175
176 Return value(stat)
177 Success:1 or DS_OK
178 Failure:0 or DS_ERR
179
180 Function
181 Stops playback of p1 buffer.
182
183
184 ☆☆☆
185 DSRELEASE p1
186
187 Argument
188 p1:Buffer number (value from 0 to 1024)
189
190 Return value(stat)
191 Success:1 or DS_OK
192 Failure:0 or DS_ERR
193
194 Function
195 Releases p1 buffer.
196 Wav files that won't be used twice will simply waste space in memory so disposing them would probably be safer.
197
198
199 ☆☆☆
200 DSSETVOLUME p1, p2
201
202 Argument
203 p1:Buffer number (0-1024)
204 p2:Volume (0-100)
205 At 0, volume is at its lowest.
206       At 100, volume is at its loudest.
207
208 Return value (stat)
209 Success:1 or DS_OK
210 Failure:0 or DS_ERR
211
212 Function
213 Changes volume level of p1 buffer.
214
215
216 ☆☆☆
217 DSGETVOLUME p1
218
219 Argument
220 p1:Buffer number (0-1024)
221
222 Return value (stat)
223 Returns the volume level.
224
225 Function.
226 Checks the volume of p1 buffer.
227
228
229 ☆☆☆
230 DSSETMASTERVOLUME p1
231
232 Argument
233 p1:Volume(0-100)
234
235 Return value(stat)
236 Success:1 or DS_OK
237 Failure:0 or DS_ERR
238
239 Function
240 Changes the WAVE master volume.
241 ※With this changes volume and also by going through accessory -> entertainment -> the location of volume control for WAVE can be changed.
242
243
244 ☆☆☆
245 DSGETMASTERVOLUME No Argument
246
247 Return value(stat)
248 Success:Acquired volume
249 Failure:0 or DS_ERR
250 ※Additionally at the time of failing, volume when at 0 will return to the same value so watch out for this.
251
252 Function
253 Acquires the WAVE master volume.
254
255
256 ☆☆☆
257 DSSETMASTERFORMAT p1, p2, p3
258
259 Argument
260 p1:Channel number
261 p2:Sampling rate
262 p3:Bit number
263
264 Return value (stat)
265 Success:1 or DS_OK
266 Failure:0 or DS_ERR
267
268 Function
269 Assigns WAVE master volume.
270 チャンネル数はステレオだったら2、モノラルだったら1
271 サンプリングレートは11.025kHzなら11025、22.05kHzなら22050、44.1kHzなら44100
272 1サンプルあたりのビット数、8か16
273 ちなみに初期設定は2,44100,16です。
274 で、何でこんなのがあるかというと、音質やCPUパワーなどに合わせて変更できるほうが便利だからです。
275 鳴らしたいwavファイルと基本音質の設定が違うとミキシングする時にCPUパワーを食いやすいです。
276 といってもそれほど気にするほどのものでもないと思います。
277
278
279 ☆☆☆
280 DSCHECKPLAY p1
281
282 Argument
283 p1:Buffer number (0-1024)
284
285 Return value(stat)
286 During playback:1 or DS_OK
287 Stop:0 or DS_ERR
288
289 Function
290 Checks if p1 buffer is being played back.
291
292 Example)
293 hmminit 1
294 dsloadfname "wave.wav", 0
295 dsplay 0
296
297 *@
298 await 10
299 dscheckplay 0
300 if stat == DS_OK : goto *@b
301
302 dialog "Playback has stopped"
303 end
304
305
306 ☆☆☆
307 DSDUPLICATE p1, p2
308
309 Argument
310 p1:Former copy buffer number (value from 0 to 1023)
311 p2:Former copy buffer number (value from 0 to 1023)
312
313 Return value (stat)
314 Success:1 or DS_OK
315 Failure:0 or DS_ERR
316
317 Function
318 コピー元バッファー番号と同じ状態のものを、コピー先バッファー番号につくります。
319 DIRECTSOUNDの仕様上、同じ音でも重ね合わせる場合は2個バッファーを作成しなければならないのです。
320 しかし、それはメモリの無駄なので1つのメモリで共有させることができます。
321
322 Example
323 hmminit 1
324 dsloadfname "wave.wav", 0
325 dsduplicate 1, 0
326 dsplay 1
327 stop
328 }}}##