Sign in to follow this  
rjbishop

[SlimDX] 2D Spectrum technique

Recommended Posts

rjbishop    157
All, I am using SlimDX to help me graph a 96KHz wide spectrum from an audio source- and so far it's working fine. I have 2048 samples that are returned from a FFT, each sample representing dB gain across 47 Hz of the spectrum. I use a VertexBuffer to create 2048 LineList, and draw the spectrum across a panel that the user can vary the size on. I also need the ability to show the entire spectrum, or a fraction of the spectrum within this panel- so my strategy so far is to use the Device.Present(SourceRectangle, DestRectangle) method to control how much of the spectrum I present (i.e. ALL, or maybe only 1/16th) across the entire panel. My problem- I'm also drawing/labeling a "Grid" on the backbuffer before I draw the spectrum (among other things), and this grid gets "scaled" by the Device.Present(srcRect,DestRect) function (which I don't want to occur- it looks terrible) Obviously, I understand how this is happening, but I'm stumped how I can change this behavior. What I want is the ability to keep the Grid in the original 1/1 scale (knowing that I'll have to do some math in my code), but then allow DirectX to scale the spectrum view as needed. So how does one do this? I'm thinking instead of using Present() to do my scaling, I might need a 2d Transform for my spectrum, and zero transform for the grid? I'm such a newbie to DirectX and all the techniques, I'm just not sure what approach to take. Thanks in advance! And again, I LOVE SlimDX! -Reid-

Share this post


Link to post
Share on other sites
Mike.Popoloski    3258
One thing you might want to look into is using a texture as a render target, and then scaling that with a StretchRect draw call. EasilyConfused talked about something similar in his journal for achieving resolution independence in your main draw code. I believe a similar system could work well here.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this