using wav files in macros, too

4 views
Skip to first unread message

Larry

unread,
Nov 15, 2009, 5:45:48 PM11/15/09
to GoogleSemWare TSE, TsePro
/***
This macro is derived from Carlo Hogeveen's macro, type.s.

This is a macro that demostrates how wav files might be used at
locations in a macro to inform the user about what is happening at that
point in the macro.

When executed, what the macro actually does is to intercept input from
the keyboard, evaluate it, and play a wav file according to what is
captured from the keyboard.

For safety's sake, the macro does not actually allow the keystrokes to
be acted on as normal keystrokes. I.e., if you press an 'a', you get a
sound but not an 'a', and so on.

As with Carlo's type.s, the macro will play a wav file if certain
conditions are met in the macro operation. In this macro, the only
exceptional tested values are the cursor keys, and the other keys simply
play the type.wav file as with Carlo's macro.

A message bar shows how to end the macro (with the ESC key).

The wav files used here were searched for and found on the internet, but
could be any wav files of choice. Like Carlo's, any wav files you use
should be located in TSE's \mac\ directory. (The wav files used here are
attached to this message.)

I may or may not use this strategy for my own macros, but it is nice to
know that it is available! :) Thanks, Carlo!!!

(Disclaimer: I have no idea what the DLL deal does or how to access
it...I take it on faith-in-Carlo that HE at least knows what he is
doing. :))

Save/Compile Date-:> 2009 11 15 @ 3:47 pm

{This Revision:}
1002- 2009 11 15 @ 3:47 pm- safe save
1001- 2009 11 15 @ 3:16 pm- rearrange Carlo Hogeveen's macro, type.s
***/

// the macro source starts here

// Carlo's mytery enabler
constant SND_ASYNC = 0x0001
constant SND_FILENAME = 0x00020000

dll "<winmm.dll>"

// play the wav
integer proc sysPlaySound(string fn:CStrVal,
integer hModule,
integer fuSound) : "PlaySound"
end

// set up the wav for playing
proc PlaySoundAsync(integer i)

string fn[_maxpath_]=""

// decide which wav to play
case i
when 1
fn="ouch2.wav"
when 2
fn="uh-oh-.wav"
when 3
fn="kerching.wav"
when 4
fn="attaboy.wav"
when 5
fn="type.wav"
when 6
fn="goodby.wav"
otherwise
fn="select.wav"
endcase

fn=loaddir()+"mac\"+fn

// play the wav
sysPlaySound(fn, 0, SND_FILENAME|SND_ASYNC)

end

proc Main()

integer a=0

// capture keystrokes and evaluate
repeat

message("Press: Quit:ESC, Sounds:Up Down Right Left, Click:anything else")

a=getkey()

// act on the key
case a
when <cursorup>
PlaySoundAsync(1)
when <cursordown>
PlaySoundAsync(2)
when <cursorright>
PlaySoundAsync(3)
when <cursorleft>
PlaySoundAsync(4)
when <escape> // end macro
goto ending
otherwise
PlaySoundAsync(5)
endcase

until a==<escape>

goto ending
ending:

PlaySoundAsync(6)

end

JigcarlowavRev1002.mac
uh-oh-.wav
JigcarlowavRev1002.s
attaboy.wav
goodby.wav
KERCHING.WAV
ouch2.wav
SELECT.WAV
TYPE.WAV
uh_oh.wav
Reply all
Reply to author
Forward
0 new messages