I've got an audio library for Silverlight that is in need of some acceleration on slower machines. Specifically, this library makes extensive and repeated use of the FFT transform as a part of its acoustic echo cancellation and noise reduction algorithms, and I'm wondering if it would make any sense to use the GPU for this (as described, for instance, here: http://www.inf.fu-berlin.de/lehre/SS10/SP-Par/download/fft1.pdf).

I know that Silverlight 5 provides a fairly simple port of Microsoft's XNA framework, but unfortunately, I'm a complete novice to 3D coding in general, and XNA in particular. It seems to me like it should be theoretically possible to use some combination of vertex and/or pixel shaders to work this magic, but before I go too far down this road, I wanted to get some expert opinions on a few questions:

(1) SL5's XNA implementation throws the output of its pipeline onto a single "DrawingSurface". I had been thinking that this is where I might be able to read the results of the calculations (kind of how you could use a WriteableBitmap to read the results of pixel shader calculations in SL4). But I can't figure out how I would do that: there's no "GetPixels()" method, or anything like that. In regular XNA 4.0, the VertexBuffer has a GetData() method, as do the Texture2D and Texture3D classes, but those methods are missing in the SL5 version. Does anyone know of any way to actually read the results of shader outputs? Or is the GPU a write-only device in SL5?

(2) It seems like the real problem with GPU calculations is reading the results quickly. Assuming I can solve problem #1, does anyone know whether an FFT would be amenable to this sort of solution?

(3) Silverlight 5 is limited to HLSL Level 2, which has a number of serious limitations, so far as instructions, registers, available functions, and so forth. Is it at all reasonable to expect to be able to port an FFT or some portion thereof over to this?

Thanks in advance.

  • 1
    \$\begingroup\$ can you describe the math operations you have to do? is it needed to be a realtime effect? can be delayed? you have to use a render target to draw your calcs, and GetData to retrieve them, are you sure that texture have no getdata? \$\endgroup\$
    – Blau
    Oct 8 '11 at 11:11
  • \$\begingroup\$ I'm doing realtime audio enhancement, using Google's WebRTC stack (which I've ported to C#). This includes acoustic echo cancellation, noise reduction, and automatic gain control, among others. There's a lot of floating point math involved, most of it having to do with converting the signals from the time domain to the frequency domain, which is done using a Fast Fourier Transform. By the nature of the beast, it needs to be realtime. And according to MSDN (msdn.microsoft.com/en-us/library/…), no Texture.GetData() method. \$\endgroup\$
    – Ken Smith
    Oct 8 '11 at 15:36
  • \$\begingroup\$ Uupps... with silverlight a Texture has no GetData... i have been looking for a workaround but no success... i recommend you to post in Shawn's post about xna and silverlight... blogs.msdn.com/b/shawnhar/archive/2011/10/05/… he may give some solution \$\endgroup\$
    – Blau
    Oct 8 '11 at 20:39
  • 1
    \$\begingroup\$ This doesn't answer your question, but D3D11 has ID3DX11FFT interface, which greatly simplifies the amount of work you have to do \$\endgroup\$
    – bobobobo
    Oct 10 '11 at 23:22
  • \$\begingroup\$ @bobobobo - Well, you're right, that doesn't help. But it does make me jealous. If I could access that on Silverlight, it would speed up my code pretty significantly, I suspect. Oh well... \$\endgroup\$
    – Ken Smith
    Oct 10 '11 at 23:59

According to Shawn Hargreaves (from MS), this isn't supported in Silverlight 5. His unofficial guess as to why is that (a) it would be difficult to get it working consistently across all GPU drivers, and (b) for all but a tiny class of demo-ware-style problems, it wouldn't make any sense.

Oh well.


I wrote a custom content importer to "GetData" for a Texture2D.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.