Plotting window functions

This is a very simple way to get a preview of window function shape. The example uses Aquila::TextPlot as a drawing tool. Windows are drawn as simple asterisk patterns.

#include "aquila/transform/Window.h"
#include "aquila/tools/TextPlot.h"

int main(int argc, char *argv[])
{
    Aquila::WindowType types[] = {Aquila::WIN_RECT, Aquila::WIN_HAMMING,
                                  Aquila::WIN_HANN, Aquila::WIN_BARLETT,
                                  Aquila::WIN_BLACKMAN, Aquila::WIN_FLATTOP};
    const char* names[] = {"Rectangular", "Hamming",
                           "Hann", "Barlett",
                           "Blackman", "Flat-top"};
    const std::size_t length = 65;
    int num = sizeof(types) / sizeof(Aquila::WindowType);

    Aquila::TextPlot plot;
    for (int i = 0; i < num; ++i)
    {
        Aquila::Window window(types[i], length);
        plot.setTitle(names[i]);
        plot.plot(window.getData());
    }

    return 0;
}

The windows are plotted below for comparison. Note: the rectangular window is improperly scaled at the moment and looks like it's all zeros. It isn't, that is a constant 1.

Rectangular















*****************************************************************

Hamming
                           ***********                           
                         **           **                         
                       **               **                       
                      *                   *                      
                    **                     **                    
                   *                         *                   
                  *                           *                  
                 *                             **                
               **                                *               
              *                                   *              
             *                                     *             
           **                                       **           
          *                                           *          
        **                                             **        
      **                                                 **      
******                                                     ******

Hann
                           ***********                           
                         **           **                         
                       **               **                       
                      *                   *                      
                    **                     **                    
                   *                         *                   
                  *                           *                  
                 *                             **                
               **                                *               
              *                                   *              
             *                                     *             
           **                                       **           
          *                                           *          
        **                                             **        
      **                                                 **      
******                                                     ******

Barlett
                               ***                               
                             **   **                             
                           **       **                           
                         **           **                         
                       **               **                       
                     **                   **                     
                   **                       **                   
                 **                           **                 
               **                               **               
             **                                   **             
           **                                       **           
         **                                           **         
       **                                               **       
     **                                                   **     
   **                                                       **   
***                                                           ***

Blackman
                            *********                            
                           *         *                           
                         **           **                         
                        *               *                        
                       *                 *                       
                      *                   *                      
                     *                     *                     
                    *                       *                    
                  **                         **                  
                 *                             *                 
                *                               *                
               *                                 *               
             **                                   **             
           **                                       **           
        ***                                           ***        
********                                                 ********

Flat-top
                              *****                              
                             *     *                             
                            *       *                            
                           *         *                           

                          *           *                          
                         *             *                         

                        *               *                        
                       *                 *                       

                      *                   *                      
                     *                     *                     
                    *                       *                    
****              **                         **              ****
    **************                             **************
« Return to list

Comments

blog comments powered by Disqus