SilverlightShow: XNA for Silverlight developers: Part 8 - Music and sound effects Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Re: XNA for Silverlight developers: Part 8 - Music and sound effects <p>@rajib, please take a look at part 1 of the series; it explains content projects in detail:</p> <p><a href="http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-1-Fundamentals.aspx">http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-1-Fundamentals.aspx</a></p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment7287 MisterGoodcat http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Tue, 06 Dec 2011 09:20:16 GMT Re: XNA for Silverlight developers: Part 8 - Music and sound effects <span style="font-family: 'segoe ui', helvetica, arial, verdana, tahoma, sans-serif; font-size: 12px; line-height: 20px; background-color: #ffffff;"><em>"Sound effects, just like music, are imported into your game through the content project."</em></span> <p><span style="font-family: 'segoe ui', helvetica, arial, verdana, tahoma, sans-serif; font-size: 12px; line-height: 20px; background-color: #ffffff;">What is the content project and how do you import stuff through it?</span></p> <p><span style="font-family: 'segoe ui', helvetica, arial, verdana, tahoma, sans-serif; font-size: 12px; line-height: 20px; background-color: #ffffff;">Thanks,</span></p> <p><span style="font-family: 'segoe ui', helvetica, arial, verdana, tahoma, sans-serif; font-size: 12px; line-height: 20px; background-color: #ffffff;"><br /> </span></p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment7285 rajib http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Tue, 06 Dec 2011 06:18:49 GMT Re: XNA for Silverlight developers: Part 8 - Music and sound effects <p>Nice work on the article. I am recording input from the microphone on a windows phone 7 project and I would like to show some indication of the playback of the clip as it is playing. Think of what you would see in windows when testing a microphone where you see the levels change as you yell into the microphone. I have not seen any examples showing how perhaps a game loop would be able to see into the sound instance and tell me the intensity. Do you know of a way to get that information? Thanks.</p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment6285 StevenHook http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Sat, 11 Jun 2011 16:30:31 GMT RE: XNA for Silverlight developers: Part 8 - Music and sound effects <p>Ah, ok. I thought we were talking about XNA. For Silverlight, this is indeed different. When you import files through an XNA content project, the processing of the content pipeline ensures that the format is compatible to what the sound effect class expects. This stage of pre-processing obviously is missing when you use the XNA libraries from Silverlight, so you have to provide the input data in a supported format already. For the sound effect class, this is PCM wave. This restriction and more details about the supported parameters is listed here: <a href="http://msdn.microsoft.com/en-us/library/ff434104.aspx">http://msdn.microsoft.com/en-us/library/ff434104.aspx</a></p> <p>So in your case, you indeed have to convert your sound files to wav format first.</p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment5782 Peter Kuhn http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Sun, 27 Mar 2011 13:20:22 GMT RE: XNA for Silverlight developers: Part 8 - Music and sound effects <p>Hello Peter,</p> <p>Thanks a lot for your response. Here is some additional info about. I have a wp7 application (it is a <strong>Silverlight project, not XNA</strong>). And I wanna play sounds from the code-behind. Obviously the MediaElement control won't work for me in this case. That's why I ended up using the <em>SoundEffect</em> and <em>SoundEffectInstance </em>classes. I added a reference to the Microsoft.Xna.Framework.dll assembly and I have the following code:</p> <p>Stream stream = TitleContainer.OpenStream( "WindowsPhoneApplication1;component/Audio/MySound.wav" );<br> </br>SoundEffect soundEffect = SoundEffect.FromStream( stream );<br> </br>soundEffect.Name = "Test";<br> </br>SoundEffectInstance effectInstance = soundEffect.CreateInstance();<br> </br>effectInstance.Play();</p> <p>Everything works perfect when I play ".wav" files, but for any other format it throws InvalidOperationException.</p> <p> </p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment5781 ppopadiyn http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Sun, 27 Mar 2011 12:09:32 GMT RE: XNA for Silverlight developers: Part 8 - Music and sound effects <p>Hi. Although I'd say it's indeed rather uncommon, you should be able to also use WMA and MP3 files as sound effects. What you are probably seeing is that XNA Game Studio preselects the "Song" content processor by default when you import an MP3 or WMA into your content project (and "SoundEffect" as default for WAV files). You can simply change the content processor to "SoundEffect" though and it will work for those formats too (I had no problems using sample MP3 and WMA files as sound effects). If your files are also not working with these settings, there is a small chance their specs are not supported (bitrate, channels etc.). For a list of supported formats, see this link:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ff462087(v=vs.92).aspx">http://msdn.microsoft.com/en-us/library/ff462087(v=vs.92).aspx</a></p> http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment5775 Peter Kuhn http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Sat, 26 Mar 2011 01:13:20 GMT RE: XNA for Silverlight developers: Part 8 - Music and sound effects Well, nice article. You haven't mentioned something important. SoundEffect class works only with sounds in "wav" format. Or at least i am unable to make it working :( http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx#comment5774 ppopadiyn http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-8-Music-and-sound-effects.aspx Fri, 25 Mar 2011 23:24:32 GMT