On single core CPU’s (I’ve tested on duel core CPU’s and the problem does not appear to exist) I’ve found that calling both channel.getPosition() and system.getSpectrum() causes the CPU usage to jump to between 40% and 90% when playing a sound file. When I disable either one of these the CPU usage goes down to about 2%.

Does anyone have any ideas on how to solve this? Is there a better way of getting the current playback position than channel.getPosition()?

Also (I’m using C# (.NET 2)) I have improved the performance of the spectrum thing in the example provided with FMOD. The spectrum example uses 90% of the CPU on all my test PC’s but with the code below the CPU usage is now between 2% and 35% depending on the CPU.

[code:2k4oc8bx] /*
The upper band of frequencies at 44khz is pretty boring (ie 11-22khz), so we are only
going to display the first 256 frequencies, or (0-11khz)
Rectangle[] rectangles = new Rectangle[255];
for (count2 = 0; count2 < 255; count2++)
float height;

                height = spectrum[count2] / max * GRAPHICWINDOW_HEIGHT;

                if (height &gt;= GRAPHICWINDOW_HEIGHT)
                    height = GRAPHICWINDOW_HEIGHT - 1;

                if (height &lt; 0)
                    height = 0;

                height = GRAPHICWINDOW_HEIGHT - height;

                rectangles[count2].X = count2;
                rectangles[count2].Y = Convert.ToInt32(height);
                rectangles[count2].Width = 1;
                rectangles[count2].Height = GRAPHICWINDOW_HEIGHT - Convert.ToInt32(height);

                //g.FillRectangle(mBrushGreen, count2, height, 1.0f, GRAPHICWINDOW_HEIGHT - height);

            g.FillRectangles(mBrushGreen, rectangles);[/code:2k4oc8bx]
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.