Picking my next graphics engine (Java vs. C#) - c#

Requirements
I am developing a music game that requires access to the audio line-in and classes to help me analyze a MIDI file (playing the MIDI is NOT necessary for me). Secondly, I need a graphics engine that allows easy and quick development (within reason). The game's focus is not cutting edge graphics - think along the lines of Audiosurf.
Issue 1
Java provides easy to use and well documented Audio line-in input and MIDI file support built right into the API that I could not find with C#. I found some resources to read from the line-in and MIDI helper classes but don't have much documentation/support and seem to be workarounds to a lack of support by C#.
Issue 2
The second aspect of the game is of course the graphics engine. On the C# side, XNA seems to be the clear choice for my needs. On the Java side, I'm leaning towards JMonkeyEngine (or ogre4j as a second choice). JMonkeyEngine seems to be fine for my graphical uses but the documentation is scattered and sparse.
Deciding
Both issues are of equal importance. Also, I know the community here is prominently .NET programmers, so try to consider both languages if possible.

Use processing, http://www.processing.org/
It seems that you for now mostly want to test a see if your concept actually can be done/(is cool)
Processing is more or less made for this sort of things, audio and visual programmatic sketchpad. You can with very little code see if your ideas stands the way you want.
It's a subset of java so you could use java inside or outside depending on some factors.
Yes, you could use some .net, XNA/WPF or whatever but too me that seems premature.
Test you ideas first.

For the .NET and audio side of things, I have written some code to read and write MIDI files and included it as part of NAudio. Have a look at MIDI File Mapper for an example of how to make use of this. NAudio also includes the capability to capture microphone input.

Related

Recording sound in real time with c++ or C#

I have a professional sound card, and I want to record the signals from the guitar with c++ or c# for developing guitar effects in real time.
How can i record in real time through a c++ method ?
Is it mean that I need the sound card API ?
this one is enough?
Although may not be as easy as using a pre-built library, you may be able to get a C++ SDK for your sound card from the manufacturer. I would start by browsing their site or contacting support.
If that isn't an option, you can also use DirectSound which is part of the DirectX family of products. The learning curve is fairly steep but I believe it should do just about anything you want.
One final option is to look at a favorite tool (such as sound forge). A number of these tools support automation which means you can click through the app, decide what you want, then automate that sequence of events (See this as an example).
Hope that helps, best of luck!
Side Note: I have developed a number of hardware interfaces and in my experience its best to start with an example that does at least something like what you are looking for, then modify the code from there. If any particular option doesn't have an example like this I would probably skip it in favor of an example that does.
Examples
Direct Sound - Microsoft has a learning site for direct sound which you can find here. I also found this blog article which has an example for recording audio with direct sound.
Sound Forge - If you download the "Script Developers Kit" there are examples for C# in the scripts folder that should get you started. I believe this particular tool is more focused on editing and effects but I am guessing there should be automation for recording.
To just record audio in real time, any API will be fine. Note that WASAPI is the primary API (since Vista), and legacy APIs like WaveIn API, DirectSound are implemented on top of WASAPI as compatibility layers.
Regular APIs assume you are okay to certain processing latency/overhead, on the order of tens of milliseconds.
If you are going to be faster than this, and you need real time performance, such as to process data and return in back for playback as soon as possible, you need so called exclusive mode streams, where you can achieve latencies on the order of a few milliseconds, which is on par to professional audio development kits.
Windows SDK has a few audio recording samples in \Samples\multimedia\audio (C++)
It's probably a good idea to use a third party library for that.
There's a multitude of options. The ones I know of are portaudio and STK.
I like the Fmod API which supports recording (Sound recording with FMOD library) and realtime effects.

Multiplatform project (iOS/OSX, Windows and optionally Android) using C#

I know this type of question has been asked a lot, but I really can't find something that nails what I'm looking for, so hopefully this is not considered an "asked without research"-question.
The backstory: I'm developing an app that initially was supposed to work on OSX/iOS, but having a Windows version is already a must. I'm trying to find out the easiest way for me to have to translate as little as possible between each version, and preferrably without having to learn too much new (I have a little time constraint).
I'm using C#, currently developing in Mono
I'm used to the Cocoa API on iPhone using MonoTouch
So, my options (as I see them now):
Go native on mac, meaning having to make a separate graphics routines for the other OSes - makes the mac version easy-peasy, and I could postpone any learning curve for the other ports, however I guess it requires a lot more meddling when porting
Use some kind of XML markup or HTML/JavaScript as a presentation layer, with hooks on links triggering backend events (I don't know how well that would work on different platforms) - would require me to learn a bit of JQuery, but it seems pretty straightforward
Make it an XNA project and use MonoXNA (or similar) to port - would require me to learn enough XNA to do it, don't know if it's a pain
Use some other multiplatform 2D kit I don't know of
Basically, I need animated 2D sprites, mouse and touch input, and it would really be nice to have movement keyframes and maybe rotation.
There's also sound, of course, but playing a sound file seems so simple on all platforms that writing platform-specific shouldn't be much hassle.
Have a look at MonoGame. It should suit your needs pretty well I think.

How should I start playing with 3D?

I'm a developer for just about 6 months now, and since I enjoy programming I've started little programs such as encripters, calculators, tools, stuff to play with DropBox (hehe), stuff that play with bitmaps, drawing graphics, and even a program to update the MSN display image according to the artwork of the music you're listening yo on iTunes.
One of my other hobbies is 3d modelling (completely amateur) and I'd like to mix these hobbies together! So I've read a little about it and figured I'd have to have good notions on geometry, math, point spacial position (which I do, from my 3d modelling experience), but I don't know how to use API's for it, so I've 'simulated' simple 3d with a simple program I've made (a spinning cube).
Here are some questions:
1) What would be a nice 3d development tool for a .NET programmer like me?
2) Is there a way of using 3d models made in 3DS Max ? (I intend on modelling characters)
3) What knowledge should I have in order to render it, and move it around ?
4) Which API should I use ?
NOTE: Not a dupe, I'm asking for directions specific for .NET development possibly using 3ds MAX, and there were no questions about it so far
EDIT:
I've got three answers that seem quite nice, so let me specify a little and maybe you can tell me what's the more appropriate tool.
What I'd like to build soon would be like:
portable (click'n'run, no need to install, and (hopefully) no need to send DLL's along)
"3D embedding" in winforms application, like a picturebox you could render in.
Real winforms application-like (having all System api's like IO, Drawing and etc)
The development enviroment would be nice if it:
Had the possibility to import existant 3D models (not a must, but a plus)
Had the ability to create 3d models programatically (a must)
Possibly has a tool for materials and textures (that would be a huge plus)
Is Well known (high availability of tutorials, questions in S.O., forums..)
And it would be really nice if I could use C# all the way :)
I'm going to provide another vote for XNA. The comment that it's too "game centric" is a non-starter - it provides a rendering loop with feedback on how fast everything is running so you can adjust your rendering to try to maintain a specific framerate (if you want). This isn't particularly game-centric as it's something that most 3D applications should worry about. The only thing that's really unusually game-centric about it is that it provides easy access to game controllers. Feel free to ignore that bit if you don't want to use it.
The only downside for you using XNA is your requirement that it be click'n'run, XNA has a redistributable that you have to worry about. Note that Win7 has this installed by default, but Vista and earlier don't.
EDIT:
XNA is made for applications that are strictly 3D. As such it doesn't natively support using typical windowing controls inside of an XNA project. But, there are ways around this...
A few useful links. Embedding XNA in a winform : http://forums.xna.com/forums/p/6471/34180.aspx#34180
WPF controls directly inside an XNA project : http://www.c-sharpcorner.com/UploadFile/iersoy/256/Default.aspx
Personally, I found XNA a little too "Game Centric" for my tastes. I was more interested in design/architecture type uses.
You may find SlimDX more to your liking.
Even though there are great suggestions in this post already(such as SlimDX and XNA), I'd just like to mention OpenTK.
OpenTK is closer to OpenGL than Direct3D, but it might be the best solution for cross-platform 3D .NET applications.
Since you are using C#.Net, the XNA library will be excellent for you. It is free off the Microsoft website and integrates into the VS IDE. A lot of available tutorials around to help get started.
Also, if I remember correctly. to use a 3d model in XNA, simply export the completed model as (.X). It can then be loaded into your work.
I vote you try Blender. www.blender.org
It's free, open source, and has a great community both on forums and IRC. Progress on the app is pushed forward by major community projects every year, some of which are movies and games and have won some awards. It is gaining industry acceptance as a way to model extremely fast.
Downsides: It's not considered as "pro" as Maya or ZBrush, and it has a very different brain about interface. Learning curve can be interesting, depending on how you learn and how much help you receive.
Upsides: It's free, great community, updated regularly, many tutorials and community projects to work on.
Community:
Blender channel on IRC
Blenderartists forums
Previous community Projects:
Elephant's Dream
Big Buck Bunny
My vote goes for Povray. It is a 3d renderer with a c-like syntax language. It doesn't satisfy your .net needs, but if cool non the less for 3d rendering. If you any kind of interactivity XNA is probably your best best. But I'm interested in your finds.
Re: "Has the ability to create 3d models programatically (a must)"
A few pointers:
Polygon Triangulation
(Dr. ?) Jonathan Richard Shewchuk's Triangle library
Dr. Hang Si's TetGen library
Constructive Solid Geometry
GNU Triangulated Surface Library
There are no .NET libraries I am aware of that allow you use the above mentioned libraries/techniques. You will have to use PInvoke or C++/CLI in order to make calls to these libraries from the managed world.

C# Grab frame from wmv file

Does anyone know if it is possible to grab a frame/image from a video (.wmv) on position X using C# without installing DirectX and working on Windows 2008 (a webserver I would like to install as less as possible).
Or even a simple solution with directx could be nice.
Henk
What you'll actually need to look into is DirectShow, the general-purpose media (both audio and video) library for Windows. It used to be part of DirectX but several years ago it branched off and became part of the Windows (Platform) SDK. I should also point out here that it's now been deprecated since Windows Vista in favour of Media Foundation. From what I've read it's a much better library (DirectShow is hell for complex tasks), but unfortunately it's not really feasible to only target Media Foundation at the moment because of the lack of support for XP and earlier...
The best I can really do is point you to DirectShow.NET, a .NET wrapper library for DirectShow, which is rather stable and well tested at the moment. It includes various samples which should help you get going, but by no means will it be a straightforward solution. Also, I strongly recommend you take a look at this CodeProject article/sample application. It deals with both webcam video capture and video playback from files (including WMV). A bit of playing around with that, and learning how to do frame seeking/single frame capture (I think that project might even some code to do that) should get you what you need. Perhaps you'll even find the precise solution somewhere within the DirectShow.NET samples of that CodeProject app.
Of course, I would suggest an easier solution if I could here, but you're pretty much stuck with the horribleness that is DirectShow for the moment. Good luck anyway!
You should try FFmpeg.
Take a look at the Windows Media Format SDK, which is designed to give you pretty direct access to the frames inside a WMV (/WMA/ASF) file.
http://msdn.microsoft.com/en-us/library/dd757738(VS.85).aspx
In particular, you're interested in the synchronous API for reading these files (IWMSyncReader is the interface name). There are some pretty decent samples in the WMFSDK; I believe the most interesting one for you here will be WMSyncReader, which will show you how to dig through a WMV file and get frames, starting at position X.

Does XNA provide audio input (line in)?

Does XNA provide a means of audio input from the line-in? I looked at the MSDNA website but can't find anything on audio input. If it is indeed possible, a snippet of code or a tutorial website would be great.
Edit:
I need to do buffered reads from the audio-line in. I'm not so much interested in the implementation but rather if it has low latency.
Also development will be implemented into a PC only game.
I think all sound files need to be compiled by XACT before they can be used in XNA.
So either you get hold of DirectSound and look at the sample in:
\Samples\Managed\DirectSound\CaptureSound
...or you could interop with winmm.dll. This guy has made a small example of how to do it:
http://www.codeproject.com/KB/audio-video/cswavrec.aspx
And this guy writes some more about enumerating all sound recording devices:
http://www.codeproject.com/KB/cs/Enum_Recording_Devices.aspx
Hope it helps!
Edit:
I'm not sure what you want to do with your audio stream so this tutorial might be of interest as well:
http://nyxtom.vox.com/library/post/recording-audio-in-c.html
Edit 2:
What he said (in the comment)
|
|
V
If you're looking at doing a Windows only project, you could certainly capture the audio coming in with code from outside the XNA framework and play it back with the same. Because of how the XNA content manager works, you wouldn't be able to use the regular playback methods because the content manager translates everything into .xnb files at compile time and reads them from there. Nothing keeping you from playing using standard windows API calls though. You wouldn't really have an XNA project at that point, but I don't suppose the distinction is all that important since you're not looking to be compatible with the other platforms anyway.
To answer your question, no, you can't access audio line-in through the XNA APIs. You'd have to look at some other library such as Port Audio that would give you access to features like that. But then you'd be restricted to running on windows (ie. no xbox or zune).
disclaimer: not sure if port audio specifically has this functionality as I just found it quickly via google. Was just trying to illustrate that you'd have to use some other API.

Categories