ReMAS  1.5
Real-time Musical Accompaniment System
Functions
CPUFunctions.c File Reference

File with code of ReMAS functions for CPU, both x86_64 and ARM. More...

#include "CPUFunctions.h"
#include "FileFunctions.h"

Go to the source code of this file.

Functions

void ApplyWindow (MyType *__restrict X_fft, const short *frame, const MyType *v_hanning, const int framesize, const int xfftsize)
 ApplyWindow applies hanning window to the current frame and store the result en vector X_fft. More...
 
void ComputeNorms (MyType *norms, MyType *ts_fk, const MyType *s_fk, const int nmidi, const int nbases, const MyType beta)
 ComputeNorms fills norms vector. More...
 
int AllocAuxiCPU (MyType **norms, short **frame, MyType **v_cfreq, MyType **v_dxState, const int nbases, const int tamframe, const int nmidi)
 AllocAuxiCPU Memory reservation for norms, frame, v_cfreq and v_dxState vectors. More...
 
int AllocFFTCPU (MyFFTCPUType *plan, MyType **X_fft, MyType **Out_fft, MyType **Mod_fft, int *kmin_fft, int *kmax_fft, const int nfft, DTWfiles NameFiles)
 AllocFFTCPU Allocates memory for FFT vector and reads some fft information from files. More...
 
int AllocS_fkCPU (MyType **s_fk, MyType **tauxi, MyType **ts_fk, const MyType BETA, const int nmidi, const int nbases, DTWfiles NameFiles)
 AllocS_fkCPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar vectors. More...
 
int AllocDTWCPU (MyType **pV, MyType **v_SxD, const int DTWSize, const int DTWSizePlusPad, const int startin)
 AllocDTWCPU Allocates memory for DTW vectors and initializes them. More...
 
int AllocDataCPU (MyType **v_hanning, int **states_time_i, int **states_time_e, int **states_seq, int **states_corr, int **I_SxD, int *DTWSize, const int tamframe, const int nstates, DTWfiles NameFiles)
 AllocDataCPU creates and initializes some structures reading info from files. More...
 
void FFT (MyType *v_cfreq, const int *kmin, const int *kmax, MyType *X_fft, MyType *Mod_fft, MyType *Out_fft, MyFFTCPUType plan, const int nfft, const int nmidi)
 FFT computes FFT and updates v_cfreq vector. More...
 
int SeqIdamin (const int N, const MyType *v)
 SeqIdamin returns the pos of the minimum in a vector. More...
 
int DTWProc (const MyType *Sequence, const MyType *Costs, MyType *__restrict pD, const int NSeq, const int Where, const int NST)
 DTWProc performs the Online-DTW process for the current frame. More...
 
void ApplyDist (const MyType *v_dxState, MyType *v_SxD, const int *I_SxD, const int size, const MyType ALPHA)
 ApplyDist applies distortion. More...
 
void ComputeDist (const MyType *v_cfreq, MyType *__restrict v_dxStates, MyType *tauxi, const MyType *norms, const MyType *s_fk, const MyType *ts_fk, const MyType BETA, const int nbases, const int nmidi)
 ComputeDist computes distortion. More...
 
int ReadWavCPU1st (short *frame, FILE *fp)
 ReadWavCPU1st reads first audio (frame) from WAV file when ARM is used. More...
 
int ReadWavCPU (short *frame, FILE *fp)
 ReadWavCPU reads current audio (frame) from WAV file when ARM is used. More...
 
void BetaNorm (MyType *v_cfreq, const int nmidi, MyType BETA)
 BetaNorm normalizes v_cfreq vector to have beta-norm 1. More...
 

Detailed Description

File with code of ReMAS functions for CPU, both x86_64 and ARM.

Author
Information Retrieval and Parallel Computing Group, University of Oviedo, Spain
Interdisciplinary Computation and Communication Group, Universitat Politecnica de Valencia, Spain
Signal Processing and Telecommunication Systems Research Group, University of Jaen, Spain.
Contact: remas.nosp@m.pack.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
February 13, 2017

Definition in file CPUFunctions.c.

Function Documentation

◆ AllocAuxiCPU()

int AllocAuxiCPU ( MyType **  norms,
short **  frame,
MyType **  v_cfreq,
MyType **  v_dxState,
const int  nbases,
const int  tamframe,
const int  nmidi 
)

AllocAuxiCPU Memory reservation for norms, frame, v_cfreq and v_dxState vectors.

Parameters
norms(out) Norms vector
frame(out) Vector for frames
v_cfreq(out) v_cfreq vector
v_dxState(out) v_dxState vector
nbases(in) Number of bases/combinations, sizeof norms and v_dxState
tamframe(in) Size of frames in samples
nmidi(in) Number of midi notes, sizeof v_cfreq
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 152 of file CPUFunctions.c.

◆ AllocDataCPU()

int AllocDataCPU ( MyType **  v_hanning,
int **  states_time_i,
int **  states_time_e,
int **  states_seq,
int **  states_corr,
int **  I_SxD,
int *  DTWSize,
const int  tamframe,
const int  nstates,
DTWfiles  NameFiles 
)

AllocDataCPU creates and initializes some structures reading info from files.

Parameters
v_hanning(out) v_hanning vector
states_time_i(out) states_time_i vector, contains the start-time of each state in frames
states_time_e(out) states_time_e vector, contains the end-time of each state in frames
states_seq(out) states_seq vector, contains the base/combination that is performed in each state
states_corr(out) states_corr vector
I_SxD(out) I_SxD vector
DTWSize(in) Size of DTW vectors
tamframe(in) Size of frames in samples
nstates(in) Number of states
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 310 of file CPUFunctions.c.

◆ AllocDTWCPU()

int AllocDTWCPU ( MyType **  pV,
MyType **  v_SxD,
const int  DTWSize,
const int  DTWSizePlusPad,
const int  startin 
)

AllocDTWCPU Allocates memory for DTW vectors and initializes them.

Parameters
pV(out) DTW pV vector
v_SxD(out) v_SxD vector
DTWSize(in) Size of DTW vectors
DTWSizePlusPad(in) Size of DTW vectors plus padding
startin(in) Where we start to store data within circular-buffer
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 270 of file CPUFunctions.c.

◆ AllocFFTCPU()

int AllocFFTCPU ( MyFFTCPUType *  plan,
MyType **  X_fft,
MyType **  Out_fft,
MyType **  Mod_fft,
int *  kmin_fft,
int *  kmax_fft,
const int  nfft,
DTWfiles  NameFiles 
)

AllocFFTCPU Allocates memory for FFT vector and reads some fft information from files.

Parameters
plan(out) FFT scheduler
X_fft(out) X_fft vector
Out_fft(out) Out_fft vector
Mod_fft(out) Mod_fft vector
kmin_fft(out) Where kmin_fft is stored
kmax_fft(out) Where kmax_fft is stored
nfft(in) As is to be, Mod_fft and Out_fft size
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 177 of file CPUFunctions.c.

◆ AllocS_fkCPU()

int AllocS_fkCPU ( MyType **  s_fk,
MyType **  tauxi,
MyType **  ts_fk,
const MyType  BETA,
const int  nmidi,
const int  nbases,
DTWfiles  NameFiles 
)

AllocS_fkCPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar vectors.

Parameters
s_fk(out) s_fk vector
tauxi(out) Auxiliar vector tauxi
ts_fk(out) Auxiliar vector ts_fk
BETA(in) BETA value
nmidi(in) Number of midi notes
nbases(in) Number of bases/combinations
NameFiles(in) Struct with the file names
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 231 of file CPUFunctions.c.

◆ ApplyDist()

void ApplyDist ( const MyType *  v_dxState,
MyType *  v_SxD,
const int *  I_SxD,
const int  size,
const MyType  ALPHA 
)

ApplyDist applies distortion.

Parameters
v_dxState(in) v_dxState vector
v_SxD(out) v_SxD vector
I_SxD(in) I_SxD vector
size(in) Size of the vectors
ALPHA(in) ALPHA value
Returns
: Nothing, it is void

Definition at line 550 of file CPUFunctions.c.

◆ ApplyWindow()

void ApplyWindow ( MyType *__restrict  X_fft,
const short *  frame,
const MyType *  v_hanning,
const int  framesize,
const int  xfftsize 
)

ApplyWindow applies hanning window to the current frame and store the result en vector X_fft.

Parameters
X_fft(out) Vector X_fft to update
frame(in) Vector with current frame
v_hanning(in) Hanning vector
framesize(in) Size of the frame
xfftsize(in) Size of the vector X_fft
Returns
: Nothing, it is void

Definition at line 48 of file CPUFunctions.c.

◆ BetaNorm()

void BetaNorm ( MyType *  v_cfreq,
const int  nmidi,
MyType  BETA 
)

BetaNorm normalizes v_cfreq vector to have beta-norm 1.

Parameters
v_cfreq(inout) v_cfreq vector
BETA(in) BETA value
nmidi(in) Number of midi notes
Returns
: Nothing, it is void

Definition at line 817 of file CPUFunctions.c.

◆ ComputeDist()

void ComputeDist ( const MyType *  v_cfreq,
MyType *__restrict  v_dxStates,
MyType *  tauxi,
const MyType *  norms,
const MyType *  s_fk,
const MyType *  ts_fk,
const MyType  BETA,
const int  nbases,
const int  nmidi 
)

ComputeDist computes distortion.

Parameters
v_cfreq(in) v_cfreq vector
v_dxStates(out) v_dxStates vector
tauxi(out) tauxi vector
norms(in) norms vector
s_fk(in) s_fk vector
ts_fk(in) ts_fk vector
BETA(in) BETA value
nbases(in) Number of bases/combinations
nmidi(in) Number of midi notes
Returns
: Nothing, it is void

Definition at line 600 of file CPUFunctions.c.

◆ ComputeNorms()

void ComputeNorms ( MyType *  norms,
MyType *  ts_fk,
const MyType *  s_fk,
const int  nmidi,
const int  nbases,
const MyType  beta 
)

ComputeNorms fills norms vector.

Parameters
norms(out) Vector with the norms
ts_fk(in) Auxiliar vector
s_fk(in) Vector s_fk
nmidi(in) Number of midi notes
nbases(in) Number of bases/combinations
beta(in) BETA value
Returns
: Nothing, it is void

Definition at line 73 of file CPUFunctions.c.

◆ DTWProc()

int DTWProc ( const MyType *  Sequence,
const MyType *  Costs,
MyType *__restrict  pD,
const int  NSeq,
const int  Where,
const int  NST 
)

DTWProc performs the Online-DTW process for the current frame.

Parameters
Sequence(in) Currente frame
Costs(in) Vector with DTW path-costs
pD(out) DTW pD vector
NSeq(in) One referenced position within DTW vectors
Where(in) Position within DTW vectors
NST(in) Number of states
Returns
: Position of the minimun

Definition at line 485 of file CPUFunctions.c.

◆ FFT()

void FFT ( MyType *  v_cfreq,
const int *  kmin,
const int *  kmax,
MyType *  X_fft,
MyType *  Mod_fft,
MyType *  Out_fft,
MyFFTCPUType  plan,
const int  nfft,
const int  nmidi 
)

FFT computes FFT and updates v_cfreq vector.

Parameters
v_cfreq(out) v_cfreq vector
kmin(input) kmin vector
kmax(input) kmax vector
X_fft(inout) X_fft vector
Mod_fft(inout) Mod_fft vector
Out_fft(inout) Out_fft vector
plan(out) FFT scheduler
nfft(in) As is to be, Mod_fft and Out_fft size
nmidi(in) Number of midi notes
Returns
: Nothing, it is void

Definition at line 356 of file CPUFunctions.c.

◆ ReadWavCPU()

ReadWavCPU ( short *  frame,
FILE *  fp 
)

ReadWavCPU reads current audio (frame) from WAV file when ARM is used.

Parameters
frame(out) Vector to store the current frame
fp(in) ID of file with data
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 756 of file CPUFunctions.c.

◆ ReadWavCPU1st()

ReadWavCPU1st ( short *  frame,
FILE *  fp 
)

ReadWavCPU1st reads first audio (frame) from WAV file when ARM is used.

Parameters
frame(out) Vector to store the first frame
fp(in) ID of file with the information
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 742 of file CPUFunctions.c.

◆ SeqIdamin()

int SeqIdamin ( const int  N,
const MyType *  v 
)

SeqIdamin returns the pos of the minimum in a vector.

When minimum's number of occurrences > 1 => returns the position of the 1st occurrence

Parameters
N(in) Vector size
v(in) The vector
Returns
: The pos of the minimum

Definition at line 462 of file CPUFunctions.c.