Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#22847 - 21/11/2000 21:54 Windows Sound Programming Question
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
The reason I'm posting the question here is because I know for a fact that the Empeg folks have gotten this working for Emplode and I wanna know how they did it. So, question for the Empeg guys or anyone else who can answer:

I can use the Windows PlaySound API function to play (via alias) one of the system sounds that you find in the control panel. You know, things like "critical stop" and "exit windows" and "new mail notification". That's not a problem.

But as soon as I try to play a sound that's associated with an application, I get nothing. I can only seem to be able to play the windows default sounds.

For instance, I have no problem playing the Windows "Menu Popup" sound:
apiPlaySound "MenuPopup", Null, &H10000 Or &H1
But when I try to do the same thing for an application-specific sound such as the Emplode download success sound:
apiPlaySound "emplodeDownloadSuccess", Null, &H10000 Or &H1
it doesn't work.

(Note: I'm not talking about playing a .WAV file directly from the disk, that's easy. I need to know how to play an alias of a sound that the user defines in the control panel.)

I've tried several different values for the parameter, including these...
'Const SND_APPLICATION = &H80 ' look for application specific association
'Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
'Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier

to no avail...

What am I doing wrong? If I have to format the string to indicate the application also, what is the format? For example I've tried "emplode\emplodeDownloadSuccess" and "emplode:\emplodeDownloadSuccess" and those didn't work.

I dug through my MSDN library CD, and they only give examples of the stuff I can already do. Nowhere is an example given of playing an app-specific sound, only the Windows sounds.

So how is it done?

(PS: Code examples above are in VB format, but the same question applies regardless of the language since I'm just calling the Windows API directly here.)

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22848 - 22/11/2000 06:48 Re: Windows Sound Programming Question [Re: tfabris]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
PlaySound("emplodeDownloadFailure", NULL, SND_ASYNC | SND_NODEFAULT | SND_APPLICATION | SND_ALIAS);

...works for emplode...



Roger - not necessarily speaking for empeg

_________________________
-- roger

Top
#22849 - 22/11/2000 09:19 Re: Windows Sound Programming Question [Re: Roger]
schofiel
carpal tunnel

Registered: 25/06/1999
Posts: 2993
Loc: Wareham, Dorset, UK
While you're at it, Roger...

How do you install a sound event into Windows for a given application?

One of the few remaining Mk1 owners... #00015
_________________________
One of the few remaining Mk1 owners... #00015

Top
#22850 - 22/11/2000 09:51 Re: Windows Sound Programming Question [Re: schofiel]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
How do you install a sound event into Windows for a given application?

There are two sets of registry keys you need to populate under HKEY_CURRENT_USER\AppEvents. A little poking around in Regedit will reveal the setup.

"EventLabels" is the raw list of all the names of all the individual events. Schemes\Apps contains those event labels grouped under the application names. Remember to set the "default" strings to the names you want to display in the control panel- the registry key names are the aliases. All the aliases on my system are one word with no spaces, I dunno if that's required, but that's the way I do it, then I put the spaces in the display names.

Beneath the Apps/MyApp/MyAlias key are the keys holding the actual sounds settings, with ".current" and ".default" keys for each (some don't have a ".default" meaning that the default is no sound at all).

Note that there is an app named ".default", that's the Windows sounds. Beneath that is also an alias named ".default", that's the windows default "ding" sound.

Okay, I'm off to try what Roger just showed me and see if I can make it work for my app. Wish me luck.

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22851 - 22/11/2000 11:49 Re: Windows Sound Programming Question [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Argh, I must be doing something wrong. I can't get it to work at all. I tried those values for the flags and they didn't work. I tried about a billion different permutations, too. As soon as I try to do an app-specific value, it doesn't work. I can play the Windows sounds till the cows come home, just not app-specific sounds.

There is one thing. I'm depending on a file called WIN32API.TXT that ships with VB6 to gather the values for those constants. It's possible that the file is in error and I'm passing a wrong parameter. It wouldn't be the first time that Microsoft's documentation was wrong.

By my calculations, SND_ASYNC | SND_NODEFAULT | SND_APPLICATION | SND_ALIAS should come out to 10083 hex which is 65667 decimal. Is there any way you can check that and make sure I've got it correct?

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22852 - 22/11/2000 12:18 Re: Windows Sound Programming Question [Re: tfabris]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
Yep, that lot comes out as 0x10083. So I don't know why it's not working for you.



Roger - not necessarily speaking for empeg
_________________________
-- roger

Top
#22853 - 22/11/2000 12:43 Re: Windows Sound Programming Question [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yep, that lot comes out as 0x10083. So I don't know why it's not working for you.

Hmm. Interesting. I suspected that I might be doing something wrong in VB, but then for the heck of it I compiled this C code...

#include "stdio.h"
#include "windows.h"
#include "mmsystem.h"
int main(int argc, char *argv[])
{
PlaySound("emplodeDownloadFailure", NULL, SND_ASYNC | SND_NODEFAULT | SND_APPLICATION | SND_ALIAS);
return 0;
}


And I still get no sound when I run that program. And yes, I checked to make sure that there was a sound assigned to Emplode Download Failed in Control Panel, and tested the sound.

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22854 - 22/11/2000 15:49 Re: Windows Sound Programming Question [Re: tfabris]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5914
Loc: Wivenhoe, Essex, UK
I know it doesn't help much, but I have just tried the same thing and couldn't get any joy out of it either Tony.

__
Unit serial number 47 (was 330 in the queue)...
_________________________
Remind me to change my signature to something more interesting someday

Top
#22855 - 23/11/2000 12:14 Re: Windows Sound Programming Question [Re: tfabris]
Wire
member

Registered: 11/09/2000
Posts: 143
Loc: Jylland, Denmark
Hi Tony,

This is just a wild guess, but wouldn't it seem that your application should be named "emplode.exe" for this stuff to work?

Also http://www.vbapi.com/ref/p/playsound.html mentions some alternate declarations for Visual Basic.

They are application events, not system wide events.

Just my $0.02 (or less) worth.



Lars
_________________________
Lars MkII 40gig 090000598

Top
#22856 - 23/11/2000 13:10 Re: Windows Sound Programming Question [Re: Wire]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
This is just a wild guess, but wouldn't it seem that your application should be named "emplode.exe" for this stuff to work?

Well, I've tried it, both with calling a named-the-same-as-my-exe application key, and also by calling other application's keys, and I get no results either way. If that was a restriction, then why doesn't it say so in the documentation for the PlaySound function?

The web page you linked gives no more information on the subject than MSDN does. There are no specific pieces of documentation stating how to trigger items in the appevents/schemes/apps tree. Anywhere. Not in MSDN, not at any of the code sites on the internet, not on Usenet, nowhere. I can't find diddly-squat on the subject. But There are hundreds of apps that make it work just fine and I don't know why mine can't. It's very frustrating.

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22857 - 24/11/2000 17:04 Re: Windows Sound Programming Question [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Well, I was never able to get the PlaySound function to work exactly the way I wanted it to. Thanks for everyone's help and advice, but I implemented a work-around.

My solution was to cheap out. I set up the registry entries so that my application's sounds appear in the Control Panel and can be edited there. But under the hood, when my app makes one of those sounds, it simply reads those entries and physically plays the .wav directly from the file.

So, from an end-user perspective, it works the same way, I just couldn't tell PlaySound to play the event itself, I had to locate the file that the event points to and tell PlaySound to play the file.

I actually have the app working, and I've been using it regularly. I've just recently added features that might make it ready for public consumption. Does anyone want to test it for me and give me feeback?

Here's a description of the app:

I call it PageChecker. It's a system tray icon that reloads a web page over and over again at specified intervals. When the web page has new content, it blinks at you and plays a wav file.

For instance, I run two instances of PageChecker on my system, one to monitor my web-based email account, and another to monitor the Empeg BBS.

Why do I use it to check my mail? Because at work, I'm behind a firewall and can't check my mail using SMTP and POP3 protocols because they're blocked. So I have PageChecker log into my ISP's webmail interface with this tool.

PageChecker also has a built-in web browser (using the web browser DLL that comes with Internet Explorer), so I don't have to launch a copy of IE or Netscape if I want to quickly reply to one of the messages.

You could, theoretically, also use it to check news pages or weather pages (within certain restrictions). Or if there were an FTP site that you wanted to check for new files, I think you could even do that as well. I can remember days when I was awaiting certain game demos and I'd sit there mashing the "reload" button until the file appeared. This utility will essentially do that for you if you want.

I'm a little leery about publishing this app, though, because of its very nature. Its job is to hammer a web site with queries. Some site admins would frown upon that. I dunno how to resolve that...

If anyone wants to try out this app and give me feedback, let me know and I'll e-mail you the first version. After I get some feedback, I'll probably put it up on my home page for the public.

___________
Tony Fabris
_________________________
Tony Fabris

Top
#22858 - 28/11/2000 07:12 Re: Windows Sound Programming Question [Re: tfabris]
schofiel
carpal tunnel

Registered: 25/06/1999
Posts: 2993
Loc: Wareham, Dorset, UK
Good luck - and thanks for the info, that was just what was needed.

One of the few remaining Mk1 owners... #00015
_________________________
One of the few remaining Mk1 owners... #00015

Top
#22859 - 29/11/2000 08:25 Re: Windows Sound Programming Question [Re: tfabris]
Dearing
addict

Registered: 22/07/1999
Posts: 453
Loc: Florida
and another to monitor the Empeg BBS
So That's how he always has the first reply to everything!


_~= Dearing =~_
"WAY too happy about having #99."
_________________________
_~= Dearing =~_
Gettin' back into it thanks to slimrio!

Top