PDA

View Full Version : what does waveformData contain?


Razvan
8th June 2002, 10:04
Hi everybody,

I just made a LED output plugin, using as a framework the mini_sdk I downloaded from this site. The only problem is that the plugin seems to act only on high frequencies and I want it to act on the low ones. I can't do this since I don't know what waveformData contains.
This is my render function:

int render(struct winampVisModule *this_mod)
{
int x, y;
static int draw=0;
for(y=0;y<=1;y++)
{
int last=this_mod->waveformData[y][0];
int total=0;
for (x = 1; x < 576; x ++)
{
last = abs(last - this_mod->waveformData[y][x]);
last = this_mod->waveformData[y][x];

}
total /= 200;
if (total > 252) total = 252;
if(total>draw) draw=total;
else draw-=15;
out_signal(draw/32); //this is the function that outputs
//the signal. out_signal(1) will light the
//fist led, out_signal(2)
//will light the first two leds, and so on.
}

return 0;
}

ampz
16th June 2002, 23:16
1: You want "spectrumData" not "waveformData". Use the first three or four values of spectrumData to get the lower frequencies.

2: Your code seems to be wrong... that big for-loop of yours... you keep overwriting "last" for each loop..

waveformData contains exactly what it sounds like. Waveform Data.
spectrumData contains spectrum data. (a linear spectrum)

Razvan
18th June 2002, 18:37
thanks for helping. you were right. the code I wrote in the last message works. I just didn't copy it right. the loop should of been

//...

for (x = 1; x < 576; x ++)
{
total = abs(last - this_mod->waveformData[y][x]);
last = this_mod->waveformData[y][x];

}
total /= 200;

//etc...

because i am new to writing winamp plug-ins and i am not so good at programming I used a framework. the author of this framework wrote those loops and used the waveformData :weird:. this is why i got confused. i thought that there was something wrong with it and that's why I asked for help. thanks again.

ampz
19th June 2002, 01:17
This second version of your loop doesn't work either. Again, you keep overwriting the variable "total" each time you loop.
After the loop, total will contain the difference between the two last values of Waveformdata.

As I said previously, you don't want waveformdata, you want spectrum data.
Add the four lowest values and divide by four to get a value between 0-255 that you you probably can use to feed your LEDs. However, you might vanna convert it to something logarithmic first.

The first values in spectrumdata represents the lower frequencies.