Catch up on stories from the past week (and beyond) at the Slashdot story archive

typodupeerror
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! × ## Play Random Sounds for E-Mail Notifications?156 An anonymous reader asks: "I, like many of my fellow Outlook-using geek friends, like to set funny sounds to be played when a new message arrives ('Leeroy Jenkins' is the one I have set now). However, we have always wanted to be able to have random sounds be played when a new message arrives, rather than the same sound over and over. I've searched high and low, and I was hoping Slashdot could suggest/write a program that can randomly play sound files from a specified folder when a new message arrives. Any ideas?" This discussion has been archived. No new comments can be posted. #### Play Random Sounds for E-Mail Notifications? More Login ## Play Random Sounds for E-Mail Notifications? Comments Filter: • #### Random sounds? (Score:5, Insightful) by Anonymous Coward on Tuesday July 19, 2005 @07:18PM (#13108651) Is this what Ask Slashdot has boiled down to - asking about playing random sounds when email arrives? There's gotta be better material to pick from than this. • #### let's get this out of the way. took me 3 mins. (Score:3, Informative) #!/bin/sh # updates the sound list path=$1

find $path -name "*.[Oo][Oo][Gg]" -print > soundlist.txt find$path -name "*.[Mm][Pp][3]" -print >> soundlist.txt
find $path -name "*.[Ww][Aa][Vv]" -print >> soundlist.txt find$path -name "*.[Ff][Ll][Aa][Cc]" -print >> soundlist.txt
find $path -name "*.[Aa][Ii][Ff][Ff]" -print >> soundlist.txt #!/bin/sh # play random file from filelist filelist=$1

• #### Re:Ooh! What a great idea! (Score:1)

You should add my firewall sound effects program too. (I don't have a random option, but with all the crud coming in from the Internet, and a different sound for each port, that's almost as good.)
• #### Re:Ooh! What a great idea! (Score:1)

A different sound for each port? Why not just a speak-and-spell-style (or even concatenated prerecorded digits) voice synth that reads off the port number?
• #### Score; -5 Banal (Score:2, Funny)

by Anonymous Coward
I thought I had seen it all but, this is BY FAR the lamest Ask Slashdot I have ever seen. The Article needs to be moderated -5 Banal.

How to rotate notification sounds? In Microsoft Outlook?? On Slashdot????

Dear Slashdot, how can I cause this person to receive a severe electric shock everytime a new message arrives in his Outlook inbox?
• #### Re:Score; -5 Banal (Score:2)

If I had the time, I'd write a script that would take a random file from his \windows directory, substitute a .wav file extension for the existing one and play it. That would be plenty random.
• #### Perl... (Score:4, Informative)

on Tuesday July 19, 2005 @07:46PM (#13108907)
#!/usr/bin/perl
$SOUNDDIR="/usr/share/sounds";$ DESTFILE="/tmp/sound.wav";
opendir(DIR,$SOUNDDIR) || die "Can't open$SOUNDDIR: $!\n";$count=0;
while(defined($file = readdir(DIR))) { if($file =~ /\.wav$/) {$files[$count]=$file;
$count++; } }$arraysize=@files;
while(1) {
$rnd=int(rand($arraysize));
$filename=$files[$rnd]; cp$SOUNDDIR/$filename$DESTFILE;
sleep 10;
}

Mangle appropriately (source dir, sleep time, dest file, file-type).

Have fun.

Red.
• #### Re:Perl... (Score:2)

Since you're on MS, you'll probably want to:
* Install activestate perl
* Use appropriate MS compatible directories (c:\path\to\somewhere rather than /usr/share/sounds)
* swap out the cp ... for copy ... .. probably worth chucking a closedir in there somewhere too.

Bah, ahh well - can't expect much for 20 seconds of coding and no debugging I guess.

Red.
• #### Re:Perl... (Score:1)

perl for windows accepts path with "/" ias wall as "\" . Also use File::Copy and don't shell out to copy a file .
• #### Re:Perl... (Score:2)

Nice.

#!/usr/bin/perl
$SOUNDDIR="/usr/share/sounds"; opendir(DIR,$SOUNDDIR) || die "Can't open $SOUNDDIR:$!\n";

$count=0; while(defined($file = readdir(DIR))) {
if($file =~ /\.wav$/) {
$files[$count]=$file;$count++;
}
}

$arraysize=@files;$rnd=int(rand($arraysize));$filename=$files[$r nd];
• #### Outlook-using geek (Score:1, Troll)

Outlook-using geek

That's it. Turn in your fucking geek card. Now. There's the door. Get going and don't ever come back here.
• #### Are you ready? (Score:2)

Do already have the sounds lined up? Lots of Locutus quotes, Ballmer's "Developers^3" quote, a few Brain "Take over the World" quotes, and you should be perfectly prepared.
• #### You can do this with VBScript (Score:2)

Write a script that gets triggered by file access events for the wave file Outlook is looking at. Every time that event happens, have it wait fifteen seconds, then overwrite the file with a randomly-selected one from a directory tree that contains wav files.

Bonus points for having it read the config information out of the registry and/or an ini file.
• #### Wow (Score:3, Insightful)

on Tuesday July 19, 2005 @07:53PM (#13108977)
Without trying to disrespect the submitter, I can't believe this is a Ask Slashdot topic. Certainly this would have been better answered on a Windows related forum.
• #### No Problem (Score:4, Funny)

on Tuesday July 19, 2005 @08:25PM (#13109271)
Be glad to help - just give me your e-mail address and I'll send you over an executable. I'll even be so nice as to include an MD5 hash so you know its secure.

• #### Try a free program (Score:5, Funny)

on Tuesday July 19, 2005 @08:28PM (#13109292)
from Claria [claria.com]. Nothing makes a Windows PC do random shit faster.
• #### ... Use the Macros (Score:4, Interesting)

on Tuesday July 19, 2005 @09:04PM (#13109544) Homepage
In Outlook, press ALT-F11

Create a rule for receiving emails - to play your Macro.

Bonus point.
Make your macro play a random sound.

I think the whole effort should take about 5 minutes.
• #### Re:... Use the Macros (Score:2, Funny)

Surely that's ALT-F4?
• #### MOD PARENT UP!!! (Score:2)

Holy shit. A useful answer. This actually works.
• #### This is better than the Ask Slashdot I submitted.. (Score:5, Funny)

on Tuesday July 19, 2005 @09:09PM (#13109565)
This is better than the Ask Slashdot I submitted, where I wanted to find out a way for thunderbird to play a random sound every time my RSS feed picks up a new Slashdot story.

I settled for comic book guy saying "Worst. Slashdot. Story. EVER."

Surprisingly its true every time!
• #### Random audio files in Outlook 2002 for dummies (Score:5, Informative)

on Tuesday July 19, 2005 @09:41PM (#13109753)
1. Write a simple application/script that plays a random sound file
- Read directory and store files in a list/array
- Use a random function to pick a wav file
- Load and play the selected audio file

2. Disable e-mail sound notifications (Tools->Options->Email options->Advanced email options->uncheck 'play a sound'

3. Set up a rule for incoming email: (Tools->Rules wizard->New.
Start from a blank rule. Check messages when they arrive (next).
(Next) and confirm to apply to all rules.
Check 'start application'. Click the underlined 'application'. Choose your custom app (open).
(next)(next).
Name the rule 'sound script'
(finish)(ok).

To prevent your script from playing sounds for every email received, put a delay counter on it to prevent multiple instances of the same application, or some form of lock preventing concurrent running.
• #### Re:Random audio files in Outlook 2002 for dummies (Score:2)

Oh man, first I have to hand back my geek card because I am also an Outlook using geek, and now I realise that I didn't think of this way of doing it, so I have to hand back my MCSE.

I mean, can't you leave me with some shreds of dignity?

Alright, heres my last suggestion, get your colleagues and friends to record a mail notification for you, and attach it to Outlook (via the rules wizard) to play that notification when that person sends you a greeting.
• #### VBA for Outlook (Score:2)

One way is to use VBA. I don't have much experience with it. All I've ever done is make a quick thing that would page me when the 15-minute notification for meetings came up. If you go to Tools -> Macros -> Visual Basic Editor, the help file in that is very useful, specifically the information on the NewMail event. It won't explain exactly how to do it (and I don't know enougrh to explain how here), but it should go a long way to helping out.
• #### Why just random? (Score:1)

Why not vary the sound depending on the amount of email arriving? With a Ferris Bueller theme, a short note would be a small cough, up to a load of spam and several Powerpoint presentations which would sound like someone coughing up a lung and a face-hugger or two.

Since my new mail sound is currently a Klingon yellow alert, each email could be a hit on the shields, which slowly regenerate. Too much email in a short period would start a warp-core breach warning followed a huge explosion. Real fans could in

• #### Poly MacBeep (Score:1)

Ah, Poly MacBeep
You always were so much fun
Windows needs you now
• #### duh (Score:2)

just play a file called "email_sound.wav", then have a cron job symbolically link a random sound to it every minute.
• #### Skip the boing old alert sound - go festival (Score:3, Interesting)

on Wednesday July 20, 2005 @01:00AM (#13110809) Homepage
I used to have alert sounds on my email system, but it got really tedious, because I get lots of mail and most of it can wait, while some of it is important enough that I must look at it there and then (think important clients, not so important clients) - every time the alert went off, I'd have to stop what I was doing, go to the mail software, check to see what the message was and if it was important enough to deal with there and then.

So anyway I had a bit of a brainwave one day - I hooked up festival (the voice synthesis software) to Evolution (my preferred mail client) and now instead of non-informational alert sounds I have festival read out-loud the sender and subject.

It's probably the best thing since sliced bread as far as I'm concerned (I've had it like this for, umm, about a year I guess, and it's still very cool). Now when an email comes in I don't have to stop what I'm doing, I know if it's important enough to go look at because my PC tells me :)

Even better..like all good geeks I have my PC running 24/7 a couple of meters from my bed (and like all good geeks I'm the only one in my bed), so no more do I have to get up and go see what the email was if I'm in bed :) Strangely enough I find I often sort of half-wake up in time to hear the subject being read to me even in the middle of the night (perhaps the hard drive churning before as fest starts up etc wakes me slightly).

Most useful thing... ever. Perhaps I should patent it ;)
• #### Here is the code (Score:3, Informative)

on Wednesday July 20, 2005 @01:05AM (#13110841)
Step 1 - Lower your macro security.

Step 2 - Close Outlook and restart Outlook.

Step 3 - Open up the Visual Basic editor.

Step 4 - Add this in the code session of "ThisOutLookSession".

Step 5 - Reformat the thing. I spent more time trying get it through the Slashdot filters than writing it.

Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Function GetAllFilesInDir(ByVal strDirPath As String) As Variant ' Loop through the directory specified in strDirPath and save each ' file name in an array, then return that array to the calling ' procedure. ' Return False if strDirPath is not a valid directory. Dim strTempName As String Dim varFiles() As Variant Dim lngFileCount As Long On Error GoTo GetAllFiles_Err ' Make sure that strDirPath ends with a "\" character. If Right\$(strDirPath, 1) "\" Then strDirPath = strDirPath & "\" End If ' Make sure strDirPath is a directory. If GetAttr(strDirPath) = vbDirectory Then strTempName = Dir(strDirPath, vbDirectory) Do Until Len(strTempName) = 0 ' Exclude ".", "..". If (strTempName ".") And (strTempName "..") Then ' Make sure we do not have a sub-directory name. If (GetAttr(strDirPath & strTempName) _ And vbDirectory) vbDirectory Then ' Increase the size of the array ' to accommodate the found filename ' and add the filename to the array. ReDim Preserve varFiles(lngFileCount) varFiles(lngFileCount) = strTempName lngFileCount = lngFileCount + 1 End If End If ' Use the Dir function to find the next filename. strTempName = Dir() Loop ' Return the array of found files. GetAllFilesInDir = varFiles End If GetAllFiles_End: Exit Function GetAllFiles_Err: GetAllFilesInDir = False Resume GetAllFiles_End End Function Private Sub Application_NewMail() Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 Dim varFileArray As Variant Dim lngI As Long Dim strDirName As String Const NO_FILES_IN_DIR As Long = 9 Const INVALID_DIR As Long = 13 On Error GoTo Test_Err strDirName = "C:\windows\media" varFileArray = GetAllFilesInDir(strDirName) For lngI = 0 To UBound(varFileArray) Debug.Print varFileArray(lngI) Next lngI lngI = Math.Round(Math.Rnd() * UBound(varFileArray)) WAVFile = "C:\windows\media\" & varFileArray(lngI) Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) Test_Err: Select Case Err.Number Case NO_FILES_IN_DIR MsgBox "The directory named '" & strDirName _ & "' contains no files." Case INVALID_DIR MsgBox "'" & strDirName & "' is not a valid directory." Case 0 Case Else MsgBox "Error #" & Err.Number & " - " & Err.Description End Select End Sub

Step 6 - Ignore all replies to this post. They are all the same Microsoft bashing crap you've already read 1000 times on /.

Step 7 - If you think this is some kind of virus learn to code and then you can check it yourself.

Step 8 - Fix the API call. It is too slow.
• #### Named pipe. (Score:1)

Just create a named pipe connected to an app that spits out a random wave file on access.

Oh, right, you can't do that and use Outlook at the same time.