[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/amarok/amarok/analyzers
From:       Adam Pigg <adam () piggz ! fsnet ! co ! uk>
Date:       2004-01-15 20:24:00
Message-ID: 20040115202400.AFE5E3562 () office ! kde ! org
[Download RAW message or body]

CVS commit by piggz: 

Should now be height aware


  M +20 -10    baranalyzer2.cpp   1.5
  M +2 -1      baranalyzer2.h   1.4


--- kdenonbeta/amarok/amarok/analyzers/baranalyzer2.cpp  #1.4:1.5
@@ -67,14 +67,23 @@ void BarAnalyzer2::init()
   p.eraseRect( 0, 0, m_pSrcPixmap->width(), m_pSrcPixmap->height() );
 
-  m_lvlMap.resize(50, 0);
+  m_lvlMap.resize(height() , 0);
   m_barArray.resize(width() - 20, 0);
+  m_bands.resize(width() - 20, 0);
   m_peakArray.resize(width() - 20);
   
-  //generate a list of values that express amplitudes in range 0-MAX_AMP as ints \
from 0-height() on log scale +  //Maybe use this in the future
+  //A frequency level mapper to boost frequencies for display purposes
+  /*m_freqMap.resize(width() - 20, 0);
+  
+  for (uint i = 0; i < uint(width() - 20); i++)
+  {
+        m_freqMap[i] = (((0/(width() - 20)) * i) + 1);
+  }*/
+  
+  //generate a list of values that express amplitudes in range 0-MAX_AMP as ints \
from 0-height() on square scale  m_lvlMap[0] = 0;
-  for( uint x = 1; x < 50; x++ )
+  for( uint x = 1; x < height(); x++ )
   {
-    m_lvlMap[x] = uint(-(((x-50)*(x-50))/50)+50-1);
-    kdDebug() << "X=" << x << " Y=" << m_lvlMap[x] << endl;
+    m_lvlMap[x] = uint(-(((x-height())*(x-height()))/height())+height()-1);
   }
     
@@ -97,17 +106,18 @@ void BarAnalyzer2::drawAnalyzer( std::ve
   int change;
   
-  std::vector<float> bands(width() - 20, 0);
-
   if ( s )
   {
-    interpolate( s, bands ); //if no s then we are paused/stopped
+    interpolate( s, m_bands ); //if no s then we are paused/stopped
   }
   
   bitBlt( m_pComposePixmap, 0, 0, grid() ); //start with a blank canvas
 
-  for ( uint i = 0, x = 10; i < bands.size(); ++i, x++ )
+  for ( uint i = 0, x = 10; i < m_bands.size(); ++i, x++ )
   {
     //note: values in bands can be greater than 1!
-    newval = uint(bands[i] * 49);
+    newval = uint((m_bands[i] * (height()-1)) /** m_freqMap[i]*/);
+    if (newval > height()-1)
+      newval = height() - 1;
+      
     newval = m_lvlMap[newval];
     change = newval - m_barArray[i];

--- kdenonbeta/amarok/amarok/analyzers/baranalyzer2.h  #1.3:1.4
@@ -63,5 +63,6 @@ protected:
   std::vector<uint> m_barArray;;
   std::vector<uint> m_lvlMap;
-  
+  std::vector<float> m_bands;
+  //std::vector<float> m_freqMap; //See .cpp file init() for description 
 };
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic