0
0

Hi i am trying to create a spectrum analyser for an lcd screen. I have the basics working but the values i am using dont seem to give the best results?? Currently i take the first 128 as that seems to be where most of the action is?? Then factor it up to 1 by finding the highest result in that 128 range and dividing all vals by that. But how should i group them?? I display 16 bars at the minute but am considering 24. How should i group the values for best effect?? Currenlty i use 8 vals for each bar. But i read a thread somewhere about using the first 2 then 2 then 4 then 8 etc??

Can anyone suggest the best groupings or ranges that would give a good display range.

Cheers for any help.

Drinkyfish

• You must to post comments
0
0

Thanks for the reply, yeah you are basically doing the same as me. Have a look on the forum for vis_getspectrumcount and vis_simplifyspectrum i think and in that you will find a some code that gives a really nice spectrum. It uses an increasing total for the values to give smooth looking bars across the levels. The code currently works for 16 and 32 bars but with mods any value should be possible.

Cheers

Drinkyfish

• You must to post comments
0
0

I use the first 256 values from the DSP, group them into blocks of 4 and take the average. This gives me 64 numbers which are between 0 – 100 which I plot as lines. It seems to work quite well.

[code:1shcm1jp]
for( i = 0; i < 256; i += 4 )
{
spectrum[yPos] = (float)Math.Round(dsp[i] * 1000, 0)+(float)Math.Round(dsp[i+1] * 1000, 0)+(float)Math.Round(dsp[i+2] * 1000, 0)+(float)Math.Round(dsp[i+3] * 1000, 0);
spectrum[yPos] /= 4;
yPos += 1;
}
[/code:1shcm1jp]

where dsp is my array of floats from the DSP, and spectrum is an array of floats

The code I use to display the lines is:

[code:1shcm1jp]
int yPos;
int i;
int height;

``````        yPos = 0;
for( i = 0; i &lt; 64; i++ )
{
height = 100 - (int)spectrum[i];
// draw the coloured part
if( ( i % 2 ) == 0 )
spectrumGraphic.DrawLine( redPen, yPos, height, yPos, 100 );
else
spectrumGraphic.DrawLine( bluePen, yPos, height, yPos, 100 );
// draw the black bit at the top to blank out what was there before
spectrumGraphic.DrawLine( blackPen, yPos, 0, yPos, height + 1 );
yPos += 4;
}
this.spectrumBox.Refresh();
``````

[/code:1shcm1jp]

I do all of this in a thread where I sleep for 25ms.

The cpu load does go up, but only to about 10% which is fine as far as I am concerned.

Hope this helps a little. am using c# but the principle should be the same.

• You must to post comments
Showing 2 results