Is it possible to dynanmically generate sounds with XNA C# code?
I looked into this some time ago when XNA was first released. At that time it was only possible to playback sound resources included in the compiled code.
Have there been any changes or new features added since XNA 1.0 that would allow an XNA application to generate and playback audio on the fly?
Yes.
XNA 4.0 added support for dynamic audio that allows you to:
Create a regular immutable sound
effect from a raw buffer using the SoundEffect.FromStream method.
Create a
DynamicSoundEffectInstance object then modify the audio data of this new
streaming sound effect object
dynamically.
Read more in the blog entry What’s “Dynamic” about this SoundEffectInstance? and in the AppHub article Dynamic Audio.
I think you can do this in XNA with DirectSound. Here's a link with code that seems to do what you want:
http://forums.create.msdn.com/forums/t/40361.aspx
Depends how dynamic you want to get. I know that XACT will let you change pitch and such, which, when combined with using cues in a programmatic fashion, can give some nice results.
If you want to generate your own waveform, you're out of luck. There's always the option of dropping below the framework and doing it yourself.
Related
I am integrating a video player to an existing .NET WinForms application.
I first tried to use "Windows Media Player Control" which is included in Windows SDK,
but I could not change the playback rate.
The following is the code I wrote to change the rate.
if (axWindowsMediaPlayer1.settings.get_isAvailable("Rate"))
{
axWindowsMediaPlayer1.settings.rate = 3.0;
}
The condition in the if statement always returns "false" no matter what video file I use. Does anyone have any idea why I cannot change the rate? It really needs to be available to change the playback rate, so WMP control seems to be a bad choice if it's impossible to do so.
Or, is there any alternative solution which allows me to change the rate? Preferably a .NET based library which does not involve any unmanaged code.
Thanks!
I ended up using DirectShow.NET (http://directshownet.sourceforge.net/) which is an open-source library. It contains a lot of samples, and it has a sample with playback rate control.
IF a commercial library is an option take a look at http://www.visioforge.com/media-player-sdk-net.html
Another commercial option would be Leadtools MultIMedia SDK - see http://www.leadtools.com/sdk/multimedia.htm#+cp_playback
Is the if statement really necessary?
I could set the rate fine without it..
axWindowsMediaPlayer1.settings.rate = 3.0;
I was wondering if there was a simple way to record audio, and have it saved as an object of any sort.
My personal goal is to eventually record audio, save it to a "channel", allow for multiple channels, and play them back simultaneously.
This project on CodeProject provides some classes for capturing audio. It uses Managed DirectX, which has been deprecated, so you might want to look into using SlimDx as a wrapper around DirectSound instead.
You could take a look into the OpenAL wrapper in OpenTK.
It should have what you need in it. The AudioCapture and AudioContext classes will collect your data, and then AL.SourcePlay() can be used to play multiple contexts together.
So it has been a while since I have done any game programming in C#, but I have had a recent bug to get back into it, and I wanted some opinions on what configuration I should use.
I wanted to use C# as that is what I use for work, and have become vary familiar with. I have worked with both DirectX and OpenGL in the past, but mostly in 3D, but now I am interested in writing a 2D game with all vector graphics, something that resembles the look of Geometry Wars or the old Star Wars arcade game.
Key points I am interested in:
• Ease of use/implementation.
• Easy on memory. (I plan on having a lot going on at once)
• Looks good, I don't want curve to look pixelated.
• Maybe some nice effects like glow or particle.
I am open to any and all suggestions, maybe even something I have not thought of...
Thanks in advance!
If you're just starting out again and already have a C# background, why not try XNA? You'll definitely be able to leverage your C# skills here
http://creators.xna.com
http://creators.xna.com/en-US/downloads
I use SlimDX for C# graphics programming and I prefer it to XNA.
http://slimdx.org/
TBH it doesn't really matter what you use. OpenGL, SlimDX, or XNA. They'll all be about as complex (or not as the case may be) as each other.
You might consider using the Axiom engine, which is a C# port of Ogre3D. It's enough higher level that you can have it render your graphics via XNA or OpenGL with little or no change to your code. It can also handle keyboard and mouse input (which are normally separate -- e.g., via DirectInput on Windows or SDL on Linux).
You also might consider using TAO Framework which is OpenGL based and quite nice. But you have to write the 2D Engine all by yourself tho. It also works on Mono!
I create my OpenGL engine with a C# wrapper because I like C# a lot too. Sadly managed languages are very slow when it comes to graphics and that's why I always make my OpenGL part in C++, compile it as a DLL and get it from C# using interop. If you by any chance dislike DirectX than I suggest you stay away from XNA. Everybody I know is very dissapointed about it and switched back to C++(OpenGL) + C#.
Since you already know C# I'd use XNA or Unity. While there are faster languages and middlewares, they're probably plenty fast enough. Both frameworks would have the necessary features you require.
I'm looking at trying to create a simple 'slider puzzle' game. You've seen the ones, you have an image and you shuffle the tiles.
However, I want to make one that will play back videos instead. What I'm trying to determine is whether it's possible to playback a video in C# and render the video on different controls (probably buttons, or panels). I've spotted the Microsoft.DirectX.AudioVideoPlayback classes but haven't found much documentation on them yet.
So to throw it up in the air, is this going to be possible to do without too much difficulty? Are there any useful (free) libraries that might help me along?
Have a look at DirectShowNet that wraps the DirectShow API, in the samples page there is a sample called PlayWnd the shows how to play a video file.
Depending upon how large and how long your video sources are, you could accomplish this very simply by first converting your videos to animated GIFs. A .Net PictureBox control will display and animate a GIF automatically, and you could easily use PictureBoxes for your tiles.
One big advantage of this approach is that (thanks to Mono) your application could work unaltered on Windows, Mac and the iPhone (also Linux and a couple others).
I am working on the development of a Massively Multiplayer Online Role Playing Game (MMORPG) in .NET using C# and Silverlight. One of the features that has been requested for this game is to allow players to upload their own avatars.
Rather than displaying the uploaded images in their raw forms, we want to convert the images to a cartoon form--in other words to cartoonize the image.
Several sites which can accomplish such a task are listed at http://www.hongkiat.com/blog/11-sites-to-create-cartoon-characters-of-yourself/
I realize that these sites are applying an image filter to create the cartoon image. Frankly, I have no reasonable idea what these cartoon image filter algorithms might look like or if there is anything already available in C# or .NET that I could use. If there are no libraries available, I am curious how difficult it would be to roll my own.
This is a minor game feature so I am not interested in devoting a week or more of coding time to implement this. However, if I can code up what I need within a day, then it is probably viable.
At this point, I am primarily looking for guidance as to
what is possible
what libraries are already available (preferably as open source)
where i may find additional information
any other advice or guidance you may be able to provide
Thank you in advance!
Apparently you apply a Gaussian Blur filter to the image. Then you sharpen the image. Perhaps the AForge libraries would help you out.
I've used code from the image processing lab on code project before with success. (update: here's the library it uses)
Christian Graus also has written a whole series on GDI image processing which I found useful (and has the effects listed above for filtering capabilities).