View Full Version : Scrolling Spectrogram
23rd November 2008, 05:09
Hey all. This is my first attempt at making a MilkDrop preset. Wanted to implement a basic scrolling spectrogram, since XBMC doesn't seem to have one.
I'd hugely appreciate any feedback as to how to get around some minor issues I was having:
1. Making a continuous wave over the scrolling: I get small gaps in the spectrogram between each frame due to the scrolling. Any idea how to eliminate these?
2. Eliminating scrolling trails: A side-effect of the scrolling was that colors seemed to bleed as they approach the left-side of the screen. Any idea how to prevent all blurring, just a perfect non-destructive scrolling, like a ticker?
3. Clear the screen at preset load: Currently, any color on screen prior to the preset loading will stay there. I'd like to start with a black screen.
23rd November 2008, 09:25
Welcome to the boards :)
1. I think there's no simple way to get rid of this, other than slowing down the scroll rate. It's a fundamental problem with scrolling, since the wave is drawn only once per frame then the frame is scrolled. That'll always leave a gap between successive drawings of the wave.
2. This can be done very simply with pixel shaders. Check out the warp shader in the attached preset, basically all it's doing is the same as the dx equation in the per frame code (which is commented out now because it's not needed anymore).
The important part is the sampler type. The four types are fw, fc, pw and pc, milkdrop uses the fw type as default. The w's are the same as setting texture wrap to 'on' in the post-processing menu, the c's are the same as setting it to 'off'. The f's sample each point as an average of the points around it, and this is where the bleeding comes from. The p's on the other hand sample the nearest point directly, so you get no bleeding. Which you use depends entirely on the preset, some look really ugly with point sampling and others look ugly with averaged sampling.
Setting zoom=1 in the per frame code also helps, since (like warp) zoom isn't completely 'off' until it's set to 1 in the per frame code. You can see this by commenting out zoom=1 in the attached preset.
3. There's a few ways to do this. Since the colors are 'stuck' on the border of the preset (a side-effect of using no texture wrap) you can simply add a small outer border set to black. I've set this up in the preset.
That's the long and short of it :D Always nice to see some new people working on presets, I'm pretty new here myself.
23rd November 2008, 17:18
Beautiful. Thanks muchly! I made a couple more minor tweaks, mainly to get better color response from quiet sounds and to minimize the gaps. Update is attached.
One more question:
When I tried loading the preset to XBMC, it didn't seem to know how to react to the shader code. Same with my laptop. I suspect these are probably hardware limitations that are fundamentally unresolvable, but is anyone aware of any workarounds I could try?
In particular, is it possible to disable averaged sampling without using pixel shaders?
23rd November 2008, 22:01
Well the laptop's graphics chip probably doesn't support pixel shaders, no way around that. I'm not sure about XBMC, never used it. I'd assume it supports pixel shaders in some way, but maybe they have to be formatted differently than in milkdrop.
I don't think there's a way to disable averaged sampling without the shaders, unless somebody here knows of a hack.
Looks good though :up:
25th November 2008, 12:34
If I remember correctly, XMBC only runs Pixel Shader 1.4.
What graphics chip is in your laptop?
26th November 2008, 03:49
It's an NVIDIA GeForce4 440 Go. So, yeah, it only supports Pixel Shader 1.3.
I assume there's no way to write a MilkDrop preset using v1.3/1.4 pixel shaders?
26th November 2008, 10:14
uh ... what ... wait ... ProjectM2.0 ... Pixelshader2.0 ... opensource ... I'm shitting bricks :D
8/28/08 - projectM 2.0 - Pixel Shaders & Milkdrop 2.0 Support
projectM 2.0 is a huge step forward. Pixel Shaders have been integrated via NVidia's Cg toolkit, for cross-platform shader acceleration. This, of course, allows Milkdrop 2.0 preset compatibility! It's awesome.
projectM (has been/is being) completely restructured. This will set the framework for new ways of writing presets. Milkdrop presets will become just one way of using the projectM framework. How do you want to write presets? PHP, Python, or Ruby? Let us know!
About the Mac port... Our macbook broke. So now any hopes for a polished up mac binary rest upon a) getting another macbook or b) Alligator returning and saving the day.
projectM 2.0 is in subversion and we have reports of it working on many different distributions and with multiple video cards, so the handy among you should feel free to try it out. Just remember to use Milkdrop 2.0 presets if you want to see the new stuff! We'll make a formal release once our hackathon stops.
btw: here's one more pixel-accurate scrolling code
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.