User Tools

Site Tools


pausing_20and_20resuming_20midi_20playback

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

=====Pausing and resuming MIDI playback===== //by Richard Russell, May 2006//\\ \\ BBC BASIC for Windows allows you to play a MIDI file using the ***PLAY** command. Whilst you can terminate playback before the song has finished by using the **SOUND OFF** statement, there is no built-in mechanism for //pausing// playback.\\ \\ The program below makes it possible to pause and resume playback. For the purposes of the example a key-press is used, but the code can be adapted to control playback from any other source. For example in a game you may wish to pause the music whilst a high-score table is displayed.\\ \\ *PLAY C:\Windows\Media\Flourish.mid MCI_PLAY = &806 MCI_PAUSE = &809 PRINT "Press a key to pause and unpause..." pause% = FALSE REPEAT IF GET THEN pause% = NOT pause% IF pause% THEN PROCmcicommand(@midi%, MCI_PAUSE, 0, 0) PRINT "Paused" ELSE PROCmcicommand(@midi%, MCI_PLAY, 0, 0) PRINT "Resumed" ENDIF ENDIF UNTIL FALSE END DEF PROCmcicommand(D%, C%, F%, S%) LOCAL K%, M%, O%, P%, T% DIM P% LOCAL 50 [OPT 2 .K% push S%:push F%:push C%:push D%:call "mciSendCommand" ret 16 .M% cmp dword [esp+8],&500 : jz K% jmp [^O%] ] SWAP T%,@midi% SYS "GetWindowLong", @hwnd%, -4 TO O% SYS "SetWindowLong", @hwnd%, -4, M% SYS "SendMessage", @hwnd%, &500, 0, 0 SYS "SetWindowLong", @hwnd%, -4, O% SYS "SendMessage", @hwnd%, 0, 0 SWAP T%,@midi% ENDPROC You may need to change the MIDI file specification if your PC doesn't have **Flourish.mid** in that location.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
pausing_20and_20resuming_20midi_20playback.1522502373.txt.gz · Last modified: 2018/03/31 14:19 by 127.0.0.1