FAIL (the browser should render some flash content, not this).

Search the site

FAIL (the browser should render some flash content, not this).

Main Menu

XNA - not just for games, not just for XBox/WP7 PDF Print E-mail
Written by Mike Bergenstjerna   
Friday, 15 April 2011 15:20

Earlier this week, I was asked to write a quick program to generate a spectrum waterfall from a realtime audio stream.  Now I'm not really that familiar with DirectX sound control, and the example code I uncovered while planning the code was like Manderin Chinese to me, so I decided that I'd do a windowed XNA program and use the spiffy Microphone / DynamicSoundEffect system, which is a really, really amazingly simple way to get data from sound buffers from any audio device.  You connect up an event handler or two and seamles audio streaming (in this case from a USB sound device to the default playback device) slots in to place very quickly and with a minimum of effort.  This meant I could focus on the interesting stuff like running a fast fourier transform on the captured buffer data and plotting the aplitude of each frequency bin on-screen.  XNA is absolutely excellent for this kind of application, and when working for a Windows "game" you get access to all the other lovely, friendly features exposed in C#.

After I'd got the basic spectrograph sorted, I wanted to add a couple of "controls" to the app - zoom, start/stop, a clean way to quit, all the usual jazz - so I build a very quick UI engine which allows buttons, text boxes, dials, list displays and a few other bits and bobs.  So far, so disinteresting I hear you cry, but wait!  Long-term visitors to the site might know that I like to dabble in ham radio once in a while, and for a long time I've had a "standby" project to create a nice, clean, simple but powerful app to control my favorite radio scanner, the Icom PCR-1500.  THis lovely little unit plugs in to your USB port and provides a simple audio device to listen to the radio and a COM port to send and recieve commands.  I've already got a control engine which used to sit in a normal Windows Forms app, so I thought I'd combine this engine with my new FFT class and UI engine.  Over the last 2 days I've got the whole thing together, and the result is (I think) a really nice example of how XNA can be used for things other than games or "pseudo-apps".  Right now I'm tidying up a few little things and after that it'll be available as a demo  (time limited, since when it's done I want to sell this baby).  I'm going to be putting more details of the program up soon, but in the meantime if you've got a requirement for a good-looking, non-windows forms multimedia application, have a go at using XNA - you won't be sorry!



Add this page to your favorite Social Bookmarking websites