Home | History | Annotate | Download | only in lib
      1 /*
      2  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of 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,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 /**
     17  * @file picodsp.h
     18  *
     19  * Include file for DSP related data types and constants in Pico
     20  *
     21  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
     22  * All rights reserved.
     23  *
     24  * History:
     25  * - 2009-04-20 -- initial version
     26  *
     27  */
     28 
     29 #ifndef PICODSP_H_
     30 #define PICODSP_H_
     31 
     32 #ifdef __cplusplus
     33 extern "C" {
     34 #endif
     35 #if 0
     36 }
     37 #endif
     38 
     39 /*----------------------------CONSTANTS ----------------------*/
     40 /*Normalization factors used at the start and at the end of the sig*/
     41 #define PICODSP_START_FLOAT_NORM      0.41f
     42 #define PICODSP_ENVSPEC_K1            0.5f
     43 #define PICODSP_ENVSPEC_K2            2
     44 #define PICODSP_GETEXC_K1             1024
     45 #define PICODSP_FIXRESP_NORM          4096.0f
     46 #define PICODSP_END_FLOAT_NORM        1.5f*16.0f
     47 #define PICODSP_FIX_SCALE1            0x4000000
     48 #define PICODSP_FIX_SCALE2            0x4000
     49 #define PICODSP_SHIFT_FACT1           10
     50 #define PICODSP_SHIFT_FACT2           16
     51 #define PICODSP_SHIFT_FACT3           12
     52 #define PICODSP_SHIFT_FACT4           1
     53 #define PICODSP_SHIFT_FACT5           18
     54 #define PICODSP_SHIFT_FACT6           9
     55 #define PICOSIG_NORM1                 9.14f /100.0f /*normalization factor*/
     56 #define PICOSIG_MAXAMP                (32767)
     57 #define PICOSIG_MINAMP                (-32768)
     58 #define PICODSP_M_PI        3.14159265358979323846
     59 #define PICODSP_MAX_EX      32
     60 #define PICODSP_WGT_SHIFT  (0x20000000)
     61 #define PICODSP_N_RAND_TABLE (760)
     62 #define PICODSP_COS_TABLE_LEN (512)
     63 #define PICODSP_COS_TABLE_LEN2 (1024)
     64 #define PICODSP_COS_TABLE_LEN4 (2048)
     65 #define PICODSP_PI_SHIFT (4)            /* -log2(PICODSP_COS_TABLE_LEN2/0x4000) */
     66 
     67 #define PICODSP_V_CUTOFF_FREQ  4500
     68 #define PICODSP_UV_CUTOFF_FREQ 300
     69 #define PICODSP_SAMP_FREQ      16000
     70 #define PICODSP_FREQ_WARP_FACT 0.42f
     71 
     72 /*----------------------------CEP/PHASE CONSTANTS----------------------------*/
     73 #define PICODSP_CEPORDER    25
     74 #define PICODSP_PHASEORDER  72
     75 #define CEPST_BUFF_SIZE     3
     76 #define PHASE_BUFF_SIZE     5
     77 /*----------------------------FFT CONSTANTS----------------------------*/
     78 #define PICODSP_FFTSIZE     (256)
     79 
     80 #define PICODSP_H_FFTSIZE   (PICODSP_FFTSIZE/2)
     81 
     82 #define PICODSP_DISPLACE    PICODSP_FFTSIZE/4
     83 
     84 #define PICODSP_H_FFTSIZE   (PICODSP_FFTSIZE/2)
     85 #define PICODSP_HFFTSIZE_P1 (PICODSP_H_FFTSIZE+1)
     86 
     87 #define FAST_DEVICE(aCount, aAction) \
     88 { \
     89     int count_ = (aCount); \
     90     int times_ = (count_ + 7) >> 3; \
     91     switch (count_ & 7){ \
     92         case 0: do { aAction; \
     93         case 7: aAction; \
     94         case 6: aAction; \
     95         case 5: aAction; \
     96         case 4: aAction; \
     97         case 3: aAction; \
     98         case 2: aAction; \
     99         case 1: aAction; \
    100     } while (--times_ > 0); \
    101 } \
    102 }
    103 /*------------------------------------------------------------------------------------------
    104  Fast Exp Approximation now remapped to a function in picoos
    105  -----------------------------------------------------------------------------------------*/
    106 #define EXP(y) picoos_quick_exp(y)
    107 
    108 #ifdef __cplusplus
    109 }
    110 #endif
    111 
    112 #endif /*PICODSP_H_*/
    113