# v_resample

## PURPOSE

V_RESAMPLE Resample and remove end transients [y,h]=(x,p,q,n,b)

## SYNOPSIS

function [y,h]=v_resample(x,p,q,n,b)

## DESCRIPTION

    V_RESAMPLE Resample and remove end transients [y,h]=(x,p,q,n,b)

     This multiplies the sample rate of x by p/q. It is identical to resample()
     except that the initial and final filter transients are removed.
     The number of ouput samples will be length(x)*ceil(p/q) - 2*ceil(n*max(p/q,1))
     where the filter length n has a default value of 10.

     Inputs:  x    input signal (or multiple signals with one per column)
              p,q  sampling rate is multiplied by p/q (p and q must be +ve integers)
              n    length of filter [default: 10]
              b    Kaiser window parameter beta [default: 5]

     Outputs: y    resampled output signal
              h    filter used (at a rate of p times the input sample rate)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [y,h]=v_resample(x,p,q,n,b)
    0002 %V_RESAMPLE Resample and remove end transients [y,h]=(x,p,q,n,b)
    0003 %
    0004 % This multiplies the sample rate of x by p/q. It is identical to resample()
    0005 % except that the initial and final filter transients are removed.
    0006 % The number of ouput samples will be length(x)*ceil(p/q) - 2*ceil(n*max(p/q,1))
    0007 % where the filter length n has a default value of 10.
    0008 %
    0009 % Inputs:  x    input signal (or multiple signals with one per column)
    0010 %          p,q  sampling rate is multiplied by p/q (p and q must be +ve integers)
    0011 %          n    length of filter [default: 10]
    0012 %          b    Kaiser window parameter beta [default: 5]
    0013 %
    0014 % Outputs: y    resampled output signal
    0015 %          h    filter used (at a rate of p times the input sample rate)
    0016
    0017 %      Copyright (C) Mike Brookes 2014
    0018 %      Version: $Id: v_resample.m 5119 2014-09-11 07:22:12Z dmb $
    0019 %
    0020 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0021 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0022 %
    0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0024 %   This program is free software; you can redistribute it and/or modify
    0025 %   it under the terms of the GNU Lesser General Public License as published by
    0026 %   the Free Software Foundation; either version 3 of the License, or
    0027 %   (at your option) any later version.
    0028 %
    0029 %   This program is distributed in the hope that it will be useful,
    0030 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0031 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0032 %   GNU Lesser General Public License for more details.
    0033 %
    0034 %   You can obtain a copy of the GNU Lesser General Public License from
    0035 %   https://www.gnu.org/licenses/ .
    0036 %
    0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0038 if p==q
    0039     y=x;
    0040     h=1;
    0041 else
    0042     if nargin < 5,  b = 5;  end   % design parameter for Kaiser window LPF
    0043     if nargin < 4,   n = 10;   end
    0044     [y,h]=resample(x,p,q,n,b);
    0045     m=ceil(n*max(p/q,1));
    0046     if size(x,1)==1 % x is a row vector
    0047         y=y(m+1:end-m);
    0048     else
    0049         y=y(m+1:end-m,:);
    0050     end
    0051 end