DirectSound.en.txt

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

Notes

Translation of DirectSound.txt to English.  Props to Doorknob for translating it.

Contents

☆☆☆ DirectSound System ☆☆☆ Starts WAVE file playback. Also applies to OGG files. ☆☆☆ DSINIT No Argument Return value (stat) Success:1 or DS_OK Failure:0 or DS_ERR Function 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. ☆☆☆ DSEND No Argument Return value (stat) 1 always comes back. Function Exits DirectSound. ☆☆☆ DSLOADFNAME p1, p2, p3, p4 Argument p1:File name p2:Buffer number(value from 0 to 1023) Default 0 p3:File seek position Default 0 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. Return value (stat) Success:1 or DS_OK Failure:0 or DS_ERR Function With a WAVE file name specified by p1, from p3 position, p2 buffer loads. Example)hmminit 1 ;Initializes DirectSound. dsloadfname "wave.wav", 10 ;Loads the start of a file in buffer 10. ☆☆☆ DSLOADFNAME2 p1, p2, p3, p4 Argument p1:File name p2:Seek position Default 0 p3:Buffer size Default 2 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. Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function To have a stream you want to playback specify a WAVE file name in p1 and from p2 position, 1024 buffer will be read. p3 determines how many seconds the stream buffer will create. To explain, in p3 it tells how many seconds a WAVE file will be segmented. Example)hmminit 1 fname = "stream.wav" ;This WAVE file is 5 minutes long. dsloadfname2 "stream.wav", 0, 4 ;Every 4 seconds reads buffer 1024. dsplay 1024 ;Playback. 1024 is an exclusively used stream buffer. ☆☆☆ DSLOADMEMORY p1, p2, p3 Argument p1:WAVE data p2:Buffer number(value from 0 to 1023) Default 0 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. Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function p1 WAVE data loads p2 buffer. Example)hmminit 1 fname = "wave.wav" exist fname wavesize = strsize sdim wavebuf, wavesize bload fname, wavebuf, wavesize dsloadmemory wavebuf, 0 ☆☆☆ DSOGGLOADFNAME p1, p2, p3 Argument p1:File name p2:Buffer number (value from 0 to 1023) Default 0 p3:Window when in active status playback flag  Default 0 Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function 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. 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. ☆☆☆ DSOGGLOADFNAMETHREAD p1, p2, p3 Argument p1:File name p2:Buffer name (value from 0 to 1023) Default 0 p3:Window when in active status playback flag  Default 0 Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function 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. 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. ☆☆☆ DSOGGLOADINGCHECK p1 Argument p1:Buffer number (value from 0 to 1023) Default 0 Function Buffer designated by p1 will check the status of OGG file during loading. Return value (stat) Loading:1 Finished loading:0 ☆☆☆ DSPLAY p1, p2 Argument p1:Buffer number (value from 0 to 1023) p2:Loop flag  Default 0 At 0 does not loop.   At 1 loops. Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Playbacks p1 buffer. Example)hmminit 1 dsloadfname "wave.wav", 0 dsplay 0 ☆☆☆ DSSTOP p1 Argument p1:Buffer number (value from 0 to 1024) Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Stops playback of p1 buffer. ☆☆☆ DSRELEASE p1 Argument p1:Buffer number (value from 0 to 1024) Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Releases p1 buffer. Wav files that won't be used twice will simply waste space in memory so disposing them would probably be safer. ☆☆☆ DSSETVOLUME p1, p2 Argument p1:Buffer number (0-1024) p2:Volume (0-100) At 0, volume is at its lowest.       At 100, volume is at its loudest. Return value (stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Changes volume level of p1 buffer. ☆☆☆ DSGETVOLUME p1 Argument p1:Buffer number (0-1024) Return value (stat) Returns the volume level. Function. Checks the volume of p1 buffer. ☆☆☆ DSSETMASTERVOLUME p1 Argument p1:Volume(0-100) Return value(stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Changes the WAVE master volume. ※With this changes volume and also by going through accessory -> entertainment -> the location of volume control for WAVE can be changed. ☆☆☆ DSGETMASTERVOLUME No Argument Return value(stat) Success:Acquired volume Failure:0 or DS_ERR ※Additionally at the time of failing, volume when at 0 will return to the same value so watch out for this. Function Acquires the WAVE master volume. ☆☆☆ DSSETMASTERFORMAT p1, p2, p3 Argument p1:Channel number p2:Sampling rate p3:Bit number Return value (stat) Success:1 or DS_OK Failure:0 or DS_ERR Function Assigns WAVE master volume. チャンネル数はステレオだったら2、モノラルだったら1 サンプリングレートは11.025kHzなら11025、22.05kHzなら22050、44.1kHzなら44100 1サンプルあたりのビット数、8か16 ちなみに初期設定は2,44100,16です。 で、何でこんなのがあるかというと、音質やCPUパワーなどに合わせて変更できるほうが便利だからです。 鳴らしたいwavファイルと基本音質の設定が違うとミキシングする時にCPUパワーを食いやすいです。 といってもそれほど気にするほどのものでもないと思います。 ☆☆☆ DSCHECKPLAY p1 Argument p1:Buffer number (0-1024) Return value(stat) During playback:1 or DS_OK Stop:0 or DS_ERR Function Checks if p1 buffer is being played back. Example) hmminit 1 dsloadfname "wave.wav", 0 dsplay 0 *@ await 10 dscheckplay 0 if stat == DS_OK : goto *@b dialog "Playback has stopped" end ☆☆☆ DSDUPLICATE p1, p2 Argument p1:Former copy buffer number (value from 0 to 1023) p2:Former copy buffer number (value from 0 to 1023) Return value (stat) Success:1 or DS_OK Failure:0 or DS_ERR Function コピー元バッファー番号と同じ状態のものを、コピー先バッファー番号につくります。 DIRECTSOUNDの仕様上、同じ音でも重ね合わせる場合は2個バッファーを作成しなければならないのです。 しかし、それはメモリの無駄なので1つのメモリで共有させることができます。 Example hmminit 1 dsloadfname "wave.wav", 0 dsduplicate 1, 0 dsplay 1 stop