开发者

play beep in silverlight

I a开发者_如何学编程m trying to make a small application for learning Morse code and I am stuck because I do not know how to play a Beep in Silverlight. How can I do something like?

Console.Beep(Freq, elementLength)

(I have made a console application that uses Console.Beep and it does not work very well (for 20word per minute the dot length is 60ms and the space between 2 signs is 180ms so for letter s witch is ... (3 dots) in my headphones I hear poc! not a clear sound)... I suppose the solution is to use DirectX/XNA) Can you please advise me how to make the application beep and if xna is the solution can you please direct me to a tutorial (I did not figure out what sdk I need to install and from where to download) Thank you


There is no direct "beep" in silverlight, that I'm aware. However, you have a plethora of sound capabilities; one of which is using the MediaElement control. So, you could add one of those to your page:

<MediaElement x:Name="beeper"></MediaElement>

Then in your code behind you can assign and call the sound:

private void AssignBeep()
{
  Uri beepUri = new Uri("Project;component/beep.mp3", UriKind.RelativeOrAbsolute);
  StreamResourceInfo streamInfo = Application.GetResourceStream(beepUri);
  this.beeper.SetSource(streamInfo.Stream);
  this.beeper.AutoPlay = false;
}

Then you can call it for a beep:

private void PlayBeep()
{
  this.beeper.Position = new TimeSpan(0,0,0,0);
  this.beeper.Volume = 1;
  this.beeper.Play();
}

Credits to forums.silverlight.net


Look at this.. i think this is what you need.. http://silversynth.codeplex.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜