Home | History | Annotate | Download | only in audioquality
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 
     17 #ifndef WINDOW_INTERFACE_H
     18 #define WINDOW_INTERFACE_H
     19 
     20 class Window {
     21 public:
     22     Window(int size) : mWindowWeights(0), mWindowSize(0) {
     23         windowCreate(size);
     24     }
     25 
     26     Window() : mWindowWeights(0), mWindowSize(0) {
     27     }
     28 
     29     virtual ~Window(void) {
     30         windowCleanup();
     31     }
     32 
     33     /* Create a Hann window of length size.  This allocates memory that
     34        should be freed using window_cleanup(). */
     35     void windowCreate(int size);
     36 
     37     /* Free up memory and reset size to 0. */
     38     void windowCleanup(void);
     39 
     40 
     41     /* Multiply the signal in data by the window weights.  Place the
     42        resulting window_size floating-point values in output.  If preemp
     43        is != 0.0, apply a 1st-order preemphasis filter, and assume that
     44        there are window_size+1 samples available in data. */
     45     void window(short* data, float* output, float preemp);
     46 
     47     int getWindowSize() { return mWindowSize; }
     48 
     49     float* getWindowWeights() { return mWindowWeights; }
     50 
     51 private:
     52     float* mWindowWeights;
     53     int mWindowSize;
     54 
     55 };
     56 
     57 #endif /* WINDOW_INTERFACE_H */
     58