Help - Search - Members - Calendar
Full Version: I just don't understand whats wrong
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
kalmark
Hello!

I have a strange problem with the vis plugin I wrote. Once I noticed that the channels are mixed up (I let it show only 2 channels at max), so I checked my code again, found the faulty spot, and repaired it. Ok, at that time it worked. I even uploaded it to the fb2kplugins site. And now, I notice, channels are flawed again! And I have not changed that portion of the source, AFAIK... I dl-d my own plugin from the plugin site, and it is flawed, too!

You can easily notice the flaw if you play a stereo track which has only sound in one channel. My vis's peaks display the sound in the opposite channel than it really is. blink.gif

I can't really imagine what could have gone wrong... I only tried to edit the visibility of the visualization window in the code, but reverted all of my changes. I uploaded my source to THIS LINK, maybe someone will find the bad parts.

Any ideas? unsure.gif

Thanks a lot!
kalmark
Bump smile.gif

Now I post the code for processing the audio chunks, maybe my error will be trivial for some with less efforts.
CODE

vis_sample * src = data->spectrum;
if (data->nch <= 2)
{
for(n=0;n<data->spectrum_size;n++)
{
 g_left.left = MulDiv(g_rect.right,n,data->spectrum_size+1);
 g_left.right = MulDiv(g_rect.right,n+1,data->spectrum_size+1);
 if (data->nch==2)
  {
   g_left.left=g_left.left/2;
   g_left.right=g_left.right/2;
  }
 if (g_left.left < g_left.right)
  {
          double val = fabs(*(src++));
   val = log((val/2) + 1) / log(2);
   val *= 0.25;
   if (val>1.0) val = 1.0;
   g_left.bottom = g_rect.bottom;
   g_left.top = (int)((1.0 - val) * g_rect.bottom);
   FillRect(dc,&g_left,leftbrush);
   
   if(cfg_show_peaks==1)
   {
    if(leftlimit[n]>=g_left.top)
    {
     leftlimit[n]=g_left.top;
     fallspeedleft[n]=1;
    }
    else
    {
     leftlimit[n]+=fallspeedleft[n];
     fallspeedleft[n]+=fallspeedleft[n];
    }
    SelectObject(dc,toppen);
    toDraw[0].x=g_left.left; toDraw[0].y=leftlimit[n];
    toDraw[1].x=g_left.right; toDraw[1].y=leftlimit[n];
    Polyline(dc,toDraw,2);
   }
  }
   
 if (data->nch==2)
 {
         g_right.left = g_rect.right/2+MulDiv(g_rect.right,data->spectrum_size-(n+1),data->spectrum_size+1)/2;
         g_right.right = g_rect.right/2+MulDiv(g_rect.right,data->spectrum_size-n,data->spectrum_size+1)/2;

  if (g_right.left < g_right.right)
  {
   double val = fabs(*(src++));
   val = log((val/2) + 1) / log(2);
   val *= 0.25;
   if (val>1.0) val = 1.0;
   g_right.bottom = g_rect.bottom;
   g_right.top = (int)((1.0 - val) * g_rect.bottom);
   FillRect(dc,&g_right,rightbrush);
   if(cfg_show_peaks==1)
   {
    if(rightlimit[n]>=g_right.top)
    {
     rightlimit[n]=g_right.top;
     fallspeedright[n]=1;
    }
    else
    {
     rightlimit[n]+=fallspeedright[n];
     fallspeedright[n]+=fallspeedright[n];
    }
    SelectObject(dc,toppen);
    toDraw[0].x=g_right.left; toDraw[0].y=rightlimit[n];
    toDraw[1].x=g_right.right; toDraw[1].y=rightlimit[n];
    Polyline(dc,toDraw,2);
   
   }
  }
 }
}
}
That's about it. Ideas? unsure.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.