# v_rfft

## PURPOSE

V_RFFT Calculate the DFT of real data Y=(X,N,D)

## SYNOPSIS

function y=v_rfft(x,n,d)

## DESCRIPTION

    V_RFFT     Calculate the DFT of real data Y=(X,N,D)
     Data is truncated/padded to length N if specified.
       N even:    (N+2)/2 points are returned with
                 the first and last being real
       N odd:    (N+1)/2 points are returned with the
                 first being real
     In all cases floor(1+N/2) points are returned
     D is the dimension along which to do the DFT

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- v_fxrapt V_FXRAPT RAPT pitch tracker [FX,VUV]=(S,FS,M,Q)
- v_lpcar2db V_LPCAR2DB LPC: Convert AR coefs to power spectrum in dB DB=(AR)
- v_lpcar2ff V_LPCAR2FF LPC: Convert AR coefs to complex spectrum FF=(AR,NP)
- v_lpcar2pf V_LPCAR2PF Convert AR coefs to power spectrum PF=(AR,NP)
- v_lpccc2db V_LPCCC2DB Convert complex cepstrum to dB power spectrum DB=(CC,NP,NC)
- v_lpccc2ff V_LPCCC2FF Convert complex cepstrum to complex spectrum FF=(CC,NP,NC)
- v_lpccc2pf V_LPCCC2PF Convert complex cepstrum to power spectrum PF=(CC,NP,NC)
- v_lpcra2pf V_LPCAR2PF Convert AR coefs to power spectrum PF=(RA,NP)
- v_modspect V_MODSPECT Calculate the modulation spectrum of a signal C=(S,FS,W,NC,P,N,INC,FL,FH)
- v_sigalign V_SIGALIGN align a clean reference with a noisy signal [d,g,rr,ss]=(s,r,maxd,m,fs)
- v_specsub V_SPECSUB performs speech enhancement using spectral subtraction [SS,ZO]=(S,FSZ,P)
- v_specsubm V_SPECSUBM obsolete speech enhancement algorithm - use v_specsub instead
- v_spendred V_SPENDRED Speech Enhancement and Dereverberation by Doire
- v_spgrambw V_SPGRAMBW Draw spectrogram [T,F,B]=(s,fs,mode,bw,fmax,db,tinc,ann)
- v_ssubmmse V_SSUBMMSE performs speech enhancement using mmse estimate of spectral amplitude or log amplitude [SS,ZO]=(S,FSZ,PP)
- v_ssubmmsev V_SSUBMMSE performs speech enhancement using mmse estimate of spectral amplitude or log amplitude [SS,ZO]=(S,FSZ,P)
- v_stftw V_STFTW converts a time-domain signal into the time-frequency domain with the Short-time Fourier Transform [Y,SO,T,F]=(X,NW,M,OV)
- v_vadsohn V_VADSOHN implements a voice activity detector [VS,ZO]=(S,FSZ,M,P)

## SOURCE CODE

    0001 function y=v_rfft(x,n,d)
    0002 %V_RFFT     Calculate the DFT of real data Y=(X,N,D)
    0003 % Data is truncated/padded to length N if specified.
    0004 %   N even:    (N+2)/2 points are returned with
    0005 %             the first and last being real
    0006 %   N odd:    (N+1)/2 points are returned with the
    0007 %             first being real
    0008 % In all cases floor(1+N/2) points are returned
    0009 % D is the dimension along which to do the DFT
    0010
    0011 %      Copyright (C) Mike Brookes 1998
    0012 %      Version: $Id: v_rfft.m 10865 2018-09-21 17:22:45Z dmb $
    0013 %
    0014 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0015 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0016 %
    0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0018 %   This program is free software; you can redistribute it and/or modify
    0019 %   it under the terms of the GNU Lesser General Public License as published by
    0020 %   the Free Software Foundation; either version 3 of the License, or
    0021 %   (at your option) any later version.
    0022 %
    0023 %   This program is distributed in the hope that it will be useful,
    0024 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0025 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0026 %   GNU Lesser General Public License for more details.
    0027 %
    0028 %   You can obtain a copy of the GNU Lesser General Public License from
    0029 %   https://www.gnu.org/licenses/ .
    0030 %
    0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0032
    0033 s=size(x);
    0034 if prod(s)==1
    0035     y=x
    0036 else
    0037     if nargin <3 || isempty(d)
    0038         d=find(s>1,1);
    0039         if nargin<2
    0040             n=s(d);
    0041         end
    0042     end
    0043     if isempty(n)
    0044         n=s(d);
    0045     end
    0046     y=fft(x,n,d);
    0047     y=reshape(y,prod(s(1:d-1)),n,prod(s(d+1:end)));
    0048     s(d)=1+fix(n/2);
    0049     y(:,s(d)+1:end,:)=[];
    0050     y=reshape(y,s);
    0051 end