Documentation on Creating Visualisers for XMPlay?

Started by I Ate Minecraft,

I Ate Minecraft

I am trying to make a slightly more advanced version of SpectrumBars, but I cannot find any documentation on actually making visualisers. I would like to also know at what sample rate does XMPlay play at?

Hope I'm not asking a dumb question :)

Ian @ un4seen

XMPlay uses the Sonique visual plugin system. I don't think there was ever any detailed documentation on that, but the VIS.H header includes useful information. The SpectrumBars plugin's source code is also available, so you could use that as a starting point for your plugin:

    https://support.xmplay.com/files_view.php?file_id=621

Some other plugins also have their source code available for reference:

    http://support.xmplay.com/files_view.php?file_id=184
    http://support.xmplay.com/files_view.php?file_id=525
    http://support.xmplay.com/files_view.php?file_id=544
    http://support.xmplay.com/files_view.php?file_id=598

I Ate Minecraft

Thanks a bunch Ian,

I have attempted to base my spectrum visualiser off of SpectrumBars.
What I have done so far: removed the 'bars' and spacing stuffs, and added fast decay
plot all the points and drawing lines between them, filling the space underneath
draw frequency markings and intensity markings.

but my main problem is that the spectrum looks very wrong compared to the built in spectrum viewer, So I'd love to know what formulas you used to get that nice spectrum, or the source code of it/hints on what I need to do.

If you would like pictures or my code please do say!

Ian @ un4seen

The FFT data in the Sonique vis "Spectrum" array is lower res than what the built-in spectrum display uses, so it won't be possible to get exactly the same result, but here's an update that should allow getting closer:

   www.un4seen.com/stuff/xmplay.exe

The FFT data is still lower res (can't change that without breaking compatibility) but it does now have the same window function applied (to reduce spectral leakage) as the built-in spectrum. I don't remember now if Sonique itself applied a window but I guess not (otherwise XMPlay surely would have done too all this time :)), so this change could potentially make some vis plugins behave differently, but I think it would only improve things. Let me know if you do see some vis not looking right compared to before.

I Ate Minecraft

Just tried with your alternate "stuff" version, still can't get them to look the same.
You say the built-in one gets its data from a different place, because I thought about maybe trying to make some amalgamation of a dsp plugin and a visualiser that gets its data from the dsp (buffer?) and render that to the visualiser part, haven't a clue if XM Play will recognise both at once, and then allow them to work together.

I don't know if the way I plot them is correct either, because I space them evenly across the screen space, and then the logarithmic calculations do some magic and make a value which then is multiplied with the magnitude value (from the given spectrum).

Is there anything else I should know/try before I give up?
The main reason I want to do this is to add frequency and intensity markings to the visualiser (which I have successfully done), but if the data isn't accurate then there isn't much point :(

another thing is that the built in one seems to have slightly more data at the lower end of the spectrum, and have some kind of falloff at the high end, which is one of the things that make mine so obviously wrong.

I also assume you are also doing some sort of interpolation between points to get a bit of a curve (to make the graph look more natural?), I remember seeing some formula for that, which I intend to implement once I get this thing working properly.

Ian @ un4seen

Quote from: I Ate MinecraftI thought about maybe trying to make some amalgamation of a dsp plugin and a visualiser that gets its data from the dsp (buffer?) and render that to the visualiser part, haven't a clue if XM Play will recognise both at once, and then allow them to work together.

It isn't possible to have a single plugin be both a DSP plugin and a Sonique vis plugin, but it is possible to have a DSP plugin be a non-Sonique vis plugin with its own window (instead of displaying in XMPlay's vis window). For example, the Winamp Visualisations plugin works like that:

    https://support.xmplay.com/files_view.php?file_id=679

Note that DSP plugins are called some time before the sample data is actually heard (due to buffering), so displaying the data as it's received would make the display out of sync with what's heard. In the Winamp Visualisations plugin source code, you can see it buffering the data and then using the XMPFUNC_STATUS::GetLatency function to work out what data to display so that it's in sync with what's being heard.

Quote from: I Ate Minecraftanother thing is that the built in one seems to have slightly more data at the lower end of the spectrum, and have some kind of falloff at the high end, which is one of the things that make mine so obviously wrong.

I also assume you are also doing some sort of interpolation between points to get a bit of a curve (to make the graph look more natural?), I remember seeing some formula for that, which I intend to implement once I get this thing working properly.

Yes, the built-in spectrum plots the FFT values/bins logarithmically across the display area (this makes lower freqs look wider than otherwise), using linear interpolation (ie. a straight line) to connect them.