Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
30 results

samplerateconverter.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    samplerateconverter.h 3.00 KiB
    /*
     *  Copyright (C) 2008 Savoir-Faire Linux inc.
     *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
     * 
     *  This program is free software; you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation; either version 3 of the License, or
     *  (at your option) any later version.
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU General Public License for more details.
     * 
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
     *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     */
    
    #ifndef _SAMPLE_RATE_H
    #define _SAMPLE_RATE_H
    
    #include <samplerate.h>
    #include <math.h>
    
    #include "global.h"
    #include "manager.h"
    
    class SamplerateConverter {
      public:
        /** Constructor */
        SamplerateConverter( void );
        SamplerateConverter( int freq , int fs );
        /** Destructor */
        ~SamplerateConverter( void );
    
        /** 
         * Upsample from the samplerate1 to the samplerate2
         * @param data  The data buffer
         * @param SamplerateConverter1 The lower sample rate
         * @param SamplerateConverter2 The higher sample rate
         * @param nbSamples	  The number of samples to process
         * @return int The number of samples after the operation
         */
        int upsampleData( SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples );
    
        /**
         * Downsample from the samplerate1 to the samplerate2
         * @param data  The data buffer
         * @param SamplerateConverter1 The lower sample rate
         * @param SamplerateConverter2 The higher sample rate
         * @param nbSamples	  The number of samples to process
         * @return int The number of samples after the operation
         */
        int downsampleData( SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples );
    
        int getFrequence( void ) { return _frequence; }
    
        int getFramesize( void ) { return _framesize; } 
    
      private:
        // Copy Constructor
        SamplerateConverter(const SamplerateConverter& rh);
    
        // Assignment Operator
        SamplerateConverter& operator=( const SamplerateConverter& rh);
        
        void init( void );
    
        /** Audio layer caracteristics */
        int _frequence;
        int _framesize;
    
        /** Downsampled/Upsampled float buffers for the mic data processing */
        float32* _floatBufferDownMic;
        float32* _floatBufferUpMic;
        /** libSamplerateConverter converter for outgoing voice */
        SRC_STATE*    _src_state_mic;
    
        /** Downsampled/Upsampled float buffers for the speaker data processing */
        float32* _floatBufferDownSpkr;
        float32* _floatBufferUpSpkr;
        /** libSamplerateConverter converter for incoming voice */
        SRC_STATE*    _src_state_spkr;
        /** libSamplerateConverter error */
        int _src_err;
    };
    
    #endif //_SAMPLE_RATE_H