Beep() once again

  • Thread starter Thread starter Rudolf Ziegaus
  • Start date Start date
R

Rudolf Ziegaus

Is it still true, that there is no support for a Beep()-method in the
compactframework? I thought that this feature would have come with .NET
2.0.

Well then, what's the best way to achieve this? I am trying so write a
small metronome application and would like to be able to

o choose between different frequencies (e. g. the first click should have a
different frequency that the others)
o modify duration - well this is an optional feature but would be nice.

Is the only way to achieve this playing wave files? Or is there a better
solution. I am a bit concerned about speed.

When I have a song with say 180 bpm (beats per minute), I need to play 3
beeps per second (duration e. g. 100 ms). The remaining time of 700 ms then
is used to create an audible gap between the clicks.

Now the questions is if playing wave files will be accurate enough for my
purpose.

What do you think? What options are there available for my problem?

Thanks for any hints,

Rudi
 
I use this to play system sounds....

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Eden.Windows.Media
{
public enum SystemSound
{
Asterisk, Beep, Exclamation, Hand, Question
}

public static class SoundPlayer
{
[Flags]
private enum PlaySoundFlags
{
SND_ALIAS = 0x10000,
SND_FILENAME = 0x20000,
SND_RESOURCE = 0x40004,
SND_SYNC = 0x0,
SND_ASYNC = 0x1,
SND_NODEFAULT = 0x2,
SND_MEMORY = 0x4,
SND_LOOP = 0x8,
SND_NOSTOP = 0x10,
SND_NOWAIT = 0x2000,
SND_VALIDFLAGS = 0x17201F,
SND_TYPE_MASK = 0x170007
}

[DllImport("CoreDll.dll")]
private static extern int PlaySound(string fileName, IntPtr handle,
PlaySoundFlags flags);

public static void PlaySystemSound(SystemSound systemSound)
{
switch (systemSound)
{
case SystemSound.Asterisk:
PlaySound("SystemAsterisk", IntPtr.Zero, PlaySoundFlags.SND_SYNC);
break;

case SystemSound.Beep:
PlaySound("SystemBeep", IntPtr.Zero, PlaySoundFlags.SND_SYNC);
break;

case SystemSound.Exclamation:
PlaySound("SystemExclamation", IntPtr.Zero, PlaySoundFlags.SND_SYNC);
break;

case SystemSound.Hand:
PlaySound("SystemExclamation", IntPtr.Zero, PlaySoundFlags.SND_SYNC);
break;

case SystemSound.Question:
PlaySound("SystemQuestion", IntPtr.Zero, PlaySoundFlags.SND_SYNC);
break;

default:
throw new ArgumentException("Unknown system sound: " +
systemSound.ToString());
}//switch systemSound
}
}
}


You could put a beep.wav onto your PPC and pass the filename to that.


Pete
 
Since CE doesn't support beeps like XP does, (possibly becasue non x86
processors don't have simple way to achieve this) it's no surprise that the
CF doesn't support it. I'm pretty sure CF 3.0 won't have it either - it's
just not simple to do, and the payback is tiny.
 
Back
Top